|
1 | 1 | package com.rimo.footprintparticle.mixin; |
2 | 2 |
|
3 | 3 | import com.rimo.footprintparticle.FPPClient; |
4 | | -import net.minecraft.entity.Entity; |
5 | | -import net.minecraft.entity.EntityType; |
6 | | -import net.minecraft.entity.vehicle.AbstractBoatEntity; |
7 | | -import net.minecraft.particle.ParticleTypes; |
8 | | -import net.minecraft.util.math.MathHelper; |
9 | | -import net.minecraft.world.World; |
| 4 | +import net.minecraft.core.particles.ParticleTypes; |
| 5 | +import net.minecraft.util.Mth; |
| 6 | +import net.minecraft.world.entity.Entity; |
| 7 | +import net.minecraft.world.entity.EntityType; |
| 8 | +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; |
| 9 | +import net.minecraft.world.level.Level; |
10 | 10 | import org.spongepowered.asm.mixin.Mixin; |
11 | 11 | import org.spongepowered.asm.mixin.Shadow; |
12 | 12 | import org.spongepowered.asm.mixin.injection.At; |
13 | 13 | import org.spongepowered.asm.mixin.injection.Inject; |
14 | 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
15 | 15 |
|
16 | | -@Mixin(AbstractBoatEntity.class) |
| 16 | +@Mixin(AbstractBoat.class) |
17 | 17 | public abstract class AbstractBoatEntityMixin extends Entity { |
18 | 18 |
|
19 | | - public AbstractBoatEntityMixin(EntityType<?> type, World world) { |
| 19 | + public AbstractBoatEntityMixin(EntityType<?> type, Level world) { |
20 | 20 | super(type, world); |
21 | 21 | } |
22 | 22 |
|
23 | 23 | @Shadow |
24 | | - protected abstract boolean checkBoatInWater(); |
| 24 | + protected abstract boolean checkInWater(); |
25 | 25 |
|
26 | 26 | @Inject(method = "tick", at = @At("TAIL")) |
27 | 27 | public void tick(CallbackInfo ci) { |
28 | 28 | if (FPPClient.CONFIG.isEnableBoatTrail()) { |
29 | | - int k = (int)(this.getVelocity().horizontalLength() * 10); |
| 29 | + int k = (int)(this.getDeltaMovement().horizontalDistance() * 10); |
30 | 30 | while (Math.random() < k-- / 5f) { |
31 | 31 | var i = Math.random() > 0.5f ? 1 : -1; //TODO: boat's yaw is 90 degrees more than other entity, strange. |
32 | | - if (this.checkBoatInWater()) { |
33 | | - this.getEntityWorld().addParticleClient( // at head |
| 32 | + if (this.checkInWater()) { |
| 33 | + this.level().addParticle( // at head |
34 | 34 | ParticleTypes.RAIN, |
35 | | - this.getX() + 1.2f * MathHelper.cos((float) Math.toRadians(this.getRotationClient().y + 90 + Math.random() * 30 * i)), |
| 35 | + this.getX() + 1.2f * Mth.cos((float) Math.toRadians(this.getRotationVector().y + 90 + Math.random() * 30 * i)), |
36 | 36 | (int) this.getY() + 1f, |
37 | | - this.getZ() + 1.2f * MathHelper.sin((float) Math.toRadians(this.getRotationClient().y + 90 + Math.random() * 30 * i)), |
| 37 | + this.getZ() + 1.2f * Mth.sin((float) Math.toRadians(this.getRotationVector().y + 90 + Math.random() * 30 * i)), |
38 | 38 | 0, |
39 | 39 | 0, |
40 | 40 | 0 |
41 | 41 | ); |
42 | 42 | for (int j = 0; j < 2; j++) { |
43 | | - this.getEntityWorld().addParticleClient( // at paddle |
| 43 | + this.level().addParticle( // at paddle |
44 | 44 | FPPClient.WATERSPLASH, |
45 | | - this.getX() + i * MathHelper.cos((float) Math.toRadians(this.getRotationClient().y - 10 + Math.random() * 20)), |
| 45 | + this.getX() + i * Mth.cos((float) Math.toRadians(this.getRotationVector().y - 10 + Math.random() * 20)), |
46 | 46 | (int) this.getY() + 1f, |
47 | | - this.getZ() + i * MathHelper.sin((float) Math.toRadians(this.getRotationClient().y - 10 + Math.random() * 20)), |
| 47 | + this.getZ() + i * Mth.sin((float) Math.toRadians(this.getRotationVector().y - 10 + Math.random() * 20)), |
48 | 48 | (Math.random() - 0.5f) / 4f, |
49 | | - Math.random() * this.getVelocity().horizontalLength() / 2f, |
| 49 | + Math.random() * this.getDeltaMovement().horizontalDistance() / 2f, |
50 | 50 | (Math.random() - 0.5f) / 4f |
51 | 51 | ); |
52 | 52 | } |
53 | | - this.getEntityWorld().addParticleClient( // at tail |
| 53 | + this.level().addParticle( // at tail |
54 | 54 | ParticleTypes.BUBBLE, |
55 | | - this.getX() - 1.2f * MathHelper.cos((float) Math.toRadians(this.getRotationClient().y + 90 + Math.random() * 30 * i)), |
| 55 | + this.getX() - 1.2f * Mth.cos((float) Math.toRadians(this.getRotationVector().y + 90 + Math.random() * 30 * i)), |
56 | 56 | (int) this.getY() + 0.5f + Math.random() / 2f, |
57 | | - this.getZ() - 1.2f * MathHelper.sin((float) Math.toRadians(this.getRotationClient().y + 90 + Math.random() * 30 * i)), |
58 | | - this.getVelocity().getX() / 5f, |
| 57 | + this.getZ() - 1.2f * Mth.sin((float) Math.toRadians(this.getRotationVector().y + 90 + Math.random() * 30 * i)), |
| 58 | + this.getDeltaMovement().x() / 5f, |
59 | 59 | Math.random() / 3f, |
60 | | - this.getVelocity().getZ() / 5f |
| 60 | + this.getDeltaMovement().z() / 5f |
61 | 61 | ); |
62 | 62 | } else { |
63 | 63 | if (Math.random() > 0.5f) { |
64 | | - this.getEntityWorld().addParticleClient( // at paddle |
| 64 | + this.level().addParticle( // at paddle |
65 | 65 | ParticleTypes.CLOUD, |
66 | | - this.getX() + i * MathHelper.cos((float) Math.toRadians(this.getRotationClient().y - 10 + Math.random() * 20)), |
| 66 | + this.getX() + i * Mth.cos((float) Math.toRadians(this.getRotationVector().y - 10 + Math.random() * 20)), |
67 | 67 | this.getY(), |
68 | | - this.getZ() + i * MathHelper.sin((float) Math.toRadians(this.getRotationClient().y - 10 + Math.random() * 20)), |
| 68 | + this.getZ() + i * Mth.sin((float) Math.toRadians(this.getRotationVector().y - 10 + Math.random() * 20)), |
69 | 69 | Math.random() / 5f, |
70 | 70 | Math.random() / 5f, |
71 | 71 | Math.random() / 5f |
72 | 72 | ); |
73 | 73 | } else { |
74 | | - this.getEntityWorld().addParticleClient( // at tail |
| 74 | + this.level().addParticle( // at tail |
75 | 75 | ParticleTypes.CLOUD, |
76 | | - this.getX() - 1.2f * MathHelper.cos((float) Math.toRadians(this.getRotationClient().y + 90 + Math.random() * 30 * i)), |
| 76 | + this.getX() - 1.2f * Mth.cos((float) Math.toRadians(this.getRotationVector().y + 90 + Math.random() * 30 * i)), |
77 | 77 | this.getY(), |
78 | | - this.getZ() - 1.2f * MathHelper.sin((float) Math.toRadians(this.getRotationClient().y + 90 + Math.random() * 30 * i)), |
79 | | - this.getVelocity().getX() / 5f, |
| 78 | + this.getZ() - 1.2f * Mth.sin((float) Math.toRadians(this.getRotationVector().y + 90 + Math.random() * 30 * i)), |
| 79 | + this.getDeltaMovement().x() / 5f, |
80 | 80 | Math.random() / 5f, |
81 | | - this.getVelocity().getZ() / 5f |
| 81 | + this.getDeltaMovement().z() / 5f |
82 | 82 | ); |
83 | 83 | } |
84 | 84 | } |
|
0 commit comments