Skip to content

Commit

Permalink
Fixed stickers being broken
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Dec 21, 2023
1 parent 4bc1b4a commit 23f71c6
Showing 1 changed file with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,42 @@
@Mixin(StickerBlock.class)
public abstract class MixinStickerBlock extends WrenchableDirectionalBlock implements IBE<StickerBlockEntity> {

public MixinStickerBlock(Properties properties) {
public MixinStickerBlock(final Properties properties) {
super(properties);
}

@Override
public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) {
public void onRemove(
@NotNull final BlockState state,
@NotNull final Level world,
@NotNull final BlockPos pos,
@NotNull final BlockState newState,
final boolean isMoving
) {
IBE.onRemove(state, world, pos, newState);
}

@Inject(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0), cancellable = true)
private void injectNeighbourChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving, CallbackInfo ci) {
StickerBlockEntity ste = getBlockEntity(worldIn, pos);
if (ste != null && ((IMixinStickerTileEntity) ste).isAlreadyPowered(false)) {
@Inject(
method = "neighborChanged",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0),
cancellable = true
)
private void injectNeighbourChanged(
final BlockState state,
final Level worldIn,
final BlockPos pos,
final Block blockIn,
final BlockPos fromPos,
final boolean isMoving,
final CallbackInfo ci
) {
final StickerBlockEntity ste = getBlockEntity(worldIn, pos);
// By checking `instanceof IMixinStickerTileEntity` we only run this code if Clockwork is installed
if (ste instanceof final IMixinStickerTileEntity iMixinStickerTileEntity && iMixinStickerTileEntity.isAlreadyPowered(false)) {
if (!worldIn.hasNeighborSignal(pos)) {
ci.cancel();
} else {
((IMixinStickerTileEntity) ste).isAlreadyPowered(true);
iMixinStickerTileEntity.isAlreadyPowered(true);
}
}
}
Expand Down

0 comments on commit 23f71c6

Please sign in to comment.