diff --git a/build.gradle b/build.gradle index 58e175a..9e4c7ba 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "1.12.2-0.4.6" +version = "1.12.2-0.4.7" group = "com.charles445.rltweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "RLTweaker" diff --git a/src/main/java/com/charles445/rltweaker/RLTweaker.java b/src/main/java/com/charles445/rltweaker/RLTweaker.java index 2852015..f05a76f 100644 --- a/src/main/java/com/charles445/rltweaker/RLTweaker.java +++ b/src/main/java/com/charles445/rltweaker/RLTweaker.java @@ -79,7 +79,7 @@ public class RLTweaker { public static final String MODID = "rltweaker"; public static final String NAME = "RLTweaker"; - public static final String VERSION = "0.4.6"; + public static final String VERSION = "0.4.7"; public static final VersionDelimiter VERSION_DELIMITER = new VersionDelimiter(VERSION); public static final VersionDelimiter MINIMUM_VERSION = new VersionDelimiter("0.3.0"); diff --git a/src/main/java/com/charles445/rltweaker/config/ConfigBetterSurvival.java b/src/main/java/com/charles445/rltweaker/config/ConfigBetterSurvival.java index a3fe4b6..fe26f81 100644 --- a/src/main/java/com/charles445/rltweaker/config/ConfigBetterSurvival.java +++ b/src/main/java/com/charles445/rltweaker/config/ConfigBetterSurvival.java @@ -42,6 +42,13 @@ public class ConfigBetterSurvival @RLConfig.RLCraftTwoNine("true") public boolean tunnelingCancelable = true; + @Config.Comment("Whether tunneling can break tile entities") + @Config.Name("Tunneling Breaks Tile Entities") + @RLConfig.ImprovementsOnly("false") + @RLConfig.RLCraftTwoEightTwo("true") + @RLConfig.RLCraftTwoNine("false") + public boolean tunnelingBreaksTileEntities = false; + @Config.Comment("Speed multiplier for the Range enchantment. Default is 2") @Config.Name("Range Speed Multiplier") @RLConfig.ImprovementsOnly("2.0") diff --git a/src/main/java/com/charles445/rltweaker/handler/BetterSurvivalHandler.java b/src/main/java/com/charles445/rltweaker/handler/BetterSurvivalHandler.java index 035db37..413315e 100644 --- a/src/main/java/com/charles445/rltweaker/handler/BetterSurvivalHandler.java +++ b/src/main/java/com/charles445/rltweaker/handler/BetterSurvivalHandler.java @@ -22,7 +22,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -191,7 +193,7 @@ public void onBreakHighCancel(final BlockEvent.BreakEvent event) public void onBreakAny(final BlockEvent.BreakEvent event) { - if(disabled || !ModConfig.server.bettersurvival.tunnelingBlacklistEnabled) + if(disabled) { handler.invoke(event); return; @@ -229,6 +231,7 @@ public void onBreakAny(final BlockEvent.BreakEvent event) boolean tagUp = player.getTags().contains("up"); boolean tagDown = player.getTags().contains("down"); + boolean isBlacklistEnabled = ModConfig.server.bettersurvival.tunnelingBlacklistEnabled; boolean isWhitelist = ModConfig.server.bettersurvival.tunnelingBlacklistIsWhitelist; String[] blacklist = ModConfig.server.bettersurvival.tunnelingBlacklist; @@ -251,27 +254,39 @@ public void onBreakAny(final BlockEvent.BreakEvent event) boolean isNotCenter = !(x == 0 && y == 0 && z == 0); if(isInRadius && isNotCenter) { + BlockPos newpos = event.getPos().add(x,y,z); + + if(!ModConfig.server.bettersurvival.tunnelingBreaksTileEntities) + { + //Check tile entity + if(world.getTileEntity(newpos) != null) + return; + } + //Check if the block is blacklisted - Block block = world.getBlockState(event.getPos().add(x,y,z)).getBlock(); + Block block = world.getBlockState(newpos).getBlock(); //TODO issues with whitelist behavior due to it picking up all sorts of blocks that are normally skipped //Skip air though for sure if(block == Blocks.AIR) continue; - String blockRegistry = block.getRegistryName().toString(); - boolean inBlacklist = false; - for(String entry : blacklist) + if(isBlacklistEnabled) { - if(entry.equals(blockRegistry)) + String blockRegistry = block.getRegistryName().toString(); + boolean inBlacklist = false; + for(String entry : blacklist) { - inBlacklist = true; - break; + if(entry.equals(blockRegistry)) + { + inBlacklist = true; + break; + } } + + if(inBlacklist != isWhitelist) + return; } - - if(inBlacklist != isWhitelist) - return; } } }