mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-04-21 02:03:13 +00:00
Remove usages of onNeighborChange
Oh. This is from ye olde days (it's one of the first PRs to CC[^1]!). In pre-1.13 days, furnaces changing their lit state would replace the block (creating a new BE) and then set back the old BE. CC wouldn't pick up the second event, and so would continue to use the peripheral from the first. We don't really need this any more, for a couple of reasons: a) Furnaces don't do this any more. b) Peripherals are now refreshed on the next tick rather than immediately. c) Forge's capabilities have an explicit invalidate() hook already. This technically only detects *removing* block entities, but I'm not sure there's any cases where you add a block entity without also triggering a block state change. Ironically, the place we probably need this more is Fabric, where the lookup API doesn't have a public invalidate hook (it's hidden away in the BlockApiCache). I'm mostly relying on c) here, in that we just won't see this happen in practice. [^1]: https://github.com/dan200/ComputerCraft/pull/180
This commit is contained in:
parent
63ba3fe274
commit
676fb5fb53
@ -4,7 +4,6 @@
|
||||
|
||||
package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.annotations.ForgeOverride;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.common.IBundledRedstoneBlock;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
@ -25,7 +24,6 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
@ -177,12 +175,6 @@ public abstract class AbstractComputerBlock<T extends AbstractComputerBlockEntit
|
||||
if (be instanceof AbstractComputerBlockEntity computer) computer.neighborChanged(neighbourPos);
|
||||
}
|
||||
|
||||
@ForgeOverride
|
||||
public final void onNeighborChange(BlockState state, LevelReader world, BlockPos pos, BlockPos neighbour) {
|
||||
var be = world.getBlockEntity(pos);
|
||||
if (be instanceof AbstractComputerBlockEntity computer) computer.neighborChanged(neighbour);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) {
|
||||
|
@ -260,11 +260,6 @@ public class CableBlock extends Block implements SimpleWaterloggedBlock, EntityB
|
||||
if (world.getBlockEntity(pos) instanceof CableBlockEntity modem) modem.neighborChanged(neighbourPos);
|
||||
}
|
||||
|
||||
@ForgeOverride
|
||||
public final void onNeighborChange(BlockState state, LevelReader world, BlockPos pos, BlockPos neighbour) {
|
||||
if (world.getBlockEntity(pos) instanceof CableBlockEntity modem) modem.neighborChanged(neighbour);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource rand) {
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import dan200.computercraft.annotations.ForgeOverride;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@ -15,7 +14,6 @@ import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
@ -66,13 +64,6 @@ public class WiredModemFullBlock extends Block implements EntityBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeOverride
|
||||
public final void onNeighborChange(BlockState state, LevelReader level, BlockPos pos, BlockPos neighbour) {
|
||||
if (state.getValue(PERIPHERAL_ON) && level.getBlockEntity(pos) instanceof WiredModemFullBlockEntity modem) {
|
||||
modem.neighborChanged(neighbour);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource rand) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user