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:
Christian Knaapen
2019-01-11 03:01:04 +01:00
parent f3ad36e6a6
commit d07751a01f
6 changed files with 33 additions and 10 deletions

View File

@@ -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. //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
version = "1.0" version = "1.0.1"
group = "nl.requios.effortlessbuilding" // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = "nl.requios.effortlessbuilding" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "effortlessbuilding" archivesBaseName = "effortlessbuilding"

View File

@@ -101,18 +101,27 @@ public class BuildModifiers {
} }
public static void onBlockBroken(BlockEvent.BreakEvent event) { 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()); BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(event.getPlayer());
//Only use own break event if anything is enabled //Only use own break event if anything is enabled
if (isEnabled(buildSettings, event.getPos())) { if (isEnabled(buildSettings, pos)) {
//get coordinates //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 //break all those blocks
for (BlockPos coordinate : coordinates) { for (BlockPos coordinate : coordinates) {
if (event.getWorld().isBlockLoaded(coordinate, false)) { if (world.isBlockLoaded(coordinate, false)) {
SurvivalHelper.breakBlock(event.getWorld(), event.getPlayer(), coordinate); if (!onlyInstaBreaking || world.getBlockState(coordinate).getBlockHardness(world, coordinate) == 0f) {
SurvivalHelper.breakBlock(world, event.getPlayer(), coordinate);
}
} }
} }
} }

View File

@@ -104,6 +104,7 @@ public class BuildSettingsManager {
public BuildSettings() { public BuildSettings() {
mirrorSettings = new Mirror.MirrorSettings(); mirrorSettings = new Mirror.MirrorSettings();
arraySettings = new Array.ArraySettings(); arraySettings = new Array.ArraySettings();
radialMirrorSettings = new RadialMirror.RadialMirrorSettings();
} }
public BuildSettings(Mirror.MirrorSettings mirrorSettings, Array.ArraySettings arraySettings, public BuildSettings(Mirror.MirrorSettings mirrorSettings, Array.ArraySettings arraySettings,
@@ -116,26 +117,32 @@ public class BuildSettingsManager {
} }
public Mirror.MirrorSettings getMirrorSettings() { public Mirror.MirrorSettings getMirrorSettings() {
return mirrorSettings; if (this.mirrorSettings == null) this.mirrorSettings = new Mirror.MirrorSettings();
return this.mirrorSettings;
} }
public void setMirrorSettings(Mirror.MirrorSettings mirrorSettings) { public void setMirrorSettings(Mirror.MirrorSettings mirrorSettings) {
if (mirrorSettings == null) return;
this.mirrorSettings = mirrorSettings; this.mirrorSettings = mirrorSettings;
} }
public Array.ArraySettings getArraySettings() { public Array.ArraySettings getArraySettings() {
return arraySettings; if (this.arraySettings == null) this.arraySettings = new Array.ArraySettings();
return this.arraySettings;
} }
public void setArraySettings(Array.ArraySettings arraySettings) { public void setArraySettings(Array.ArraySettings arraySettings) {
if (arraySettings == null) return;
this.arraySettings = arraySettings; this.arraySettings = arraySettings;
} }
public RadialMirror.RadialMirrorSettings getRadialMirrorSettings() { public RadialMirror.RadialMirrorSettings getRadialMirrorSettings() {
return radialMirrorSettings; if (this.radialMirrorSettings == null) this.radialMirrorSettings = new RadialMirror.RadialMirrorSettings();
return this.radialMirrorSettings;
} }
public void setRadialMirrorSettings(RadialMirror.RadialMirrorSettings radialMirrorSettings) { public void setRadialMirrorSettings(RadialMirror.RadialMirrorSettings radialMirrorSettings) {
if (radialMirrorSettings == null) return;
this.radialMirrorSettings = radialMirrorSettings; this.radialMirrorSettings = radialMirrorSettings;
} }

View File

@@ -36,7 +36,7 @@ public class EffortlessBuilding
{ {
public static final String MODID = "effortlessbuilding"; public static final String MODID = "effortlessbuilding";
public static final String NAME = "Effortless Building"; 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) @Mod.Instance(EffortlessBuilding.MODID)
public static EffortlessBuilding instance; public static EffortlessBuilding instance;

View File

@@ -88,6 +88,7 @@ public class EventHandler
//EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed())); //EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
float originalBlockHardness = event.getState().getBlockHardness(world, pos); float originalBlockHardness = event.getState().getBlockHardness(world, pos);
if (originalBlockHardness < 0) return; //Dont break bedrock
float totalBlockHardness = 0; float totalBlockHardness = 0;
//get coordinates //get coordinates
List<BlockPos> coordinates = BuildModifiers.findCoordinates(player, pos); List<BlockPos> coordinates = BuildModifiers.findCoordinates(player, pos);

View File

@@ -123,6 +123,12 @@ public class SurvivalHelper {
{ {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
state = state.getBlock().getActualState(state, world, pos); state = state.getBlock().getActualState(state, world, pos);
//Dont break bedrock
if (state.getBlockHardness((World) world, pos) < 0) {
return false;
}
if (state.getMaterial().isToolNotRequired()) if (state.getMaterial().isToolNotRequired())
{ {
return true; return true;