-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Spectral Block/Tile #1979
base: 1.20.1
Are you sure you want to change the base?
Conversation
`BlockSpectral.tick` was no longer being called. Set up `BlockSpectra.getTicker` and moved tick logic to `TileSpectral.tick`.
Why is the functionality moved to the BE ? I don't think this requires a BE |
It has been two weeks since I did it, but IIRC it is more consistent with the other Block Entities (Tiles) in the mod (I looked at the Hellfire Forge when trying to work out how it is supposed to work), and the BE had the data like State, Position, and Level already in it. |
oh okay! Then it makes sense. Move the blockEntity type check from block to BE for consistency as well (Other mods do it in BE as well) |
While this does technically work, the fluid seems to revert way too quickly. Ideally we would want a solution that makes it not revert at all while the player is around, such as by resetting the decaying process. This was done previously by having it handled by the TileEntity (are they called Block Entity or BE now?), and the sigil would refresh the TE's progress. |
switch (state.getValue(SPECTRAL_STATE)) { | ||
case SOLID -> { | ||
level.setBlock(pos, state.setValue(SPECTRAL_STATE, SpectralBlockType.LEAKING), 3); | ||
level.scheduleTick(pos, state.getBlock(), BlockSpectral.DECAY_RATE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scheduleTick
is not required anymore
Level level = this.getLevel(); | ||
switch (state.getValue(SPECTRAL_STATE)) { | ||
case SOLID -> { | ||
level.setBlock(pos, state.setValue(SPECTRAL_STATE, SpectralBlockType.LEAKING), 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of '3' use the proper flag (Block.UPDATE_ALL). They are present in Block.java
.
if (tile instanceof TileSpectral) | ||
{ | ||
((TileSpectral) tile).revertToFluid(); | ||
((TileSpectral) tile).tick(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should pass the blockPos, level and tile from the lambda into the tick
method instead of fetching them in the method. Also use the automatic cast when using instanceof
instead of manual casting
|
||
public void tick() | ||
{ | ||
BlockState state = this.getBlockState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason the blocks vanish so quickly is that the BE is ticked every tick. Instead, use a tick_counter and check against the DECAY_RATE and only then tick it.
BlockSpectral.tick
was no longer being called. Set upBlockSpectra.getTicker
and moved tick logic toTileSpectral.tick
. This makes the Spectral Block decay back into the fluid block.Currently needs review to ensure it works as intended. Other changes may be required (ex.
canBeReplaced
is depreciated).Fixes #1978.