Skip to content
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

Draft
wants to merge 1 commit into
base: 1.20.1
Choose a base branch
from

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`.
@mystchonky
Copy link

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.

@mystchonky
Copy link

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

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

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();

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();

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.

None yet

3 participants