Fixed issue #8 Craft when activating the menu.
Fixed being able to mine bedrock. Whoops. Fixed grass and flowers instabreaking other blocks.
This commit is contained in:
@@ -101,18 +101,27 @@ public class BuildModifiers {
|
||||
}
|
||||
|
||||
public static void onBlockBroken(BlockEvent.BreakEvent event) {
|
||||
if (event.getWorld().isRemote) return;
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
|
||||
if (world.isRemote) return;
|
||||
|
||||
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(event.getPlayer());
|
||||
//Only use own break event if anything is enabled
|
||||
if (isEnabled(buildSettings, event.getPos())) {
|
||||
if (isEnabled(buildSettings, pos)) {
|
||||
//get coordinates
|
||||
List<BlockPos> coordinates = findCoordinates(event.getPlayer(), event.getPos());
|
||||
List<BlockPos> coordinates = findCoordinates(event.getPlayer(), pos);
|
||||
|
||||
//If the player is going to instabreak grass or a plant, only break other instabreaking things
|
||||
boolean onlyInstaBreaking = world.getBlockState(pos).getBlockHardness(
|
||||
world, pos) == 0f;
|
||||
|
||||
//break all those blocks
|
||||
for (BlockPos coordinate : coordinates) {
|
||||
if (event.getWorld().isBlockLoaded(coordinate, false)) {
|
||||
SurvivalHelper.breakBlock(event.getWorld(), event.getPlayer(), coordinate);
|
||||
if (world.isBlockLoaded(coordinate, false)) {
|
||||
if (!onlyInstaBreaking || world.getBlockState(coordinate).getBlockHardness(world, coordinate) == 0f) {
|
||||
SurvivalHelper.breakBlock(world, event.getPlayer(), coordinate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ public class BuildSettingsManager {
|
||||
public BuildSettings() {
|
||||
mirrorSettings = new Mirror.MirrorSettings();
|
||||
arraySettings = new Array.ArraySettings();
|
||||
radialMirrorSettings = new RadialMirror.RadialMirrorSettings();
|
||||
}
|
||||
|
||||
public BuildSettings(Mirror.MirrorSettings mirrorSettings, Array.ArraySettings arraySettings,
|
||||
@@ -116,26 +117,32 @@ public class BuildSettingsManager {
|
||||
}
|
||||
|
||||
public Mirror.MirrorSettings getMirrorSettings() {
|
||||
return mirrorSettings;
|
||||
if (this.mirrorSettings == null) this.mirrorSettings = new Mirror.MirrorSettings();
|
||||
return this.mirrorSettings;
|
||||
}
|
||||
|
||||
public void setMirrorSettings(Mirror.MirrorSettings mirrorSettings) {
|
||||
if (mirrorSettings == null) return;
|
||||
this.mirrorSettings = mirrorSettings;
|
||||
}
|
||||
|
||||
public Array.ArraySettings getArraySettings() {
|
||||
return arraySettings;
|
||||
if (this.arraySettings == null) this.arraySettings = new Array.ArraySettings();
|
||||
return this.arraySettings;
|
||||
}
|
||||
|
||||
public void setArraySettings(Array.ArraySettings arraySettings) {
|
||||
if (arraySettings == null) return;
|
||||
this.arraySettings = arraySettings;
|
||||
}
|
||||
|
||||
public RadialMirror.RadialMirrorSettings getRadialMirrorSettings() {
|
||||
return radialMirrorSettings;
|
||||
if (this.radialMirrorSettings == null) this.radialMirrorSettings = new RadialMirror.RadialMirrorSettings();
|
||||
return this.radialMirrorSettings;
|
||||
}
|
||||
|
||||
public void setRadialMirrorSettings(RadialMirror.RadialMirrorSettings radialMirrorSettings) {
|
||||
if (radialMirrorSettings == null) return;
|
||||
this.radialMirrorSettings = radialMirrorSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class EffortlessBuilding
|
||||
{
|
||||
public static final String MODID = "effortlessbuilding";
|
||||
public static final String NAME = "Effortless Building";
|
||||
public static final String VERSION = "1.0";
|
||||
public static final String VERSION = "1.0.1";
|
||||
|
||||
@Mod.Instance(EffortlessBuilding.MODID)
|
||||
public static EffortlessBuilding instance;
|
||||
|
||||
@@ -88,6 +88,7 @@ public class EventHandler
|
||||
//EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
||||
|
||||
float originalBlockHardness = event.getState().getBlockHardness(world, pos);
|
||||
if (originalBlockHardness < 0) return; //Dont break bedrock
|
||||
float totalBlockHardness = 0;
|
||||
//get coordinates
|
||||
List<BlockPos> coordinates = BuildModifiers.findCoordinates(player, pos);
|
||||
|
||||
@@ -123,6 +123,12 @@ public class SurvivalHelper {
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
state = state.getBlock().getActualState(state, world, pos);
|
||||
|
||||
//Dont break bedrock
|
||||
if (state.getBlockHardness((World) world, pos) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (state.getMaterial().isToolNotRequired())
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user