Skip to content

Commit

Permalink
Add option for sparing item entities
Browse files Browse the repository at this point in the history
  • Loading branch information
ljfa-ag committed Feb 13, 2016
1 parent 03a5c93 commit 5d64aa4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plugins {

apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.1.2"
version = "1.1.3"
group= "ljfa.tntutils"
archivesBaseName = "tnt_utilities-mc1.8.9"

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/ljfa/tntutils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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) {
Expand Down Expand Up @@ -68,8 +69,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();
//----------------
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/ljfa/tntutils/handlers/ExplosionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.block.state.IBlockState;
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;
Expand Down Expand Up @@ -42,13 +43,14 @@ public boolean test(BlockPos 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<Entity>() {
@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);
}
});
Expand Down

0 comments on commit 5d64aa4

Please sign in to comment.