diff --git a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningEntityMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningEntityMixin.java index f728c1dc..890d166d 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningEntityMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningEntityMixin.java @@ -42,7 +42,7 @@ public LightningEntityMixin(EntityType type, World world) { if (blockState.isIn(FriendsAndFoesTags.LIGHTNING_RODS)) { this.getWorld().setBlockState( blockPos, - Oxidizable.getUnaffectedOxidationState(this.getWorld().getBlockState(blockPos)) + FriendsAndFoesOxidizable.getUnaffectedOxidationState(this.getWorld().getBlockState(blockPos)) ); ((LightningRodBlock) this.getWorld().getBlockState(blockPos).getBlock()).setPowered(blockState, this.getWorld(), blockPos); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodAbstractBlockMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodAbstractBlockMixin.java index 3e7a0923..8169a680 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodAbstractBlockMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodAbstractBlockMixin.java @@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = AbstractBlock.class, priority = 10000) +@Mixin(value = AbstractBlock.class, priority = 1001) public abstract class LightningRodAbstractBlockMixin { @Inject( diff --git a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockBlockMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockBlockMixin.java index 5902dbf5..892f339a 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockBlockMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockBlockMixin.java @@ -7,12 +7,12 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = Block.class, priority = 10000) +@Mixin(value = Block.class, priority = 1001) public abstract class LightningRodBlockBlockMixin extends LightningRodAbstractBlockMixin { @Inject( method = "hasRandomTicks", - at = @At("TAIL"), + at = @At("HEAD"), cancellable = true ) public void friendsandfoes_hasRandomTicks( diff --git a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockDegradableMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockDegradableMixin.java index 7e770b95..f6fa10d9 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockDegradableMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockDegradableMixin.java @@ -5,7 +5,7 @@ import net.minecraft.block.Oxidizable; import org.spongepowered.asm.mixin.Mixin; -@Mixin(value = LightningRodBlock.class, priority = 10000) +@Mixin(value = LightningRodBlock.class, priority = 1003) public abstract class LightningRodBlockDegradableMixin implements Degradable { @Override diff --git a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockMixin.java index 53741591..84faa2d6 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockMixin.java @@ -1,6 +1,7 @@ package com.faboslav.friendsandfoes.common.mixin; import com.faboslav.friendsandfoes.common.FriendsAndFoes; +import com.faboslav.friendsandfoes.common.block.FriendsAndFoesOxidizable; import com.faboslav.friendsandfoes.common.block.OnUseOxidizable; import com.faboslav.friendsandfoes.common.client.render.entity.animation.KeyframeAnimation; import com.faboslav.friendsandfoes.common.entity.CopperGolemEntity; @@ -33,7 +34,7 @@ import java.util.ArrayList; -@Mixin(value = LightningRodBlock.class, priority = 10000) +@Mixin(value = LightningRodBlock.class, priority = 1001) public abstract class LightningRodBlockMixin extends LightningRodBlockBlockMixin { @Nullable @@ -205,7 +206,7 @@ private boolean friendsandfoes_isCopperBlockWaxed( public void friendsandfoes_hasRandomTicks( BlockState state, CallbackInfoReturnable cir ) { - cir.setReturnValue(Oxidizable.getIncreasedOxidationBlock(state.getBlock()).isPresent()); + cir.setReturnValue(FriendsAndFoesOxidizable.getIncreasedOxidationBlock(state.getBlock()).isPresent()); } @Override @@ -216,7 +217,8 @@ public void friendsandfoes_randomTick( Random random, CallbackInfo ci ) { - ((Degradable) this).tickDegradation(state, world, pos, random); + ((Degradable)this).tickDegradation(state, world, pos, random); + ci.cancel(); } @Override diff --git a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockOxidizableMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockOxidizableMixin.java index a12f57b4..5a79002b 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockOxidizableMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/common/mixin/LightningRodBlockOxidizableMixin.java @@ -1,14 +1,23 @@ package com.faboslav.friendsandfoes.common.mixin; +import com.faboslav.friendsandfoes.common.block.FriendsAndFoesOxidizable; +import net.minecraft.block.BlockState; import net.minecraft.block.LightningRodBlock; import net.minecraft.block.Oxidizable; import net.minecraft.block.RodBlock; import org.spongepowered.asm.mixin.Mixin; -@Mixin(value = LightningRodBlock.class, priority = 10000) +import java.util.Optional; + +@Mixin(value = LightningRodBlock.class, priority = 1002) public abstract class LightningRodBlockOxidizableMixin extends RodBlock implements Oxidizable { public LightningRodBlockOxidizableMixin(Settings settings) { super(settings); } + + @Override + public Optional getDegradationResult(BlockState state) { + return FriendsAndFoesOxidizable.getIncreasedOxidationBlock(state.getBlock()).map((block) -> block.getStateWithProperties(state)); + } } \ No newline at end of file