mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-17 03:05:10 +00:00
Fix reamining present issues:
- Fix dupes - Fix bounding boxes - Fix inventory order being swapped in the GUI - Fix in-world chiseling not working - Fix losing items when metadata changes
This commit is contained in:
1 parent
385c692e1b
commit
ffc4ca9308
5 files changed
+119
-35
No files matched your search
@@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -76,13 +77,13 @@ public class BlockPresent extends Block implements ICarvable {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
world.setBlockMetadataWithNotify(x, y, z, heading, 3);
|
||||
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3);
|
||||
te.setRotation(heading);
|
||||
te.findConnections();
|
||||
if (te.isConnected()) {
|
||||
TileEntityPresent other = te.getConnection();
|
||||
world.setBlockMetadataWithNotify(other.xCoord, other.yCoord, other.zCoord, heading, 3);
|
||||
other.setRotation(heading);
|
||||
}
|
||||
te.setType(stack.getItemDamage());
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
@@ -92,8 +93,8 @@ public class BlockPresent extends Block implements ICarvable {
|
||||
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
|
||||
if (tileEntityPresent != null) {
|
||||
for (int c = 0; c < tileEntityPresent.getSizeInventory(); c++) {
|
||||
ItemStack itemStack = tileEntityPresent.getStackInSlot(c);
|
||||
for (int c = 0; c < tileEntityPresent.getTrueSizeInventory(); c++) {
|
||||
ItemStack itemStack = tileEntityPresent.getTrueStackInSlot(c);
|
||||
|
||||
if (itemStack != null) {
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
@@ -127,12 +128,14 @@ public class BlockPresent extends Block implements ICarvable {
|
||||
|
||||
public AxisAlignedBB getBoundingBox(TileEntityPresent me) {
|
||||
if (me == null) {
|
||||
System.out.println(-1);
|
||||
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
int x = me.xCoord, y = me.yCoord, z = me.zCoord;
|
||||
if (me.isConnected()) {
|
||||
ForgeDirection dir = me.getConnectionDir();
|
||||
if (dir != ForgeDirection.NORTH && (!me.isParent() || dir == ForgeDirection.SOUTH)) {
|
||||
// warning: magic below! Do not change this conditional
|
||||
if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH) || (!me.isParent() && dir == ForgeDirection.SOUTH)) {
|
||||
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX + dir.offsetX, y + maxY, z + maxZ + dir.offsetZ);
|
||||
} else {
|
||||
return AxisAlignedBB.getBoundingBox(x + dir.offsetX + minX, y + minY, z + dir.offsetZ + minZ, x + maxX, y + maxY, z + maxZ);
|
||||
@@ -191,6 +194,16 @@ public class BlockPresent extends Block implements ICarvable {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -200,8 +213,7 @@ public class BlockPresent extends Block implements ICarvable {
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
return te instanceof TileEntityPresent ? carverHelper.getVariation(((TileEntityPresent) te).getType()) : carverHelper.getVariation(metadata);
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user