Skip to content

Commit

Permalink
Update BlockEntityTypeMixin.java
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Sep 21, 2024
1 parent 96cda3d commit 195ceb1
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package net.frozenblock.lib.core.mixin;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.world.level.block.CeilingHangingSignBlock;
import net.minecraft.world.level.block.StandingSignBlock;
import net.minecraft.world.level.block.WallHangingSignBlock;
Expand All @@ -25,24 +26,23 @@
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BlockEntityType.class)
public class BlockEntityTypeMixin {

/**
* This allows custom sign and hanging sign blocks to be added to their block entities
*/
@Inject(method = "isValid", at = @At("RETURN"), cancellable = true)
private void isValid(BlockState state, CallbackInfoReturnable<Boolean> info) {
@ModifyReturnValue(method = "isValid", at = @At("RETURN"))
private boolean frozenLib$isValid(boolean original, BlockState state) {
var type = BlockEntityType.class.cast(this);

if ((type == BlockEntityType.SIGN &&
(state.getBlock() instanceof StandingSignBlock || state.getBlock() instanceof WallSignBlock))
|| (type == BlockEntityType.HANGING_SIGN
&& (state.getBlock() instanceof CeilingHangingSignBlock || state.getBlock() instanceof WallHangingSignBlock))) {
info.setReturnValue(true);
return true;
}
return original;
}
}

0 comments on commit 195ceb1

Please sign in to comment.