From 8240c182d22f7536a0dd3ac8e7c8edf54252af2a Mon Sep 17 00:00:00 2001 From: Hermelijn15 <79708538+Hermelijn15@users.noreply.github.com> Date: Mon, 20 Nov 2023 20:18:36 +0100 Subject: [PATCH] Added explosion proof items (#5) * Added exposion proof items * Remove getLevel and use level accessor instead * Move items configuration section into entity * Remove extra parentheses in condition * Remove explosion proof configuration section * Use an empty list instead of providing a default item --------- Co-authored-by: Samsuik <40902469+Samsuik@users.noreply.github.com> --- .../0004-Sakura-Configuration-Files.patch | 11 ++++++-- ...-ItemEntity-s-that-ignore-explosions.patch | 28 +++++++++++++++++++ ...034-Add-option-to-disable-entity-ai.patch} | 0 ...> 0035-Reduce-living-entity-sensing.patch} | 0 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 patches/server/0033-Added-list-of-ItemEntity-s-that-ignore-explosions.patch rename patches/server/{0033-Add-option-to-disable-entity-ai.patch => 0034-Add-option-to-disable-entity-ai.patch} (100%) rename patches/server/{0034-Reduce-living-entity-sensing.patch => 0035-Reduce-living-entity-sensing.patch} (100%) diff --git a/patches/server/0004-Sakura-Configuration-Files.patch b/patches/server/0004-Sakura-Configuration-Files.patch index df28503..7a35d8d 100644 --- a/patches/server/0004-Sakura-Configuration-Files.patch +++ b/patches/server/0004-Sakura-Configuration-Files.patch @@ -608,10 +608,10 @@ index 0000000000000000000000000000000000000000..5fc23a0b579d7cbe03baf5324bef887a +} diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..78793a8091aad0aecd8175c1eab73cd7516e2311 +index 0000000000000000000000000000000000000000..4cb5a385e660be058ba471c779a2e2e7b7bb6605 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java -@@ -0,0 +1,131 @@ +@@ -0,0 +1,138 @@ +package me.samsuik.sakura.configuration; + +import com.mojang.logging.LogUtils; @@ -626,12 +626,14 @@ index 0000000000000000000000000000000000000000..78793a8091aad0aecd8175c1eab73cd7 +import net.minecraft.Util; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.item.FallingBlockEntity; ++import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import org.slf4j.Logger; +import org.spongepowered.configurate.objectmapping.meta.Comment; +import org.spongepowered.configurate.objectmapping.meta.Setting; + ++import java.util.List; +import java.util.Map; + +@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"}) @@ -740,6 +742,11 @@ index 0000000000000000000000000000000000000000..78793a8091aad0aecd8175c1eab73cd7 + public class Entity extends ConfigurationPart { + @Comment("Only modify if you know what you're doing") + public boolean disableMobAi = false; ++ ++ public Items items = new Items(); ++ public class Items extends ConfigurationPart { ++ public List explosionResistantItems = List.of(); ++ } + } + +} diff --git a/patches/server/0033-Added-list-of-ItemEntity-s-that-ignore-explosions.patch b/patches/server/0033-Added-list-of-ItemEntity-s-that-ignore-explosions.patch new file mode 100644 index 0000000..84927dd --- /dev/null +++ b/patches/server/0033-Added-list-of-ItemEntity-s-that-ignore-explosions.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Hermelijn15 +Date: Fri, 17 Nov 2023 20:09:03 +0100 +Subject: [PATCH] Added list of ItemEntity's that ignore explosions + + +diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +index eb0351aa12eebcefab1d1d14641fc3c60cbbcab8..92c8cae1709052ec09715b6f27e6b0199762a00e 100644 +--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java ++++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +@@ -559,6 +559,17 @@ public class ItemEntity extends Entity implements TraceableEntity { + + } + ++ // Sakura start ++ @Override ++ public boolean ignoreExplosion() { ++ if (this.level().sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) { ++ return true; ++ } else { ++ return super.ignoreExplosion(); ++ } ++ } ++ // Sakura end ++ + public void setTarget(@Nullable UUID owner) { + this.target = owner; + } diff --git a/patches/server/0033-Add-option-to-disable-entity-ai.patch b/patches/server/0034-Add-option-to-disable-entity-ai.patch similarity index 100% rename from patches/server/0033-Add-option-to-disable-entity-ai.patch rename to patches/server/0034-Add-option-to-disable-entity-ai.patch diff --git a/patches/server/0034-Reduce-living-entity-sensing.patch b/patches/server/0035-Reduce-living-entity-sensing.patch similarity index 100% rename from patches/server/0034-Reduce-living-entity-sensing.patch rename to patches/server/0035-Reduce-living-entity-sensing.patch