From 79916955ecec5b3f9edda6fa48b89b3748f2a623 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Sat, 13 Feb 2016 10:59:07 +0100 Subject: [PATCH] Add option for sparing item entities Conflicts: build.gradle --- build.gradle | 2 +- src/main/java/ljfa/tntutils/Config.java | 4 +++- src/main/java/ljfa/tntutils/handlers/ExplosionHandler.java | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 2fcdff3..0772fe6 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ buildscript { apply plugin: 'forge' apply plugin: 'curseforge' -version = "1.1-beta" +version = "1.1.3" group= "ljfa.tntutils" archivesBaseName = "tnt_utilities-mc1.7.10" diff --git a/src/main/java/ljfa/tntutils/Config.java b/src/main/java/ljfa/tntutils/Config.java index 67824c5..e7da375 100644 --- a/src/main/java/ljfa/tntutils/Config.java +++ b/src/main/java/ljfa/tntutils/Config.java @@ -38,6 +38,7 @@ public class Config { public static boolean disableEntityDamage; public static boolean disablePlayerDamage; + public static boolean disableItemDamage; public static boolean disableNPCDamage; public static void loadConfig(File file) { @@ -67,8 +68,9 @@ public static void loadValues() { disableCreeperBlockDamage = conf.get(CAT_BLOCKDMG, "disableCreeperBlockDamage", false, "\"Environmentally Friendly Creepers\": Makes creepers not destroy blocks").getBoolean(); spareTileEntities = conf.get(CAT_BLOCKDMG, "disableTileEntityDamage", false, "Makes explosions not destroy blocks with tile entities").getBoolean(); //---------------- - disableEntityDamage = conf.get(CAT_ENTDMG, "disableEntityDamage", false, "Disables explosion damage to all entities (also includes items, minecarts etc.)").getBoolean(); + disableEntityDamage = conf.get(CAT_ENTDMG, "disableEntityDamage", false, "Disables explosion damage to all entities (also includes minecarts, paintings etc.)").getBoolean(); disablePlayerDamage = conf.get(CAT_ENTDMG, "disablePlayerDamage", false, "Disables explosion damage to players").getBoolean(); + disableItemDamage = conf.get(CAT_ENTDMG, "disableItemDamage", false, "Disables explosion damage to items laying on the ground").getBoolean(); disableNPCDamage = conf.get(CAT_ENTDMG, "disableNPCDamage", false, "Disables explosion damage to animals and mobs").getBoolean(); //---------------- } diff --git a/src/main/java/ljfa/tntutils/handlers/ExplosionHandler.java b/src/main/java/ljfa/tntutils/handlers/ExplosionHandler.java index 7a245fc..7f494eb 100644 --- a/src/main/java/ljfa/tntutils/handlers/ExplosionHandler.java +++ b/src/main/java/ljfa/tntutils/handlers/ExplosionHandler.java @@ -7,6 +7,7 @@ import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityMinecartTNT; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.player.EntityPlayer; @@ -44,13 +45,14 @@ public boolean test(ChunkPosition pos) { //Entity damage if(Config.disableEntityDamage) event.getAffectedEntities().clear(); - else if(Config.disablePlayerDamage || Config.disableNPCDamage || Config.preventChainExpl) { - //Remove certain from the list + else if(Config.disablePlayerDamage || Config.disableItemDamage || Config.disableNPCDamage || Config.preventChainExpl) { + //Remove configured entities from the list ListHelper.removeIf(event.getAffectedEntities(), new Predicate() { @Override public boolean test(Entity ent) { return (Config.disableNPCDamage && ent instanceof EntityLivingBase && !(ent instanceof EntityPlayer)) || (Config.disablePlayerDamage && ent instanceof EntityPlayer) + || (Config.disableItemDamage && ent instanceof EntityItem) || (Config.preventChainExpl && ent instanceof EntityMinecartTNT); } });