Made the Block Placer function with the chest on its rear
This commit is contained in:
parent
73f13f5712
commit
2917c31ce9
1 changed files with 99 additions and 85 deletions
|
@ -1,28 +1,27 @@
|
|||
package resonantinduction.mechanical.process.edit;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.content.module.TileRender;
|
||||
import calclavia.lib.content.module.prefab.TileInventory;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.render.RenderItemOverlayUtility;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
||||
/**
|
||||
* @since 18/03/14
|
||||
|
@ -30,31 +29,46 @@ import calclavia.lib.render.RenderItemOverlayUtility;
|
|||
*/
|
||||
public class TilePlacer extends TileInventory implements IRotatable, IPacketReceiver
|
||||
{
|
||||
public TilePlacer()
|
||||
public TilePlacer ()
|
||||
{
|
||||
super(Material.iron);
|
||||
normalRender = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
public void onAdded ()
|
||||
{
|
||||
if (!getWorldObj().isRemote)
|
||||
work();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
public void onNeighborChanged ()
|
||||
{
|
||||
if (!getWorldObj().isRemote)
|
||||
work();
|
||||
}
|
||||
|
||||
public void work()
|
||||
public void work ()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
ForgeDirection dir = getDirection();
|
||||
Vector3 check = position().translate(dir);
|
||||
ItemStack placeStack = getStackInSlot(0);
|
||||
ItemStack placeStack = null;
|
||||
if (getStackInSlot(0) == null)
|
||||
{
|
||||
ForgeDirection op = dir.getOpposite();
|
||||
TileEntity tile = getWorldObj().getBlockTileEntity(x() + op.offsetX, y() + op.offsetY, z() + op.offsetZ);
|
||||
|
||||
if (tile instanceof IInventory)
|
||||
{
|
||||
ItemStack candidate = InventoryUtility.takeTopItemFromInventory((IInventory) tile, dir.ordinal());
|
||||
if (candidate != null)
|
||||
this.incrStackSize(0, candidate);
|
||||
}
|
||||
}
|
||||
placeStack = getStackInSlot(0);
|
||||
|
||||
if (world().isAirBlock(check.intX(), check.intY(), check.intZ()) && placeStack != null && placeStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
|
@ -66,7 +80,7 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
|
@ -74,7 +88,7 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
public void onReceivePacket (ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -88,12 +102,12 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected TileRender newRenderer()
|
||||
protected TileRender newRenderer ()
|
||||
{
|
||||
return new TileRender()
|
||||
{
|
||||
@Override
|
||||
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
|
||||
public boolean renderDynamic (Vector3 position, boolean isItem, float frame)
|
||||
{
|
||||
if (!isItem)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue