mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 05:02:25 +00:00
allow placing the inventory panels on all sides
This commit is contained in:
1 parent
26cbc4edee
commit
2dd9090220
2 files changed
+55
No files matched your search
@@ -7,13 +7,17 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.ClientProxy;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel> {
|
||||
|
||||
@@ -36,6 +40,13 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
super(ModObject.blockInventoryPanel, TileInventoryPanel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
GameRegistry.registerBlock(this, BlockItemInventoryPanel.class, modObject.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(teClass, modObject.unlocalisedName + "TileEntity");
|
||||
EnderIO.guiHandler.registerGuiHandler(getGuiId(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return 0;
|
||||
@@ -72,6 +83,12 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
int facing = getFacing(world, x, y, z);
|
||||
switch (facing) {
|
||||
case 0:
|
||||
setBlockBounds(0.0f, 1.0f - BLOCK_SIZE, 0.0f, 1.0f, 1.0f, 1.0f);
|
||||
break;
|
||||
case 1:
|
||||
setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, BLOCK_SIZE, 1.0f);
|
||||
break;
|
||||
case 2:
|
||||
setBlockBounds(0.0f, 0.0f, 1.0f - BLOCK_SIZE, 1.0f, 1.0f, 1.0f);
|
||||
break;
|
||||
@@ -98,6 +115,11 @@ public class BlockInventoryPanel extends AbstractMachineBlock<TileInventoryPanel
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
// this is handled by BlockItemInventoryPanel.placeBlockAt
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package crazypants.enderio.machine.invpanel;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockItemInventoryPanel extends ItemBlock {
|
||||
|
||||
public BlockItemInventoryPanel(Block b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
|
||||
if(!super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) {
|
||||
return false;
|
||||
}
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileInventoryPanel) {
|
||||
TileInventoryPanel teInvPanel = (TileInventoryPanel) te;
|
||||
teInvPanel.setFacing((short) side);
|
||||
teInvPanel.readFromItemStack(stack);
|
||||
if(!world.isRemote) {
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user