mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add item entity options
This commit is contained in:
@@ -344,6 +344,37 @@ gameplay-mechanics
|
||||
- minecraft:stone: 0.6
|
||||
- minecraft:black_concrete: 1.0
|
||||
|
||||
* item
|
||||
* float-in-lava
|
||||
- **default**: false
|
||||
- **description**: Can items float in lava
|
||||
|
||||
* immune
|
||||
* explosions
|
||||
- **default**: {}
|
||||
- **description**: List of items that are immune to explosions
|
||||
|
||||
* fire
|
||||
- **default**: {}
|
||||
- **description**: List of items that are immune to fire
|
||||
|
||||
* lava
|
||||
- **default**: {}
|
||||
- **description**: List of items that are immune to lava
|
||||
|
||||
.. note::
|
||||
Example of item immune list:
|
||||
* explosions:
|
||||
- minecraft:diamond
|
||||
- minecraft:diamond_block
|
||||
- minecraft:diamond_sword
|
||||
|
||||
.. warning::
|
||||
These item immune lists can cause client desync issues, such as invisible items on the ground!
|
||||
There is nothing I can do about that from the server side, but I have patched this in my
|
||||
client mod, (PurpurClient) <https://ci.pl3x.net/job/PurpurClient/>, starting with build #12.
|
||||
|
||||
|
||||
* player
|
||||
* exp-dropped-on-death
|
||||
* equation
|
||||
|
||||
112
patches/server/0100-Add-item-entity-options.patch
Normal file
112
patches/server/0100-Add-item-entity-options.patch
Normal file
@@ -0,0 +1,112 @@
|
||||
From 399ece0fbdb1e0fba235c13d2358ea3a813715e5 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 22 Feb 2020 15:54:08 -0600
|
||||
Subject: [PATCH] Add item entity options
|
||||
|
||||
---
|
||||
.../java/net/minecraft/server/Entity.java | 1 +
|
||||
.../java/net/minecraft/server/EntityItem.java | 9 ++++++++-
|
||||
.../net/pl3x/purpur/PurpurWorldConfig.java | 20 +++++++++++++++++++
|
||||
3 files changed, 29 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index f1c749c38f..98aef47056 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1257,6 +1257,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
|
||||
}
|
||||
|
||||
+ public boolean isInLiquid(Tag<FluidType> tag) { return a(tag); } // Purpur - OBFHELPER
|
||||
public boolean a(Tag<FluidType> tag) {
|
||||
return this.a(tag, false);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
index bbb9ca1efc..262a7935e7 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
@@ -71,7 +71,7 @@ public class EntityItem extends Entity {
|
||||
this.lastZ = this.locZ();
|
||||
Vec3D vec3d = this.getMot();
|
||||
|
||||
- if (this.a(TagsFluid.WATER)) {
|
||||
+ if (isInLiquid(TagsFluid.WATER) || (world.purpurConfig.itemFloatInLava && isInLiquid(TagsFluid.LAVA))) { // Purpur
|
||||
this.u();
|
||||
} else if (!this.isNoGravity()) {
|
||||
this.setMot(this.getMot().add(0.0D, -0.04D, 0.0D));
|
||||
@@ -105,6 +105,7 @@ public class EntityItem extends Entity {
|
||||
|
||||
if (this.ticksLived % i == 0) {
|
||||
if (this.world.getFluid(new BlockPosition(this)).a(TagsFluid.LAVA)) {
|
||||
+ if (!world.purpurConfig.itemImmuneToLava.contains(getItemStack().getItem())) // Purpur
|
||||
this.setMot((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F), 0.20000000298023224D, (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F));
|
||||
this.a(SoundEffects.ENTITY_GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
|
||||
}
|
||||
@@ -282,6 +283,12 @@ public class EntityItem extends Entity {
|
||||
} else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) {
|
||||
return false;
|
||||
} else {
|
||||
+ // Purpur start
|
||||
+ Item item = getItemStack().getItem();
|
||||
+ if (world.purpurConfig.itemImmuneToLava.contains(item) && damagesource == DamageSource.LAVA) return false;
|
||||
+ if (world.purpurConfig.itemImmuneToFire.contains(item) && (damagesource.isFire() || damagesource == DamageSource.FIRE)) return false;
|
||||
+ if (world.purpurConfig.itemImmuneToExplosion.contains(item) && damagesource.isExplosion()) return false;
|
||||
+ // Purpur end
|
||||
// CraftBukkit start
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
|
||||
return false;
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 5054f7b6a3..93df565c02 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -5,6 +5,8 @@ import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.Explosion;
|
||||
import net.minecraft.server.IRegistry;
|
||||
+import net.minecraft.server.Item;
|
||||
+import net.minecraft.server.Items;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.spigotmc.SpigotWorldConfig;
|
||||
@@ -14,6 +16,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
+import java.util.stream.Collectors;
|
||||
|
||||
import static net.pl3x.purpur.PurpurConfig.log;
|
||||
|
||||
@@ -185,6 +188,10 @@ public class PurpurWorldConfig {
|
||||
public Map<Block, Double> controllableMinecartsBlockSpeeds = new HashMap<>();
|
||||
public boolean disableDropsOnCrammingDeath = false;
|
||||
public boolean fixClimbingBypassingCrammingRule = false;
|
||||
+ public boolean itemFloatInLava = false;
|
||||
+ public List<Item> itemImmuneToExplosion = new ArrayList<>();
|
||||
+ public List<Item> itemImmuneToFire = new ArrayList<>();
|
||||
+ public List<Item> itemImmuneToLava = new ArrayList<>();
|
||||
public boolean milkCuresBadOmen = true;
|
||||
public String playerDeathExpDropEquation = "expLevel * 7";
|
||||
public int playerDeathExpDropMax = 100;
|
||||
@@ -214,6 +221,19 @@ public class PurpurWorldConfig {
|
||||
}
|
||||
disableDropsOnCrammingDeath = getBoolean("gameplay-mechanics.disable-drops-on-cramming-death", disableDropsOnCrammingDeath);
|
||||
fixClimbingBypassingCrammingRule = getBoolean("gameplay-mechanics.fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule);
|
||||
+ itemFloatInLava = getBoolean("gameplay-mechanics.item.float-in-lava", itemFloatInLava);
|
||||
+ getList("gameplay-mechanics.item.immune.explosion", itemImmuneToExplosion).forEach(key -> {
|
||||
+ Item item = IRegistry.ITEM.get(new MinecraftKey((String) key));
|
||||
+ if (item != Items.AIR) itemImmuneToExplosion.add(item);
|
||||
+ });
|
||||
+ getList("gameplay-mechanics.item.immune.fire", itemImmuneToFire).forEach(key -> {
|
||||
+ Item item = IRegistry.ITEM.get(new MinecraftKey((String) key));
|
||||
+ if (item != Items.AIR) itemImmuneToFire.add(item);
|
||||
+ });
|
||||
+ getList("gameplay-mechanics.item.immune.lava", itemImmuneToLava).forEach(key -> {
|
||||
+ Item item = IRegistry.ITEM.get(new MinecraftKey((String) key));
|
||||
+ if (item != Items.AIR) itemImmuneToLava.add(item);
|
||||
+ });
|
||||
milkCuresBadOmen = getBoolean("gameplay-mechanics.milk-cures-bad-omen", milkCuresBadOmen);
|
||||
playerDeathExpDropEquation = getString("gameplay-mechanics.player.exp-dropped-on-death.equation", playerDeathExpDropEquation);
|
||||
playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax);
|
||||
--
|
||||
2.24.0
|
||||
|
||||
Reference in New Issue
Block a user