Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Nov 13, 2023
1 parent 5b2e87b commit d2d28a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @N
level.setBlockAndUpdate(pos, state.setValue(DISPLAY_LIGHT, Mth.clamp(lantern.getFireflies().size() * 3, 0, 15)));
level.playSound(null, pos, RegisterSounds.ITEM_BOTTLE_PUT_IN_LANTERN_FIREFLY, SoundSource.BLOCKS, 1.0F, level.random.nextFloat() * 0.2F + 0.9F);
lantern.updateSync();
level.updateNeighbourForOutputSignal(pos, this);
return InteractionResult.SUCCESS;
}
}
Expand All @@ -145,6 +146,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @N
((DisplayLanternBlockEntity) entity).removeFirefly(fireflyInLantern);
level.setBlockAndUpdate(pos, state.setValue(DISPLAY_LIGHT, Mth.clamp(lantern.getFireflies().size() * 3, 0, 15)));
lantern.updateSync();
level.updateNeighbourForOutputSignal(pos, this);
return InteractionResult.SUCCESS;
}
}
Expand All @@ -158,6 +160,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @N
level.setBlockAndUpdate(pos, state.setValue(DISPLAY_LIGHT, Mth.clamp(light, 0, 15)));
lantern.inventory.set(0, stack.split(1));
lantern.updateSync();
level.updateNeighbourForOutputSignal(pos, this);
return InteractionResult.SUCCESS;
}
} else if (lantern.noFireflies()) {
Expand All @@ -167,6 +170,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @N
lantern.inventory.clear();
lantern.updateSync();
level.setBlockAndUpdate(pos, state.setValue(DISPLAY_LIGHT, 0));
level.updateNeighbourForOutputSignal(pos, this);
return InteractionResult.SUCCESS;
}
}
Expand Down Expand Up @@ -237,6 +241,7 @@ public void onRemove(@NotNull BlockState state, @NotNull Level level, @NotNull B
popResource(level, pos, item);
}
lantern.inventory.clear();
level.updateNeighbourForOutputSignal(pos, this);
}
}
super.onRemove(state, level, pos, newState, isMoving);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public void addFirefly(@NotNull LevelAccessor levelAccessor, @NotNull FireflyBot
Vec3 newVec = new Vec3(0.5 + (0.15 - random.nextDouble() * 0.3), 0, 0.5 + (0.15 - random.nextDouble() * 0.3));
var firefly = new FireflyInLantern(newVec, bottle.color, name, random.nextDouble() > 0.7, random.nextInt(20), 0);
this.fireflies.add(firefly);
if (this.level != null) {
this.level.updateNeighbourForOutputSignal(this.getBlockPos(), this.getBlockState().getBlock());
}
}

public void removeFirefly(@NotNull FireflyInLantern firefly) {
Expand Down Expand Up @@ -200,7 +203,7 @@ private void doFireflySpawns(@NotNull Level level) {
}

public int getComparatorOutput() {
if (this.invEmpty()) {
if (!this.invEmpty()) {
return 15;
}
if (!this.noFireflies()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static void serverStoneTick(@NotNull Level level, BlockPos pos, @NotNull
if (stoneChest.stillLidTicks > 0) {
stoneChest.stillLidTicks -= 1;
} else if (stoneChest.openProgress > 0F) {
level.updateNeighbourForOutputSignal(pos, stoneChest.getBlockState().getBlock());
serverLevel.gameEvent(null, GameEvent.CONTAINER_CLOSE, pos);
stoneChest.openProgress = Math.max(0F, stoneChest.openProgress - 0.0425F);
if (!stoneChest.closing) {
Expand Down Expand Up @@ -191,12 +192,18 @@ public void liftLid(float liftAmount, boolean ancient) {
this.openProgress = Mth.clamp(this.openProgress + (!ancient ? liftAmount * 2 : liftAmount), 0.0F, 0.5F);
this.highestLidPoint = this.openProgress;
this.stillLidTicks = (int) (Math.max((this.openProgress), 0.2) * (!ancient ? 220 : 160) * BlockConfig.get().stoneChest.getStoneChestTimer());
if (this.level != null) {
this.level.updateNeighbourForOutputSignal(this.getBlockPos(), this.getBlockState().getBlock());
}
}

public void setLid(float liftAmount) {
this.openProgress = Mth.clamp(liftAmount, 0.0F, 0.5F);
this.highestLidPoint = this.openProgress;
this.stillLidTicks = (int) (Math.max((this.openProgress), 0.2) * 180 * BlockConfig.get().stoneChest.getStoneChestTimer());
if (this.level != null) {
this.level.updateNeighbourForOutputSignal(this.getBlockPos(), this.getBlockState().getBlock());
}
}

public int getComparatorOutput() {
Expand Down Expand Up @@ -230,7 +237,7 @@ public boolean stillValid(@NotNull Player player) {

public void syncLidValuesWith(@Nullable StoneChestBlockEntity otherStoneChest) {
if (otherStoneChest != null) {
syncValues(otherStoneChest);
this.syncValues(otherStoneChest);
otherStoneChest.updateSync();
}
this.updateSync();
Expand All @@ -248,6 +255,9 @@ public void updateSync() {
}

private void syncValues(@NotNull StoneChestBlockEntity otherStoneChest) {
if (otherStoneChest.openProgress != this.openProgress && this.level != null) {
this.level.updateNeighbourForOutputSignal(otherStoneChest.getBlockPos(), otherStoneChest.getBlockState().getBlock());
}
otherStoneChest.openProgress = this.openProgress;
otherStoneChest.prevOpenProgress = this.prevOpenProgress;
otherStoneChest.highestLidPoint = this.highestLidPoint;
Expand Down

0 comments on commit d2d28a8

Please sign in to comment.