diff --git a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomBeeEntity.java b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomBeeEntity.java index 93e4c46..1ae9ab3 100644 --- a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomBeeEntity.java +++ b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomBeeEntity.java @@ -2,7 +2,10 @@ package gay.pridecraft.joy.entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.BeeEntity; +import net.minecraft.entity.passive.PassiveEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; public class CustomBeeEntity extends BeeEntity { @@ -10,6 +13,12 @@ public class CustomBeeEntity extends BeeEntity { super(entityType, world); } + @Nullable + @Override + public BeeEntity createChild(final ServerWorld serverWorld, final PassiveEntity passiveEntity) { + return (BeeEntity) this.getType().create(serverWorld); + } + public static class BiiEntity extends CustomBeeEntity { public BiiEntity(EntityType entityType, World world) { super(entityType, world); diff --git a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFoxEntity.java b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFoxEntity.java index 4449c83..b2de489 100644 --- a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFoxEntity.java +++ b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFoxEntity.java @@ -2,13 +2,26 @@ package gay.pridecraft.joy.entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.FoxEntity; +import net.minecraft.entity.passive.PassiveEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; public class CustomFoxEntity extends FoxEntity { public CustomFoxEntity(EntityType entityType, World world) { super(entityType, world); } + @Nullable + @Override + public FoxEntity createChild(final ServerWorld serverWorld, final PassiveEntity passiveEntity) { + final var fox = (FoxEntity) this.getType().create(serverWorld); + if (fox != null) { + fox.setVariant(this.random.nextBoolean() ? this.getVariant() : ((FoxEntity) passiveEntity).getVariant()); + } + return fox; + } + public static class SockFoxEntity extends CustomFoxEntity { public SockFoxEntity(EntityType entityType, World world) { super(entityType, world); diff --git a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFrogEntity.java b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFrogEntity.java index c6a425d..d8c5785 100644 --- a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFrogEntity.java +++ b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomFrogEntity.java @@ -1,15 +1,29 @@ package gay.pridecraft.joy.entity; +import gay.pridecraft.joy.mixin.minecraft.AccessorFrogBrain; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.FrogEntity; +import net.minecraft.entity.passive.PassiveEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; public class CustomFrogEntity extends FrogEntity { public CustomFrogEntity(EntityType entityType, World world) { super(entityType, world); } + @Nullable + @Override + public FrogEntity createChild(final ServerWorld serverWorld, final PassiveEntity passiveEntity) { + final var frog = (FrogEntity) this.getType().create(serverWorld); + if (frog != null) { + AccessorFrogBrain.invokeCoolDownLongJump(frog, serverWorld.getRandom()); + } + return frog; + } + public static class FrogEntity extends CustomFrogEntity { public FrogEntity(EntityType entityType, World world) { super(entityType, world); diff --git a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomSnifferEntity.java b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomSnifferEntity.java index 9c0392e..4636e1c 100644 --- a/xplat/src/main/java/gay/pridecraft/joy/entity/CustomSnifferEntity.java +++ b/xplat/src/main/java/gay/pridecraft/joy/entity/CustomSnifferEntity.java @@ -2,8 +2,11 @@ package gay.pridecraft.joy.entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.PassiveEntity; import net.minecraft.entity.passive.SnifferEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; public class CustomSnifferEntity extends SnifferEntity { @@ -11,6 +14,12 @@ public class CustomSnifferEntity extends SnifferEntity { super(entityType, world); } + @Nullable + @Override + public SnifferEntity createChild(final ServerWorld serverWorld, final PassiveEntity passiveEntity) { + return (SnifferEntity) this.getType().create(serverWorld); + } + public static class SnifferEntity extends CustomSnifferEntity { public SnifferEntity(EntityType entityType, World world) { super(entityType, world); diff --git a/xplat/src/main/java/gay/pridecraft/joy/mixin/minecraft/AccessorFrogBrain.java b/xplat/src/main/java/gay/pridecraft/joy/mixin/minecraft/AccessorFrogBrain.java new file mode 100644 index 0000000..845975e --- /dev/null +++ b/xplat/src/main/java/gay/pridecraft/joy/mixin/minecraft/AccessorFrogBrain.java @@ -0,0 +1,19 @@ +package gay.pridecraft.joy.mixin.minecraft; + +import net.minecraft.entity.passive.FrogBrain; +import net.minecraft.entity.passive.FrogEntity; +import net.minecraft.util.math.random.Random; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +/** + * @author Ampflower + * @since 1.0.0 + **/ +@Mixin(FrogBrain.class) +public interface AccessorFrogBrain { + @Invoker + static void invokeCoolDownLongJump(FrogEntity frog, Random random) { + throw new AssertionError(); + } +} diff --git a/xplat/src/main/resources/joy.mixins.json b/xplat/src/main/resources/joy.mixins.json index 5b9f9c9..e38e7a4 100644 --- a/xplat/src/main/resources/joy.mixins.json +++ b/xplat/src/main/resources/joy.mixins.json @@ -5,7 +5,7 @@ "refmap": "joy.refmap.json", "compatibilityLevel": "JAVA_21", "mixins": [ - "AllayEntityMixin", "LivingEntityMixin", "PaintingVariantsMixin", + "AllayEntityMixin", "LivingEntityMixin", "PaintingVariantsMixin", "minecraft.AccessorFrogBrain", "minecraft.AccessorPoi", "minecraft.MixinLivingEntity", "minecraft.MixinPlayerEntity" ], "injectors": {