Skip to content

Commit

Permalink
Add option for sparing item entities
Browse files Browse the repository at this point in the history
Conflicts:
	build.gradle
  • Loading branch information
ljfa-ag committed Feb 13, 2016
1 parent 3308aa4 commit 7991695
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 @@ -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"

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 @@ -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) {
Expand Down Expand Up @@ -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();
//----------------
}
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 @@ -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;
Expand Down Expand Up @@ -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<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 7991695

Please sign in to comment.