Skip to content

Conversation

VT-14
Copy link
Collaborator

@VT-14 VT-14 commented Sep 29, 2023

BlockSpectral.tick was no longer being called. Set up BlockSpectra.getTicker and moved tick logic to TileSpectral.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.

`BlockSpectral.tick` was no longer being called.  Set up `BlockSpectra.getTicker` and moved tick logic to `TileSpectral.tick`.
@dphaldes
Copy link
Contributor

Why is the functionality moved to the BE ? I don't think this requires a BE

@VT-14
Copy link
Collaborator Author

VT-14 commented Oct 10, 2023

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.

@dphaldes
Copy link
Contributor

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)

@WayofTime
Copy link
Owner

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);
Copy link
Contributor

@dphaldes dphaldes Mar 16, 2024

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);
Copy link
Contributor

@dphaldes dphaldes Mar 16, 2024

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();
Copy link
Contributor

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

Comment on lines +89 to +92

public void tick()
{
BlockState state = this.getBlockState();
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants