mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add canSaveToDisk to Entity
This commit is contained in:
committed by
granny
parent
27d7eadf95
commit
f068d01f6b
@@ -1,87 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Tue, 18 Feb 2020 20:07:08 -0600
|
||||
Subject: [PATCH] Add canSaveToDisk to Entity
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 7b017806dde98a33b64223f098cc63c286dac02b..eea1053e0ec1446e117d3ac4732deaba191db8f2 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -569,6 +569,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
}
|
||||
// Paper end - optimise entity tracker
|
||||
+ // Purpur start - Add canSaveToDisk to Entity
|
||||
+ public boolean canSaveToDisk() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Purpur end - Add canSaveToDisk to Entity
|
||||
|
||||
public Entity(EntityType<?> type, Level world) {
|
||||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||
diff --git a/net/minecraft/world/entity/projectile/WitherSkull.java b/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
index 8296765d8f63f1a9fd207b27d495d7c04646f134..45e0b9b3653de2dcb51a579f939b991beac03149 100644
|
||||
--- a/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
+++ b/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
@@ -122,6 +122,12 @@ public class WitherSkull extends AbstractHurtingProjectile {
|
||||
return target != this.getRider() && super.canHitEntity(target);
|
||||
}
|
||||
// Purpur end - Ridables
|
||||
+ // Purpur start - Add canSaveToDisk to Entity
|
||||
+ @Override
|
||||
+ public boolean canSaveToDisk() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Add canSaveToDisk to Entity
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||
diff --git a/net/minecraft/world/level/chunk/storage/EntityStorage.java b/net/minecraft/world/level/chunk/storage/EntityStorage.java
|
||||
index 356d010506fd21f3c752e4aa86c46c1106fdde3b..8573d4dbb45db6510d1a4deccb3e5a257504f7d5 100644
|
||||
--- a/net/minecraft/world/level/chunk/storage/EntityStorage.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java
|
||||
@@ -106,6 +106,7 @@ public class EntityStorage implements EntityPersistentStorage<Entity> {
|
||||
}
|
||||
// Paper end - Entity load/save limit per chunk
|
||||
CompoundTag compoundTagx = new CompoundTag();
|
||||
+ if (!entity.canSaveToDisk()) return; // Purpur - Add canSaveToDisk to Entity
|
||||
if (entity.save(compoundTagx)) {
|
||||
listTag.add(compoundTagx);
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java b/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java
|
||||
index e33e54fc31ab7dcff054d0ab245d6c3391d06449..477ae2cd8ded25023976e3b7525e0c3b0e8259d9 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/entity/DolphinSpit.java
|
||||
@@ -36,6 +36,13 @@ public class DolphinSpit extends LlamaSpit {
|
||||
dolphin.getZ() + (double) (dolphin.getBbWidth() + 1.0F) * 0.5D * (double) Mth.cos(dolphin.yBodyRot * 0.017453292F));
|
||||
}
|
||||
|
||||
+ // Purpur start - Add canSaveToDisk to Entity
|
||||
+ @Override
|
||||
+ public boolean canSaveToDisk() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Add canSaveToDisk to Entity
|
||||
+
|
||||
public void tick() {
|
||||
super_tick();
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java b/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
|
||||
index 3759e45afe16bf1d8a37b78d3526ee446e63cfe5..f57d77c0cab0174e67c1fdda6ac56f408ad6a902 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
|
||||
@@ -38,6 +38,13 @@ public class PhantomFlames extends LlamaSpit {
|
||||
phantom.getZ() + (double) (phantom.getBbWidth() + 1.0F) * 0.5D * (double) Mth.cos(phantom.yBodyRot * 0.017453292F));
|
||||
}
|
||||
|
||||
+ // Purpur start - Add canSaveToDisk to Entity
|
||||
+ @Override
|
||||
+ public boolean canSaveToDisk() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Add canSaveToDisk to Entity
|
||||
+
|
||||
public void tick() {
|
||||
super_tick();
|
||||
|
||||
@@ -75,10 +75,10 @@ index b083228bb3dc87794c6f177ad99832daf6925a39..bf863cfae63a50636c3fcc8fcf9761f1
|
||||
if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
|
||||
target.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index eef36c568050b790908787a2d423db6f7b8cf313..10fd7f0274d1a6a954f01244f6e1e356bd190211 100644
|
||||
index 539741e6fcc2a9d987e6db4df7a886d739c3cf10..605cb383f4749135f61d330dc2e3e198edd00213 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -3130,6 +3130,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -3136,6 +3136,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
this.passengers = ImmutableList.copyOf(list);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ index eef36c568050b790908787a2d423db6f7b8cf313..10fd7f0274d1a6a954f01244f6e1e356
|
||||
this.gameEvent(GameEvent.ENTITY_MOUNT, passenger);
|
||||
}
|
||||
}
|
||||
@@ -3171,6 +3178,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -3177,6 +3184,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return false;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -107,7 +107,7 @@ index eef36c568050b790908787a2d423db6f7b8cf313..10fd7f0274d1a6a954f01244f6e1e356
|
||||
if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) {
|
||||
this.passengers = ImmutableList.of();
|
||||
} else {
|
||||
@@ -5085,4 +5100,44 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5091,4 +5106,44 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return ((ServerLevel) this.level).isPositionEntityTicking(this.blockPosition());
|
||||
}
|
||||
// Paper end - Expose entity id counter
|
||||
@@ -5032,7 +5032,7 @@ index 47c1ad2ef30d464abb3c804260f0fd7cde193ba5..c6b3894fe085c2b565651ab3ae2f1acb
|
||||
this.openTradingScreen(player, this.getDisplayName(), 1);
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index 3bc8b32e9eb39745c487d377474358c8c2e5b787..a65023d0929435785116682c1378428120340547 100644
|
||||
index a8a605188f42b7875e616424be34c4bca823dd38..f58c49e6b8f121ea56f11bc107aa236969aa3208 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -218,6 +218,19 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -5073,12 +5073,12 @@ index 4880db97135d54fa72f64c108b2bd4ded096438b..bc102b049047d6e2a1d29e10f92cdf5a
|
||||
protected double getDefaultGravity() {
|
||||
return 0.06;
|
||||
diff --git a/net/minecraft/world/entity/projectile/WitherSkull.java b/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
index a83839fce264429e2a8fd3b19cd2d0a6d88585e0..93aa35ed53e84d06245613b0d64d3fbb158354fe 100644
|
||||
index 843a359d082ac1eba56f37179a6b28251dbf7c94..db071d4f98513b56bcc83e80fc2e5ee9609888af 100644
|
||||
--- a/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
+++ b/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
@@ -103,6 +103,14 @@ public class WitherSkull extends AbstractHurtingProjectile {
|
||||
}
|
||||
@@ -110,6 +110,14 @@ public class WitherSkull extends AbstractHurtingProjectile {
|
||||
}
|
||||
// Purpur end - Add canSaveToDisk to Entity
|
||||
|
||||
+ // Purpur start - Ridables
|
||||
+ @Override
|
||||
|
||||
@@ -17,6 +17,19 @@
|
||||
public boolean noPhysics;
|
||||
private boolean wasOnFire;
|
||||
public final RandomSource random = SHARED_RANDOM; // Paper - Share random for entities to make them more random
|
||||
@@ -526,6 +_,12 @@
|
||||
}
|
||||
// Paper end - optimise entity tracker
|
||||
|
||||
+ // Purpur start - Add canSaveToDisk to Entity
|
||||
+ public boolean canSaveToDisk() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Purpur end - Add canSaveToDisk to Entity
|
||||
+
|
||||
public Entity(EntityType<?> entityType, Level level) {
|
||||
this.type = entityType;
|
||||
this.level = level;
|
||||
@@ -2922,6 +_,7 @@
|
||||
if (this.isAlive() && this instanceof Leashable leashable) {
|
||||
if (leashable.getLeashHolder() == player) {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
+++ b/net/minecraft/world/entity/projectile/WitherSkull.java
|
||||
@@ -103,6 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start - Add canSaveToDisk to Entity
|
||||
+ @Override
|
||||
+ public boolean canSaveToDisk() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Add canSaveToDisk to Entity
|
||||
+
|
||||
@Override
|
||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||
builder.define(DATA_DANGEROUS, false);
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/world/level/chunk/storage/EntityStorage.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java
|
||||
@@ -106,6 +_,7 @@
|
||||
}
|
||||
// Paper end - Entity load/save limit per chunk
|
||||
CompoundTag compoundTag1 = new CompoundTag();
|
||||
+ if (!entity.canSaveToDisk()) return; // Purpur - Add canSaveToDisk to Entity
|
||||
if (entity.save(compoundTag1)) {
|
||||
listTag.add(compoundTag1);
|
||||
}
|
||||
@@ -35,6 +35,11 @@ public class DolphinSpit extends LlamaSpit {
|
||||
dolphin.getZ() + (double) (dolphin.getBbWidth() + 1.0F) * 0.5 * (double) Mth.cos(dolphin.yBodyRot * (float) (Math.PI / 180.0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSaveToDisk() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
projectileTick();
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ public class PhantomFlames extends LlamaSpit {
|
||||
phantom.getZ() + (double) (phantom.getBbWidth() + 1.0F) * 0.5D * (double) Mth.cos(phantom.yBodyRot * (float) (Math.PI / 180.0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSaveToDisk() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
projectileTick();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user