|
1 | 1 | package openblocks.common.entity; |
2 | 2 |
|
3 | 3 | import javax.annotation.Nonnull; |
4 | | -import net.minecraft.block.material.Material; |
5 | | -import net.minecraft.block.state.IBlockState; |
6 | | -import net.minecraft.entity.MoverType; |
7 | 4 | import net.minecraft.entity.item.EntityItem; |
8 | | -import net.minecraft.init.SoundEvents; |
9 | 5 | import net.minecraft.item.ItemStack; |
10 | 6 | import net.minecraft.util.datafix.DataFixer; |
11 | 7 | import net.minecraft.util.datafix.FixTypes; |
12 | 8 | import net.minecraft.util.datafix.walkers.ItemStackData; |
13 | | -import net.minecraft.util.math.BlockPos; |
14 | | -import net.minecraft.util.math.MathHelper; |
15 | 9 | import net.minecraft.world.World; |
16 | 10 |
|
17 | 11 | /** |
@@ -39,64 +33,16 @@ public static void registerFixes(DataFixer fixer) { |
39 | 33 |
|
40 | 34 | @Override |
41 | 35 | public void onUpdate() { |
42 | | - final double x = posX; |
43 | | - final double y = posY; |
44 | | - final double z = posZ; |
45 | | - |
46 | | - final double vx = motionX; |
47 | | - final double vy = motionY; |
48 | | - final double vz = motionZ; |
49 | | - |
50 | 36 | // let vanilla run |
51 | 37 | super.onUpdate(); |
52 | | - if (!isDead) return; |
53 | | - // and then overwrite position calculations |
54 | | - |
55 | | - this.posX = x; |
56 | | - this.posY = y; |
57 | | - this.posZ = z; |
58 | | - |
59 | | - this.motionX = vx; |
60 | | - this.motionY = vy; |
61 | | - this.motionZ = vz; |
62 | | - |
63 | | - this.prevPosX = this.posX; |
64 | | - this.prevPosY = this.posY; |
65 | | - this.prevPosZ = this.posZ; |
66 | | - this.motionY -= 0.03999999910593033D; |
67 | | - |
68 | | - move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); |
69 | | - |
70 | | - boolean hasMoved = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ; |
71 | 38 |
|
72 | | - if (hasMoved || this.ticksExisted % 25 == 0) { |
73 | | - if (this.world.getBlockState(new BlockPos(this)).getMaterial() == Material.LAVA) { |
74 | | - this.motionY = 0.20000000298023224D; |
75 | | - this.motionX = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F; |
76 | | - this.motionZ = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F; |
77 | | - playSound(SoundEvents.ENTITY_GENERIC_BURN, 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); |
78 | | - } |
| 39 | + // Remove the air drag that EntityItem.onUpdate adds to our velocity |
| 40 | + if (!this.onGround) { |
| 41 | + double f = 0.98F; |
| 42 | + this.motionX = this.motionX / f; |
| 43 | + this.motionY = this.motionY / f; |
| 44 | + this.motionZ = this.motionZ / f; |
79 | 45 | } |
80 | | - |
81 | | - // Zero Air Friction |
82 | | - float f = 1F; |
83 | | - |
84 | | - // Keep ground friction |
85 | | - if (this.onGround) { |
86 | | - BlockPos underPos = new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(getEntityBoundingBox().minY) - 1, MathHelper.floor(this.posZ)); |
87 | | - IBlockState underState = this.world.getBlockState(underPos); |
88 | | - f = underState.getBlock().getSlipperiness(underState, this.world, underPos, this) * 0.98F; |
89 | | - } |
90 | | - |
91 | | - this.motionX *= f; |
92 | | - // Y would there be Y resistance :D |
93 | | - // ^ not my pun, I'm just porting :P, ~B |
94 | | - // motionY *= 0.98; |
95 | | - this.motionZ *= f; |
96 | | - |
97 | | - if (this.onGround) this.motionY *= -0.5D; |
98 | | - |
99 | | - handleWaterMovement(); |
100 | 46 | } |
101 | 47 |
|
102 | 48 | } |
0 commit comments