Skip to content

Commit

Permalink
Better Survival Tunneling Tile Entities
Browse files Browse the repository at this point in the history
Better Survival:
Tunneling Breaks Tile Entities, whether tunneling breaks tile entities
  • Loading branch information
Charles445 committed Dec 21, 2021
1 parent 148f1ce commit eb90605
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/charles445/rltweaker/RLTweaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
}
}
Expand Down

0 comments on commit eb90605

Please sign in to comment.