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;
|
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.TileRender;
|
||||||
import calclavia.lib.content.module.prefab.TileInventory;
|
import calclavia.lib.content.module.prefab.TileInventory;
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
import calclavia.lib.network.PacketHandler;
|
import calclavia.lib.network.PacketHandler;
|
||||||
import calclavia.lib.prefab.tile.IRotatable;
|
import calclavia.lib.prefab.tile.IRotatable;
|
||||||
import calclavia.lib.render.RenderItemOverlayUtility;
|
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
|
* @since 18/03/14
|
||||||
|
@ -39,12 +38,14 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
||||||
@Override
|
@Override
|
||||||
public void onAdded ()
|
public void onAdded ()
|
||||||
{
|
{
|
||||||
|
if (!getWorldObj().isRemote)
|
||||||
work();
|
work();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborChanged ()
|
public void onNeighborChanged ()
|
||||||
{
|
{
|
||||||
|
if (!getWorldObj().isRemote)
|
||||||
work();
|
work();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +55,20 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
||||||
{
|
{
|
||||||
ForgeDirection dir = getDirection();
|
ForgeDirection dir = getDirection();
|
||||||
Vector3 check = position().translate(dir);
|
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)
|
if (world().isAirBlock(check.intX(), check.intY(), check.intZ()) && placeStack != null && placeStack.getItem() instanceof ItemBlock)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue