mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
re-add sign and book color code patches
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 11 Jul 2020 19:41:34 -0500
|
||||
Subject: [PATCH] Entity lifespan
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 510a4391463026dd0c896027a579a94174c24299..f7cded2bac3d58c3c5b3082cdff7d38577733646 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2800,6 +2800,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
AABB axisalignedbb = entity.getBoundingBox();
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) {
|
||||
+ if (entity instanceof Mob mob) mob.ticksSinceLastInteraction = 0; // Purpur
|
||||
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||
private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
||||
ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index c4392a997061aa4939e5ad7dcacf5e39cbecc55a..e7251ac940b49564c83b4b603e49c3990fc85db1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -152,6 +152,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
private BlockPos restrictCenter;
|
||||
private float restrictRadius;
|
||||
|
||||
+ public int ticksSinceLastInteraction; // Purpur
|
||||
public boolean aware = true; // CraftBukkit
|
||||
|
||||
protected Mob(EntityType<? extends Mob> type, Level world) {
|
||||
@@ -339,6 +340,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
entityliving = null;
|
||||
}
|
||||
}
|
||||
+ if (entityliving instanceof ServerPlayer) this.ticksSinceLastInteraction = 0; // Purpur
|
||||
this.target = entityliving;
|
||||
return true;
|
||||
// CraftBukkit end
|
||||
@@ -381,8 +383,28 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
}
|
||||
|
||||
this.level().getProfiler().pop();
|
||||
+ incrementTicksSinceLastInteraction(); // Purpur
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ private void incrementTicksSinceLastInteraction() {
|
||||
+ ++this.ticksSinceLastInteraction;
|
||||
+ if (getRider() != null) {
|
||||
+ this.ticksSinceLastInteraction = 0;
|
||||
+ return;
|
||||
+ }
|
||||
+ if (this.level().purpurConfig.entityLifeSpan <= 0) {
|
||||
+ return; // feature disabled
|
||||
+ }
|
||||
+ if (!this.removeWhenFarAway(0) || isPersistenceRequired() || requiresCustomPersistence() || hasCustomName()) {
|
||||
+ return; // mob persistent
|
||||
+ }
|
||||
+ if (this.ticksSinceLastInteraction > this.level().purpurConfig.entityLifeSpan) {
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
@Override
|
||||
protected void playHurtSound(DamageSource damageSource) {
|
||||
this.resetAmbientSoundTime();
|
||||
@@ -585,6 +607,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
}
|
||||
|
||||
nbt.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit
|
||||
+ nbt.putInt("Purpur.ticksSinceLastInteraction", this.ticksSinceLastInteraction); // Purpur
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -669,6 +692,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
this.aware = nbt.getBoolean("Bukkit.Aware");
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Purpur start
|
||||
+ if (nbt.contains("Purpur.ticksSinceLastInteraction")) {
|
||||
+ this.ticksSinceLastInteraction = nbt.getInt("Purpur.ticksSinceLastInteraction");
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1848,6 +1876,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
this.setLastHurtMob(target);
|
||||
}
|
||||
|
||||
+ if (target instanceof ServerPlayer) this.ticksSinceLastInteraction = 0; // Purpur
|
||||
return flag;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 55ae989ae13ae9c0730f6f8df5f7eba52a560b1f..9ba3a90e1af9c733949c52988c56c05af46356e8 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -125,6 +125,11 @@ public class PurpurWorldConfig {
|
||||
elytraDamagePerTridentBoost = getInt("gameplay-mechanics.elytra.damage-per-boost.trident", elytraDamagePerTridentBoost);
|
||||
}
|
||||
|
||||
+ public int entityLifeSpan = 0;
|
||||
+ private void entitySettings() {
|
||||
+ entityLifeSpan = getInt("gameplay-mechanics.entity-lifespan", entityLifeSpan);
|
||||
+ }
|
||||
+
|
||||
public List<Item> itemImmuneToCactus = new ArrayList<>();
|
||||
public List<Item> itemImmuneToExplosion = new ArrayList<>();
|
||||
public List<Item> itemImmuneToFire = new ArrayList<>();
|
||||
Reference in New Issue
Block a user