From 0fbec4900b82beffceffc89601febedb8194b21b Mon Sep 17 00:00:00 2001 From: Markus1002 <51504784+Markus1002@users.noreply.github.com> Date: Sun, 12 May 2024 00:00:22 +0300 Subject: [PATCH] Fixed #234 --- .../core/mixin/PandaBreedGoalMixin.java | 26 +++++++++++++++++++ src/main/resources/atmospheric.mixins.json | 1 + 2 files changed, 27 insertions(+) create mode 100644 src/main/java/com/teamabnormals/atmospheric/core/mixin/PandaBreedGoalMixin.java diff --git a/src/main/java/com/teamabnormals/atmospheric/core/mixin/PandaBreedGoalMixin.java b/src/main/java/com/teamabnormals/atmospheric/core/mixin/PandaBreedGoalMixin.java new file mode 100644 index 00000000..a713d041 --- /dev/null +++ b/src/main/java/com/teamabnormals/atmospheric/core/mixin/PandaBreedGoalMixin.java @@ -0,0 +1,26 @@ +package com.teamabnormals.atmospheric.core.mixin; + +import com.teamabnormals.atmospheric.core.registry.AtmosphericBlocks; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.ai.goal.BreedGoal; +import net.minecraft.world.entity.animal.Animal; +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; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(targets = "net.minecraft.world.entity.animal.Panda$PandaBreedGoal") +public abstract class PandaBreedGoalMixin extends BreedGoal { + + private PandaBreedGoalMixin(Animal animal, double speed) { + super(animal, speed); + } + + @Inject(method = "canFindBamboo", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos$MutableBlockPos;setWithOffset(Lnet/minecraft/core/Vec3i;III)Lnet/minecraft/core/BlockPos$MutableBlockPos;", shift = At.Shift.AFTER), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) + private void canFindBamboo(CallbackInfoReturnable cir, BlockPos blockPos, BlockPos.MutableBlockPos blockpos$mutableblockpos, int i, int j, int k, int l) { + if (this.level.getBlockState(blockpos$mutableblockpos).is(AtmosphericBlocks.SNOWY_BAMBOO.get())) { + cir.setReturnValue(true); + } + } +} \ No newline at end of file diff --git a/src/main/resources/atmospheric.mixins.json b/src/main/resources/atmospheric.mixins.json index f259b835..cc6bb0d8 100644 --- a/src/main/resources/atmospheric.mixins.json +++ b/src/main/resources/atmospheric.mixins.json @@ -9,6 +9,7 @@ "BlockMixin", "CamelMixin", "EntityMixin", + "PandaBreedGoalMixin", "PistonBaseBlockMixin", "ServerLevelMixin", "ShearsItemMixin",