mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 18:07:43 +01:00
Add item immunities option for cactus
This commit is contained in:
@@ -17,41 +17,47 @@ index 982b00049149bba1c49bb2a0ecaed38ad4c4a267..929b909f05fa226ea3305671a7932475
|
||||
return this.O == tag;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
index d99cecc4075338d7b8f154ab94d8ac04190ba371..cbe03923d468bf75adc10245ebd9f63ff10987f9 100644
|
||||
index d99cecc4075338d7b8f154ab94d8ac04190ba371..ec37d2c3b0393c43097bdfc6064ebe3ab8bc28ce 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
@@ -23,6 +23,8 @@ public class EntityItem extends Entity {
|
||||
@@ -23,6 +23,9 @@ public class EntityItem extends Entity {
|
||||
public final float b;
|
||||
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
|
||||
public boolean canMobPickup = true; // Paper
|
||||
+ public boolean immuneToCactus = false; // Purpur
|
||||
+ public boolean immuneToExplosion = false; // Purpur
|
||||
+ public boolean immuneToFire = false; // Purpur
|
||||
|
||||
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -274,6 +276,12 @@ public class EntityItem extends Entity {
|
||||
@@ -274,6 +277,16 @@ public class EntityItem extends Entity {
|
||||
return false;
|
||||
} else if (!this.getItemStack().getItem().a(damagesource)) {
|
||||
return false;
|
||||
+ // Purpur start
|
||||
+ } else if (immuneToCactus && damagesource == DamageSource.CACTUS) {
|
||||
+ respawnOnClient();
|
||||
+ return false;
|
||||
+ } else if (immuneToFire && (damagesource.isFire() || damagesource == DamageSource.FIRE)) {
|
||||
+ return false;
|
||||
+ } else if (immuneToExplosion && damagesource.isExplosion()) {
|
||||
+ respawnOnClient(); return false;
|
||||
+ respawnOnClient();
|
||||
+ return false;
|
||||
+ // Purpur end
|
||||
} else {
|
||||
// CraftBukkit start
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
|
||||
@@ -454,6 +462,8 @@ public class EntityItem extends Entity {
|
||||
@@ -454,6 +467,9 @@ public class EntityItem extends Entity {
|
||||
com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit
|
||||
this.getDataWatcher().set(EntityItem.ITEM, itemstack);
|
||||
this.getDataWatcher().markDirty(EntityItem.ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty
|
||||
+ if (world.purpurConfig.itemImmuneToCactus.contains(itemstack.getItem())) immuneToCactus = true; // Purpur
|
||||
+ if (world.purpurConfig.itemImmuneToExplosion.contains(itemstack.getItem())) immuneToExplosion = true; // Purpur
|
||||
+ if (world.purpurConfig.itemImmuneToFire.contains(itemstack.getItem())) immuneToFire = true; // Purpur
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -535,4 +545,15 @@ public class EntityItem extends Entity {
|
||||
@@ -535,4 +551,15 @@ public class EntityItem extends Entity {
|
||||
super.setPositionRaw(x, y, z);
|
||||
}
|
||||
// Paper end - fix MC-4
|
||||
@@ -88,16 +94,22 @@ index 228236bce14bfdf930570b453862dcfaae9e4823..ad06bd81eded5d60f16c2d0ad1a4390f
|
||||
int i;
|
||||
int j;
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 886c3b98d6bff04a93cd963a092654ef1c9729d1..793c43299e71526cca01dba3badf06dca52333c6 100644
|
||||
index 886c3b98d6bff04a93cd963a092654ef1c9729d1..75250392135f416e766e44ffdad7eecd06a89ae5 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -101,6 +101,21 @@ public class PurpurWorldConfig {
|
||||
@@ -101,6 +101,27 @@ public class PurpurWorldConfig {
|
||||
}
|
||||
}
|
||||
|
||||
+ public List<Item> itemImmuneToCactus = new ArrayList<>();
|
||||
+ public List<Item> itemImmuneToExplosion = new ArrayList<>();
|
||||
+ public List<Item> itemImmuneToFire = new ArrayList<>();
|
||||
+ private void itemSettings() {
|
||||
+ itemImmuneToCactus.clear();
|
||||
+ getList("gameplay-mechanics.item.immune.cactus", new ArrayList<>()).forEach(key -> {
|
||||
+ Item item = IRegistry.ITEM.get(new MinecraftKey(key.toString()));
|
||||
+ if (item != Items.AIR) itemImmuneToCactus.add(item);
|
||||
+ });
|
||||
+ itemImmuneToExplosion.clear();
|
||||
+ getList("gameplay-mechanics.item.immune.explosion", new ArrayList<>()).forEach(key -> {
|
||||
+ Item item = IRegistry.ITEM.get(new MinecraftKey(key.toString()));
|
||||
@@ -114,16 +126,21 @@ index 886c3b98d6bff04a93cd963a092654ef1c9729d1..793c43299e71526cca01dba3badf06dc
|
||||
public boolean idleTimeoutTickNearbyEntities = true;
|
||||
public boolean idleTimeoutCountAsSleeping = false;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
index bcbaad11852a51436a00c8e172bdd841ba93ec3c..96628c39e315d57b0153266cee48ee85ee3a0841 100644
|
||||
index bcbaad11852a51436a00c8e172bdd841ba93ec3c..8e8eaa2df20773948ec160b94798fb8ca74c326a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
@@ -114,4 +114,26 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
@@ -114,4 +114,31 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
public EntityType getType() {
|
||||
return EntityType.DROPPED_ITEM;
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ @Override
|
||||
+ public boolean isImmuneToCactus() {
|
||||
+ return item.immuneToCactus;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setImmuneToExplosion(boolean immuneToExplosion) {
|
||||
+ item.immuneToExplosion = immuneToExplosion;
|
||||
+ }
|
||||
|
||||
Reference in New Issue
Block a user