mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
Improve invpanel bounds math and clean up its code
This commit is contained in:
1 parent
1bb1a74a7d
commit
bb6b84d255
2 files changed
+21
-3
No files matched your search
@@ -13,6 +13,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -180,4 +181,17 @@ public abstract class BlockEio extends Block {
|
||||
}
|
||||
}
|
||||
|
||||
// Because the vanilla method takes floats...
|
||||
public void setBlockBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public void setBlockBounds(AxisAlignedBB bb) {
|
||||
setBlockBounds(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
|
||||
}
|
||||
}
|
||||
@@ -90,15 +90,19 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return getBoundingBox(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
AxisAlignedBB bb = getBoundingBox(world, x, y, z);
|
||||
setBlockBounds((float) bb.minX - x, (float) bb.minY - y, (float) bb.minZ - z, (float) bb.maxX - x, (float) bb.maxY - y, (float) bb.maxZ - z);
|
||||
AxisAlignedBB bb = getBoundingBox(0, 0, 0, getFacing(world, x, y, z));
|
||||
setBlockBounds(bb);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBoundingBox(IBlockAccess world, int x, int y, int z) {
|
||||
int facing = getFacing(world, x, y, z);
|
||||
return getBoundingBox(x, y, z, facing);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBoundingBox(int x, int y, int z, int facing) {
|
||||
switch (facing) {
|
||||
case 0:
|
||||
return AxisAlignedBB.getBoundingBox(x, y + (1 - BLOCK_SIZE), z, x + 1, y + 1, z + 1);
|
||||
|
||||
Reference in new issue
Block a user