Skip to content

Commit 36a098d

Browse files
committed
feat:turtle patches
1 parent 654f84d commit 36a098d

5 files changed

Lines changed: 74 additions & 56 deletions

File tree

nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch

Lines changed: 0 additions & 20 deletions
This file was deleted.

nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/main/java/org/teneted/neotenet/mixin/world/entity/animal/MixinTurtle.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package org.teneted.neotenet.mixin.world.entity.animal;
22

3+
import com.llamalad7.mixinextras.sugar.Local;
4+
import net.minecraft.world.damagesource.DamageSource;
35
import net.minecraft.world.entity.EntityType;
6+
import net.minecraft.world.entity.LightningBolt;
47
import net.minecraft.world.entity.animal.Animal;
58
import net.minecraft.world.entity.animal.Turtle;
69
import net.minecraft.world.level.Level;
710
import org.spongepowered.asm.mixin.Mixin;
811
import org.spongepowered.asm.mixin.injection.At;
912
import org.spongepowered.asm.mixin.injection.Inject;
13+
import org.spongepowered.asm.mixin.injection.ModifyArg;
1014
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1115

1216
@Mixin(Turtle.class)
@@ -25,4 +29,9 @@ protected MixinTurtle(EntityType<? extends Animal> entityType, Level level) {
2529
private void neotenet$forceDropReset(CallbackInfo ci) {
2630
this.forceDrops = false;
2731
}
32+
33+
@ModifyArg(method = "thunderHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/Turtle;hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z"), index = 0)
34+
private DamageSource neotenet$userThunderHit(DamageSource par1, @Local(argsOnly = true) LightningBolt p_30141_) {
35+
return par1.customEntityDamager(p_30141_);
36+
}
2837
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.teneted.neotenet.mixin.world.entity.animal;
2+
3+
import net.minecraft.core.BlockPos;
4+
import net.minecraft.sounds.SoundEvents;
5+
import net.minecraft.sounds.SoundSource;
6+
import net.minecraft.world.entity.PathfinderMob;
7+
import net.minecraft.world.entity.ai.goal.MoveToBlockGoal;
8+
import net.minecraft.world.entity.ai.util.DefaultRandomPos;
9+
import net.minecraft.world.entity.animal.Turtle;
10+
import net.minecraft.world.level.Level;
11+
import net.minecraft.world.level.block.Blocks;
12+
import net.minecraft.world.level.block.TurtleEggBlock;
13+
import net.minecraft.world.level.block.state.BlockState;
14+
import net.minecraft.world.level.gameevent.GameEvent;
15+
import net.minecraft.world.phys.Vec3;
16+
import org.spongepowered.asm.mixin.Final;
17+
import org.spongepowered.asm.mixin.Mixin;
18+
import org.spongepowered.asm.mixin.Overwrite;
19+
import org.spongepowered.asm.mixin.Shadow;
20+
21+
@Mixin(targets = "net.minecraft.world.entity.animal.Turtle.TurtleLayEggGoal")
22+
public abstract class MixinTurtle_TurtleLayEggGoal extends MoveToBlockGoal {
23+
24+
@Shadow
25+
@Final
26+
private Turtle turtle;
27+
28+
public MixinTurtle_TurtleLayEggGoal(PathfinderMob p_25609_, double p_25610_, int p_25611_) {
29+
super(p_25609_, p_25610_, p_25611_);
30+
}
31+
32+
/**
33+
* @author wdog5
34+
* @reason bukkit
35+
*/
36+
@Overwrite
37+
public void tick() {
38+
super.tick();
39+
BlockPos blockpos = this.turtle.blockPosition();
40+
if (!this.turtle.isInWater() && this.isReachedTarget()) {
41+
if (this.turtle.layEggCounter < 1) {
42+
this.turtle.setLayingEgg(true);
43+
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
44+
Level level = this.turtle.level();
45+
if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1))) { // CraftBukkit
46+
level.playSound(null, blockpos, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + level.random.nextFloat() * 0.2F);
47+
BlockPos blockpos1 = this.blockPos.above();
48+
BlockState blockstate = Blocks.TURTLE_EGG
49+
.defaultBlockState()
50+
.setValue(TurtleEggBlock.EGGS, Integer.valueOf(this.turtle.random.nextInt(4) + 1));
51+
level.setBlock(blockpos1, blockstate, 3);
52+
level.gameEvent(GameEvent.BLOCK_PLACE, blockpos1, GameEvent.Context.of(this.turtle, blockstate));
53+
}
54+
this.turtle.setHasEgg(false);
55+
this.turtle.setLayingEgg(false);
56+
this.turtle.setInLoveTime(600);
57+
}
58+
59+
if (this.turtle.isLayingEgg()) {
60+
this.turtle.layEggCounter++;
61+
}
62+
}
63+
}
64+
}

src/main/resources/neotenet.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
"world.entity.animal.MixinSniffer",
153153
"world.entity.animal.MixinSnowGolem",
154154
"world.entity.animal.MixinTurtle",
155+
"world.entity.animal.MixinTurtle_TurtleLayEggGoal",
155156
"world.entity.animal.MixinWolf",
156157
"world.entity.animal.allay.MixinAllay",
157158
"world.entity.animal.armadillo.MixinArmadillo",

0 commit comments

Comments
 (0)