Skip to content

Commit

Permalink
Fix For Block Collision
Browse files Browse the repository at this point in the history
Fixes Accidental Suffocation
Fixes Pillaring Issue

More Work on Fix, Torch placement

Logic Derp

Less use of instanceof
More use of actual methods

Even bigger logic derp

Collision Fix
  • Loading branch information
SamRaven2 committed Apr 30, 2015
1 parent 4f78717 commit 395a774
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions src/main/java/tconstruct/library/tools/HarvestTool.java
Expand Up @@ -5,6 +5,7 @@
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialLogic;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -16,6 +17,7 @@
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.common.ForgeHooks;
Expand All @@ -38,7 +40,7 @@ public HarvestTool(int baseDamage)
@Override
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
{
return super.onBlockStartBreak(stack, x,y,z, player);
return super.onBlockStartBreak(stack, x, y, z, player);
}

@Override
Expand Down Expand Up @@ -167,41 +169,40 @@ public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int
int posX = x;
int posY = y;
int posZ = z;
int playerPosX = (int) Math.floor(player.posX);
int playerPosY = (int) Math.floor(player.posY);
int playerPosZ = (int) Math.floor(player.posZ);
if (side == 0)
{
--posY;
}

if (side == 1)
{
++posY;
}

if (side == 2)
{
--posZ;
}

if (side == 3)
switch (side)
{
++posZ;
case 0:
--posY;
break;
case 1:
++posY;
break;
case 2:
--posZ;
break;
case 3:
++posZ;
break;
case 4:
--posX;
break;
case 5:
++posX;
break;
}

if (side == 4)
{
--posX;
}
AxisAlignedBB blockBounds = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1);
AxisAlignedBB playerBounds = player.boundingBox;

if (side == 5)
{
++posX;
}
if (posX == playerPosX && (posY == playerPosY || posY == playerPosY + 1 || posY == playerPosY - 1) && posZ == playerPosZ)
if(item instanceof ItemBlock)
{
return false;
Block blockToPlace = ((ItemBlock) item).field_150939_a;
if(blockToPlace.getMaterial().blocksMovement())
{
if (playerBounds.intersectsWith(blockBounds))
return false;
}
}

int dmg = nearbyStack.getItemDamage();
Expand Down

0 comments on commit 395a774

Please sign in to comment.