Replace ItemTag API with new API that also expands to Tiles and Entities
By: Bjarne Koll <LynxPlay101@gmail.com>
This commit is contained in:
@@ -319,7 +319,19 @@
|
||||
IChatBaseComponent ichatbasecomponent = this.getCustomName();
|
||||
|
||||
if (ichatbasecomponent != null) {
|
||||
@@ -1414,6 +1595,42 @@
|
||||
@@ -1331,6 +1512,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - stores eventually existing bukkit values
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ this.bukkitEntity.storeBukkitValues(nbttagcompound);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
||||
@@ -1414,6 +1600,42 @@
|
||||
} else {
|
||||
throw new IllegalStateException("Entity has invalid position");
|
||||
}
|
||||
@@ -362,7 +374,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||
@@ -1489,9 +1706,22 @@
|
||||
@@ -1489,9 +1711,22 @@
|
||||
} else if (this.world.isClientSide) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -385,7 +397,7 @@
|
||||
this.world.addEntity(entityitem);
|
||||
return entityitem;
|
||||
}
|
||||
@@ -1595,7 +1825,7 @@
|
||||
@@ -1595,7 +1830,7 @@
|
||||
}
|
||||
|
||||
this.vehicle = entity;
|
||||
@@ -394,7 +406,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1620,15 +1850,36 @@
|
||||
@@ -1620,15 +1855,36 @@
|
||||
Entity entity = this.vehicle;
|
||||
|
||||
this.vehicle = null;
|
||||
@@ -433,7 +445,7 @@
|
||||
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) {
|
||||
this.passengers.add(0, entity);
|
||||
} else {
|
||||
@@ -1636,15 +1887,33 @@
|
||||
@@ -1636,15 +1892,33 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -468,7 +480,7 @@
|
||||
}
|
||||
|
||||
protected boolean q(Entity entity) {
|
||||
@@ -1687,7 +1956,7 @@
|
||||
@@ -1687,7 +1961,7 @@
|
||||
int i = this.ab();
|
||||
|
||||
if (this.ai) {
|
||||
@@ -477,7 +489,7 @@
|
||||
this.world.getMethodProfiler().enter("portal");
|
||||
this.aj = i;
|
||||
this.portalCooldown = this.aW();
|
||||
@@ -1771,6 +2040,13 @@
|
||||
@@ -1771,6 +2045,13 @@
|
||||
}
|
||||
|
||||
public void setSwimming(boolean flag) {
|
||||
@@ -491,7 +503,7 @@
|
||||
this.setFlag(4, flag);
|
||||
}
|
||||
|
||||
@@ -1831,16 +2107,56 @@
|
||||
@@ -1831,16 +2112,56 @@
|
||||
}
|
||||
|
||||
public void setAirTicks(int i) {
|
||||
@@ -551,7 +563,7 @@
|
||||
}
|
||||
|
||||
public void j(boolean flag) {
|
||||
@@ -1988,20 +2304,33 @@
|
||||
@@ -1988,20 +2309,33 @@
|
||||
|
||||
@Nullable
|
||||
public Entity a(DimensionManager dimensionmanager) {
|
||||
@@ -588,7 +600,7 @@
|
||||
if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) {
|
||||
blockposition = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
||||
} else if (dimensionmanager == DimensionManager.THE_END) {
|
||||
@@ -2039,6 +2368,25 @@
|
||||
@@ -2039,6 +2373,25 @@
|
||||
vec3d = shapedetector_c.b;
|
||||
f = (float) shapedetector_c.c;
|
||||
}
|
||||
@@ -614,7 +626,7 @@
|
||||
|
||||
this.world.getMethodProfiler().exitEnter("reloading");
|
||||
Entity entity = this.getEntityType().a((World) worldserver1);
|
||||
@@ -2048,6 +2396,14 @@
|
||||
@@ -2048,6 +2401,14 @@
|
||||
entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch);
|
||||
entity.setMot(vec3d);
|
||||
worldserver1.addEntityTeleport(entity);
|
||||
@@ -629,7 +641,7 @@
|
||||
}
|
||||
|
||||
this.dead = true;
|
||||
@@ -2239,7 +2595,26 @@
|
||||
@@ -2239,7 +2600,26 @@
|
||||
}
|
||||
|
||||
public void a(AxisAlignedBB axisalignedbb) {
|
||||
|
||||
@@ -1,15 +1,47 @@
|
||||
--- a/net/minecraft/server/TileEntity.java
|
||||
+++ b/net/minecraft/server/TileEntity.java
|
||||
@@ -4,6 +4,8 @@
|
||||
@@ -3,9 +3,18 @@
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
|
||||
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
|
||||
+import org.bukkit.inventory.InventoryHolder; // CraftBukkit
|
||||
+
|
||||
public abstract class TileEntity {
|
||||
|
||||
+ // CraftBukkit start - data containers
|
||||
+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
||||
+ public final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
||||
+ // CraftBukkit end
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -55,8 +57,15 @@
|
||||
private final TileEntityTypes<?> b;
|
||||
@Nullable
|
||||
@@ -35,6 +44,12 @@
|
||||
|
||||
public void load(NBTTagCompound nbttagcompound) {
|
||||
this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
||||
+ // CraftBukkit start - read container
|
||||
+ NBTTagCompound persistentDataTag = nbttagcompound.getCompound("PublicBukkitValues");
|
||||
+ if (persistentDataTag != null) {
|
||||
+ this.persistentDataContainer.putAll(persistentDataTag);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
@@ -51,12 +66,24 @@
|
||||
nbttagcompound.setInt("x", this.position.getX());
|
||||
nbttagcompound.setInt("y", this.position.getY());
|
||||
nbttagcompound.setInt("z", this.position.getZ());
|
||||
+ // CraftBukkit start - store container
|
||||
+ if (!this.persistentDataContainer.isEmpty()) {
|
||||
+ nbttagcompound.set("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return nbttagcompound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +57,7 @@
|
||||
String s = nbttagcompound.getString("id");
|
||||
|
||||
return (TileEntity) IRegistry.BLOCK_ENTITY_TYPE.getOptional(new MinecraftKey(s)).map((tileentitytypes) -> {
|
||||
@@ -68,6 +77,7 @@
|
||||
@@ -68,6 +95,7 @@
|
||||
}
|
||||
}).map((tileentity) -> {
|
||||
try {
|
||||
@@ -33,7 +65,7 @@
|
||||
tileentity.load(nbttagcompound);
|
||||
return tileentity;
|
||||
} catch (Throwable throwable) {
|
||||
@@ -157,4 +167,13 @@
|
||||
@@ -157,4 +185,13 @@
|
||||
public TileEntityTypes<?> q() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user