Yatopia/patches/server-remap-in-progress/remap in progress/0063-lithium-entity.patch

59 lines
2.1 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JellySquid <jellysquid+atwork@protonmail.com>
Date: Sun, 24 Jan 2021 22:55:55 +0100
Subject: [PATCH] lithium entity
Co-authored-by: Hugo Planque <hookwood01@gmail.com>
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 89ec42a757060688c088baef3dd95280205c2a3d..583657316fd404d2373b4777fe26a0f4d081100a 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -282,6 +282,9 @@ public abstract class EntityLiving extends Entity {
this.shouldBurnInDay = false; // Purpur
}
+ private IBlockData lastStateAtFeet = null;
+
+ private long lastPos = Long.MIN_VALUE;
protected void initAttributes() {} // Purpur
public BehaviorController<?> getBehaviorController() {
@@ -358,6 +361,10 @@ public abstract class EntityLiving extends Entity {
@Override
public void entityBaseTick() {
+ // Yatopia start - port lithium
+ this.lastStateAtFeet = null;
+ this.lastPos = Long.MIN_VALUE;
+ // Yatopia end
this.ar = this.as;
if (this.justCreated) {
this.getBedPosition().ifPresent(this::a);
@@ -1812,7 +1819,24 @@ public abstract class EntityLiving extends Entity {
// Airplane end
public IBlockData ds() {
- return this.world.getBlockStateIfLoaded(this.getChunkCoordinates()); // Yatopia
+ // Yatopia start - port lithium
+ int x = MathHelper.floor(this.locX());
+ int y = MathHelper.floor(this.locY());
+ int z = MathHelper.floor(this.locZ());
+
+ long pos = getChunkCoordinates().asLong();
+
+ if (this.lastPos == pos) {
+ return this.lastStateAtFeet;
+ }
+
+ IBlockData state = this.world.getBlockStateIfLoaded(this.getChunkCoordinates());
+
+ this.lastPos = pos;
+ this.lastStateAtFeet = state;
+
+ return state;
+ // Yatopia end
}
private boolean c(BlockPosition blockposition, IBlockData iblockdata) {