9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-21 15:59:26 +00:00

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>
This commit is contained in:
Hermelijn15
2023-11-20 20:18:36 +01:00
committed by GitHub
parent 9bf210932a
commit 8240c182d2
4 changed files with 37 additions and 2 deletions

View File

@@ -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<Item> explosionResistantItems = List.of();
+ }
+ }
+
+}

View File

@@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Hermelijn15 <j.s.dekker-1@student.utwente.nl>
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;
}