Fixed minecarts being stopped by items and arrows on ground and flickering after certain speeds

master
Wynd 2023-04-07 19:07:52 +03:00
parent 02905fb0fc
commit 435294533a
3 changed files with 42 additions and 3 deletions

View File

@ -128,6 +128,27 @@ After:<br>
</details>
<details><summary>Fixes Minecarts hardstopping when hitting arrows or dropped items on tracks</summary>
Before:<br>
<video controls src="https://i.imgur.com/5hICLc2.mp4" />
After:<br>
<video controls src="https://i.imgur.com/Hf9X8HM.mp4" />
</details>
<details><summary>Fixes Minecarts flickering while moving</summary>
Before:<br>
<video controls src="https://i.imgur.com/cBUIE5n.mp4" />
After:<br>
<video controls src="https://i.imgur.com/vZGhuos.mp4" />
</details>
## Troubleshooting
**Q: My achievements screen is all messed up**

View File

@ -4,8 +4,6 @@ import java.lang.management.ManagementFactory;
import java.util.Random;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
public class WyHelper {
@ -26,7 +24,10 @@ public class WyHelper {
Random rand = new Random();
// player.level.playSound(player, "random.break", 1, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
player.dropItem(new ItemInstance(ItemType.fishingRod, 1), false);
// player.dropItem(new ItemInstance(ItemType.minecart, 1), false);
// player.dropItem(new ItemInstance(ItemType.bow, 1), false);
// player.dropItem(new ItemInstance(ItemType.arrow, 64), false);
// player.dropItem(new ItemInstance(Tile.STONE, 64), false);
// player.level.playLevelEvent((Player)null, 1005, (int)player.x, (int)player.y, (int)player.z, 0);

View File

@ -4,15 +4,27 @@ 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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.Minecart;
import net.minecraft.entity.projectile.Arrow;
import net.minecraft.tile.RailTile;
import net.minecraft.util.maths.Box;
import net.minecraft.util.maths.MathsHelper;
import xyz.pixelatedw.betterbeta.WyHelper;
@Mixin(Minecart.class)
public class MinecartMixin {
@Inject(method = "method_1379", at = @At("HEAD"), cancellable = true)
public void onCollision(Entity other, CallbackInfoReturnable<Box> ci) {
if(other instanceof ItemEntity || other instanceof Arrow) {
ci.setReturnValue(null);
}
}
@Inject(method = "tick", at = @At("TAIL"))
public void tick(CallbackInfo ci) {
Minecart minecart = (Minecart) (Object) this;
@ -21,6 +33,11 @@ public class MinecartMixin {
int z = MathsHelper.floor(minecart.z);
int tileId = minecart.level.getTileId(x, y, z);
if (RailTile.method_1107(tileId)) {
if(minecart.passenger != null) {
minecart.boundingBox.set(minecart.boundingBox.minX - 0.5, minecart.boundingBox.minY - 0.5, minecart.boundingBox.minZ - 0.5, minecart.boundingBox.maxX + 0.5, minecart.boundingBox.maxY + 0.5, minecart.boundingBox.maxZ + 0.5);
}
float speed = MathsHelper.sqrt(minecart.velocityX * minecart.velocityX + minecart.velocityZ * minecart.velocityZ);
float volume = 0;
float pitch = 0;