Skip to content

Commit

Permalink
Galacticraft Crash Fix
Browse files Browse the repository at this point in the history
Fix's a crash bug with Galacticraft blockstate when using Omni Tool.
  • Loading branch information
infiniteblock committed Feb 2, 2022
1 parent 83a06f9 commit 6fc1236
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
MatterOverdrive - Changelog
===========================

0.7.5b2 (2022-01-29 21:01:19 +1300)
-----------------------------------
Unreleased
----------
* OmniTool (infiniteblock)

0.7.5Release (2022-01-29 21:01:19 +1300)
----------------------------------------
* Update CHANGELOG.md (infiniteblock)
* Update RenderHandler.java (infiniteblock)
* Fixes (infiniteblock)
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/matteroverdrive/items/weapon/OmniTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,21 @@ public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {

if (hit != null && hit.typeOfHit == RayTraceResult.Type.BLOCK) {
IBlockState state = player.world.getBlockState(hit.getBlockPos());
final float hardness = state.getPlayerRelativeBlockHardness((EntityPlayer) player, player.world, hit.getBlockPos());
boolean canMine = state.getBlock().canHarvestBlock(player.world, hit.getBlockPos(), (EntityPlayer) player);
if (!state.getBlock().isAir(state, player.world, hit.getBlockPos()) && canMine) {
++STEP_SOUND_COUNTER;
LAST_SIDE = hit.sideHit;
if (isSameBlock(hit.getBlockPos())) {
if (BLOCK_DAMAGE >= 1.0F) {
//this.isHittingBlock = false;
MatterOverdrive.NETWORK.sendToServer(new PacketDigBlock(hit.getBlockPos(), PacketDigBlock.Type.HARVEST, hit.sideHit));
Minecraft.getMinecraft().playerController.onPlayerDestroyBlock(hit.getBlockPos());
BLOCK_DAMAGE = 0.0F;
STEP_SOUND_COUNTER = 0.0F;
//this.blockHitDelay = 5;
} else if (BLOCK_DAMAGE == 0) {
MatterOverdrive.NETWORK.sendToServer(new PacketDigBlock(hit.getBlockPos(), PacketDigBlock.Type.CLICK, hit.sideHit));
}

BLOCK_DAMAGE = MathHelper.clamp(modifyStatFromModules(WeaponStats.BLOCK_DAMAGE, stack, (BLOCK_DAMAGE + state.getPlayerRelativeBlockHardness((EntityPlayer) player, player.world, hit.getBlockPos()))*2), 0, 1);
BLOCK_DAMAGE = MathHelper.clamp(modifyStatFromModules(WeaponStats.BLOCK_DAMAGE, stack, (BLOCK_DAMAGE + hardness)*2), 0, 1);
player.world.sendBlockBreakProgress(player.getEntityId(), hit.getBlockPos(), (int) (BLOCK_DAMAGE * 10));
} else {
stopMiningLastBlock((EntityPlayer) player, player.world);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,11 @@ protected void onAdded(MachineEvent.Added event) {
}

protected void onUnload(MachineEvent.Unload event) {
if (!getNodeWorld().isRemote) {
if (!getNodeWorld().isRemote) {
IBlockState blockState = getNodeWorld().getBlockState(getNodePos());
if (matterNetwork != null) {
matterNetwork.onNodeDestroy(blockState, rootClient);
}
}
}
}

}
}

0 comments on commit 6fc1236

Please sign in to comment.