mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-13 00:47:31 +00:00
Add drawer controller block
This commit is contained in:
1 parent
328630fc9c
commit
68c2abecdb
18 files changed
+931
-25
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.7.10-1.2.4"
|
||||
version = "1.7.10-1.3.0-alpha2"
|
||||
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "StorageDrawers"
|
||||
|
||||
|
||||
@@ -46,9 +46,11 @@ tile.halfDrawers4.acacia.name=Compact Acacia Drawers 2x2
|
||||
tile.halfDrawers4.big_oak.name=Compact Dark Oak Drawers 2x2
|
||||
|
||||
tile.compDrawers.name=Compacting Drawer
|
||||
tile.drawerController.name=Drawer Controller
|
||||
|
||||
storageDrawers.drawers.description=Holds %d stacks per drawer
|
||||
storageDrawers.upgrade.description=Increases storage to %d times base value
|
||||
storageDrawers.controller.description=Interact with a bank of connected drawers
|
||||
|
||||
# Integration
|
||||
storageDrawers.waila.empty=Empty
|
||||
@@ -70,6 +72,7 @@ storageDrawers.config.blocks.fullDrawers4=Drawers 2x2
|
||||
storageDrawers.config.blocks.halfDrawers2=Compact Drawers 1x2
|
||||
storageDrawers.config.blocks.halfDrawers4=Compact Drawers 2x2
|
||||
storageDrawers.config.blocks.compDrawers=Compacting Drawer
|
||||
storageDrawers.config.blocks.controller=Drawer Controller
|
||||
|
||||
storageDrawers.config.upgrades=Upgrade Settings
|
||||
storageDrawers.config.upgrades.tooltip=Configure individual storage upgrades.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 575 B |
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.inventory;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDrawerInventory extends ISidedInventory
|
||||
{
|
||||
@@ -25,4 +26,8 @@ public interface IDrawerInventory extends ISidedInventory
|
||||
* @param inventorySlot An IInventory slot index returned from getInventorySlot.
|
||||
*/
|
||||
SlotType getInventorySlotType (int inventorySlot);
|
||||
|
||||
boolean canInsertItem (int slot, ItemStack stack);
|
||||
|
||||
boolean canExtractItem (int slot, ItemStack stack);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.storage;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
|
||||
public interface IDrawerGroup
|
||||
{
|
||||
/**
|
||||
@@ -16,4 +18,6 @@ public interface IDrawerGroup
|
||||
* Gets whether the drawer in the given slot is usable.
|
||||
*/
|
||||
boolean isDrawerEnabled (int slot);
|
||||
|
||||
IDrawerInventory getDrawerInventory ();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.storage;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDrawerGroupInteractive extends IDrawerGroup
|
||||
{
|
||||
ItemStack takeItemsFromSlot (int slot, int count);
|
||||
|
||||
int putItemsIntoSlot (int slot, ItemStack stack, int count);
|
||||
|
||||
int interactPutCurrentItemIntoSlot (int slot, EntityPlayer player);
|
||||
|
||||
int interactPutCurrentInventoryIntoSlot (int slot, EntityPlayer player);
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockController extends BlockContainer
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconFront;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconSide;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconSideEtched;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTrim;
|
||||
|
||||
public BlockController (String blockName) {
|
||||
super(Material.rock);
|
||||
|
||||
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
|
||||
setHardness(5f);
|
||||
setBlockName(blockName);
|
||||
setStepSound(Block.soundTypeStone);
|
||||
setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock () {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube () {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType () {
|
||||
return StorageDrawers.proxy.controllerRenderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickRate (World world) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
|
||||
TileEntityController tile = getTileEntitySafe(world, x, y, z);
|
||||
if (tile.getDirection() > 1)
|
||||
return;
|
||||
|
||||
int quadrant = MathHelper.floor_double((entity.rotationYaw * 4f / 360f) + .5) & 3;
|
||||
switch (quadrant) {
|
||||
case 0:
|
||||
tile.setDirection(2);
|
||||
break;
|
||||
case 1:
|
||||
tile.setDirection(5);
|
||||
break;
|
||||
case 2:
|
||||
tile.setDirection(3);
|
||||
break;
|
||||
case 3:
|
||||
tile.setDirection(4);
|
||||
break;
|
||||
}
|
||||
|
||||
if (world.isRemote) {
|
||||
tile.invalidate();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
TileEntityController te = getTileEntitySafe(world, x, y, z);
|
||||
if (te.getDirection() != side)
|
||||
return false;
|
||||
|
||||
if (!world.isRemote)
|
||||
te.interactPutItemsIntoInventory(player);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
if (side.ordinal() != getTileEntity(world, x, y, z).getDirection())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick (World world, int x, int y, int z, Random rand) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
TileEntityController te = getTileEntity(world, x, y, z);
|
||||
if (te == null)
|
||||
return;
|
||||
|
||||
te.updateCache();
|
||||
|
||||
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta) {
|
||||
switch (side) {
|
||||
case 0:
|
||||
case 1:
|
||||
return iconSide;
|
||||
case 4:
|
||||
return iconFront;
|
||||
default:
|
||||
return iconSideEtched;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
|
||||
TileEntityController tile = getTileEntity(blockAccess, x, y, z);
|
||||
if (tile == null)
|
||||
return iconFront;
|
||||
|
||||
if (side == tile.getDirection())
|
||||
return iconFront;
|
||||
|
||||
switch (side) {
|
||||
case 0:
|
||||
case 1:
|
||||
return iconSide;
|
||||
default:
|
||||
return iconSideEtched;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconTrim (int meta) {
|
||||
return iconTrim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntityController createNewTileEntity (World world, int meta) {
|
||||
return new TileEntityController();
|
||||
}
|
||||
|
||||
public TileEntityController getTileEntity (IBlockAccess blockAccess, int x, int y, int z) {
|
||||
TileEntity tile = blockAccess.getTileEntity(x, y, z);
|
||||
return (tile instanceof TileEntityController) ? (TileEntityController) tile : null;
|
||||
}
|
||||
|
||||
public TileEntityController getTileEntitySafe (World world, int x, int y, int z) {
|
||||
TileEntityController tile = getTileEntity(world, x, y, z);
|
||||
if (tile == null) {
|
||||
tile = createNewTileEntity(world, world.getBlockMetadata(x, y, z));
|
||||
world.setTileEntity(x, y, z, tile);
|
||||
}
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister register) {
|
||||
iconFront = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_controller_front");
|
||||
iconSide = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_side");
|
||||
iconSideEtched = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_side_2");
|
||||
iconTrim = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_trim");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,454 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroupInteractive;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TileEntityController extends TileEntity implements IDrawerGroup, ISidedInventory
|
||||
{
|
||||
private static final int DEPTH_LIMIT = 12;
|
||||
private static final int[] emptySlots = new int[0];
|
||||
|
||||
private static class BlockCoord {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public BlockCoord (int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object obj) {
|
||||
if (obj == null || obj.getClass() != getClass())
|
||||
return false;
|
||||
|
||||
BlockCoord that = (BlockCoord)obj;
|
||||
return x == that.x && y == that.y && z == that.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode () {
|
||||
int hash = 23;
|
||||
hash = hash * 31 + x;
|
||||
hash = hash * 31 + y;
|
||||
hash = hash * 31 + z;
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<BlockCoord, IDrawerGroup> storage = new HashMap<BlockCoord, IDrawerGroup>();
|
||||
private Map<BlockCoord, Boolean> mark = new HashMap<BlockCoord, Boolean>();
|
||||
private Map<BlockCoord, Integer> invStorageSize = new HashMap<BlockCoord, Integer>();
|
||||
private Map<BlockCoord, Integer> drawerStorageSize = new HashMap<BlockCoord, Integer>();
|
||||
private List<BlockCoord> invBlockList = new ArrayList<BlockCoord>();
|
||||
private List<Integer> invSlotList = new ArrayList<Integer>();
|
||||
private List<BlockCoord> drawerBlockList = new ArrayList<BlockCoord>();
|
||||
private List<Integer> drawerSlotList = new ArrayList<Integer>();
|
||||
|
||||
private int[] inventorySlots = new int[0];
|
||||
private int[] autoSides = new int[] { 0, 1 };
|
||||
private int direction;
|
||||
|
||||
private int inventorySize = 0;
|
||||
private int drawerSize = 0;
|
||||
|
||||
private long lastClickTime;
|
||||
private UUID lastClickUUID;
|
||||
|
||||
public int getDirection () {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection (int direction) {
|
||||
this.direction = direction % 6;
|
||||
|
||||
autoSides = new int[] { 0, 1, ForgeDirection.OPPOSITES[direction], 2, 3 };
|
||||
|
||||
if (direction == 2 || direction == 3) {
|
||||
autoSides[3] = 4;
|
||||
autoSides[4] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public int interactPutItemsIntoInventory (EntityPlayer player) {
|
||||
if (inventorySize == 0)
|
||||
updateCache();
|
||||
|
||||
boolean dumpInventory = worldObj.getTotalWorldTime() - lastClickTime < 10 && player.getPersistentID().equals(lastClickUUID);
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0, n = drawerSlotList.size(); i < n; i++) {
|
||||
IDrawerGroup group = getDrawerBlockForGroup(i);
|
||||
if (group == null || !(group instanceof IDrawerGroupInteractive))
|
||||
continue;
|
||||
|
||||
IDrawerGroupInteractive intGroup = (IDrawerGroupInteractive)group;
|
||||
|
||||
int slot = getDrawerSlotForGroup(i);
|
||||
if (!group.isDrawerEnabled(slot))
|
||||
continue;
|
||||
|
||||
IDrawer drawer = group.getDrawer(slot);
|
||||
if (drawer == null || drawer.isEmpty())
|
||||
continue;
|
||||
|
||||
if (dumpInventory)
|
||||
count += intGroup.interactPutCurrentInventoryIntoSlot(slot, player);
|
||||
else
|
||||
count += intGroup.interactPutCurrentItemIntoSlot(slot, player);
|
||||
}
|
||||
|
||||
lastClickTime = worldObj.getTotalWorldTime();
|
||||
lastClickUUID = player.getPersistentID();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private void resetCache () {
|
||||
storage.clear();
|
||||
invStorageSize.clear();
|
||||
drawerStorageSize.clear();
|
||||
invBlockList.clear();
|
||||
invSlotList.clear();
|
||||
drawerBlockList.clear();
|
||||
drawerSlotList.clear();
|
||||
inventorySize = 0;
|
||||
drawerSize = 0;
|
||||
}
|
||||
|
||||
//private void buildCache () {
|
||||
// populateNode(xCoord, yCoord, zCoord, 0);
|
||||
//}
|
||||
|
||||
private void rebuildCache () {
|
||||
resetCache();
|
||||
updateCache();
|
||||
}
|
||||
|
||||
public void updateCache () {
|
||||
mark.clear();
|
||||
populateNode(xCoord, yCoord, zCoord, 0);
|
||||
|
||||
for (BlockCoord coord : storage.keySet()) {
|
||||
if (!mark.containsKey(coord)) {
|
||||
storage.put(coord, null);
|
||||
|
||||
for (int i = 0, n = invBlockList.size(); i < n; i++) {
|
||||
if (coord.equals(invBlockList.get(i)))
|
||||
invBlockList.set(i, null);
|
||||
}
|
||||
|
||||
for (int i = 0, n = drawerBlockList.size(); i < n; i++) {
|
||||
if (coord.equals(drawerBlockList.get(i)))
|
||||
drawerBlockList.set(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int validSlotCount = 0;
|
||||
for (int i = 0, n = invBlockList.size(); i < n; i++) {
|
||||
if (invBlockList.get(i) != null)
|
||||
validSlotCount++;
|
||||
}
|
||||
|
||||
inventorySlots = new int[validSlotCount];
|
||||
for (int i = 0, j = 0, n = invBlockList.size(); i < n; i++) {
|
||||
if (invBlockList.get(i) != null)
|
||||
inventorySlots[j++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
private void populateNode (int x, int y, int z, int depth) {
|
||||
TileEntity te = worldObj.getTileEntity(x, y, z);
|
||||
if (te == null || !(te instanceof IDrawerGroup))
|
||||
return;
|
||||
|
||||
if (te instanceof TileEntityController) {
|
||||
populateNeighborNodes(x, y, z, depth + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
IDrawerGroup group = (IDrawerGroup)te;
|
||||
IDrawerInventory inventory = group.getDrawerInventory();
|
||||
if (inventory == null)
|
||||
return;
|
||||
|
||||
BlockCoord coord = new BlockCoord(x, y, z);
|
||||
if (storage.containsKey(coord)) {
|
||||
if (storage.get(coord) != null) {
|
||||
if (!mark.containsKey(coord)) {
|
||||
mark.put(coord, true);
|
||||
populateNeighborNodes(x, y, z, depth + 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
storage.put(coord, group);
|
||||
mark.put(coord, true);
|
||||
|
||||
invStorageSize.put(coord, inventory.getSizeInventory());
|
||||
drawerStorageSize.put(coord, group.getDrawerCount());
|
||||
|
||||
for (int i = 0, n = invStorageSize.get(coord); i < n; i++) {
|
||||
invBlockList.add(coord);
|
||||
invSlotList.add(i);
|
||||
}
|
||||
|
||||
for (int i = 0, n = drawerStorageSize.get(coord); i < n; i++) {
|
||||
drawerBlockList.add(coord);
|
||||
drawerSlotList.add(i);
|
||||
}
|
||||
|
||||
inventorySize += invStorageSize.get(coord);
|
||||
drawerSize += drawerStorageSize.get(coord);
|
||||
|
||||
if (depth == DEPTH_LIMIT)
|
||||
return;
|
||||
|
||||
populateNeighborNodes(x, y, z, depth + 1);
|
||||
}
|
||||
|
||||
private void populateNeighborNodes (int x, int y, int z, int depth) {
|
||||
populateNode(x - 1, y, z, depth);
|
||||
populateNode(x + 1, y, z, depth);
|
||||
populateNode(x, y - 1, z, depth);
|
||||
populateNode(x, y + 1, z, depth);
|
||||
populateNode(x, y, z - 1, depth);
|
||||
populateNode(x, y, z + 1, depth);
|
||||
}
|
||||
|
||||
private IDrawerGroup getDrawerBlockForInv (int slot) {
|
||||
if (slot >= invBlockList.size())
|
||||
return null;
|
||||
|
||||
BlockCoord coord = invBlockList.get(slot);
|
||||
if (coord == null)
|
||||
return null;
|
||||
|
||||
if (!storage.containsKey(coord))
|
||||
return null;
|
||||
|
||||
return storage.get(coord);
|
||||
}
|
||||
|
||||
private IDrawerGroup getDrawerBlockForGroup (int slot) {
|
||||
if (slot >= drawerBlockList.size())
|
||||
return null;
|
||||
|
||||
BlockCoord coord = drawerBlockList.get(slot);
|
||||
if (coord == null)
|
||||
return null;
|
||||
|
||||
if (!storage.containsKey(coord))
|
||||
return null;
|
||||
|
||||
return storage.get(coord);
|
||||
}
|
||||
|
||||
private int getDrawerSlotForInv (int slot) {
|
||||
if (slot >= invSlotList.size())
|
||||
return 0;
|
||||
|
||||
return invSlotList.get(slot);
|
||||
}
|
||||
|
||||
private int getDrawerSlotForGroup (int slot) {
|
||||
if (slot >= drawerSlotList.size())
|
||||
return 0;
|
||||
|
||||
return drawerSlotList.get(slot);
|
||||
}
|
||||
|
||||
private IDrawerInventory getDrawerInventory (int slot) {
|
||||
IDrawerGroup group = getDrawerBlockForInv(slot);
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
return group.getDrawerInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
setDirection(tag.getByte("Dir"));
|
||||
|
||||
if (worldObj != null && !worldObj.isRemote)
|
||||
rebuildCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
|
||||
tag.setByte("Dir", (byte)direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket () {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 5, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawerInventory getDrawerInventory () {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrawerCount () {
|
||||
if (inventorySize == 0)
|
||||
updateCache();
|
||||
|
||||
return drawerSlotList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawer getDrawer (int slot) {
|
||||
IDrawerGroup group = getDrawerBlockForGroup(slot);
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
return group.getDrawer(getDrawerSlotForGroup(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDrawerEnabled (int slot) {
|
||||
IDrawerGroup group = getDrawerBlockForGroup(slot);
|
||||
if (group == null)
|
||||
return false;
|
||||
|
||||
return group.isDrawerEnabled(getDrawerSlotForGroup(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side) {
|
||||
for (int aside : autoSides) {
|
||||
if (side == aside)
|
||||
return inventorySlots;
|
||||
}
|
||||
|
||||
return emptySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack stack, int side) {
|
||||
IDrawerInventory inventory = getDrawerInventory(slot);
|
||||
if (inventory == null)
|
||||
return false;
|
||||
|
||||
return inventory.canInsertItem(getDrawerSlotForInv(slot), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack stack, int side) {
|
||||
IDrawerInventory inventory = getDrawerInventory(slot);
|
||||
if (inventory == null)
|
||||
return false;
|
||||
|
||||
return inventory.canExtractItem(getDrawerSlotForInv(slot), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory () {
|
||||
return inventorySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot) {
|
||||
IDrawerInventory inventory = getDrawerInventory(slot);
|
||||
if (inventory == null)
|
||||
return null;
|
||||
|
||||
return inventory.getStackInSlot(getDrawerSlotForInv(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int count) {
|
||||
IDrawerInventory inventory = getDrawerInventory(slot);
|
||||
if (inventory == null)
|
||||
return null;
|
||||
|
||||
return inventory.decrStackSize(getDrawerSlotForInv(slot), count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int slot) {
|
||||
IDrawerInventory inventory = getDrawerInventory(slot);
|
||||
if (inventory == null)
|
||||
return null;
|
||||
|
||||
return inventory.getStackInSlotOnClosing(getDrawerSlotForInv(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack stack) {
|
||||
IDrawerInventory inventory = getDrawerInventory(slot);
|
||||
if (inventory == null)
|
||||
return;
|
||||
|
||||
inventory.setInventorySlotContents(getDrawerSlotForInv(slot), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName () {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit () {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory () { }
|
||||
|
||||
@Override
|
||||
public void closeInventory () { }
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int slot, ItemStack stack) {
|
||||
IDrawerInventory inventory = getDrawerInventory(slot);
|
||||
if (inventory == null)
|
||||
return false;
|
||||
|
||||
return inventory.isItemValidForSlot(getDrawerSlotForInv(slot), stack);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroupInteractive;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.ISideManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.StorageInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
|
||||
@@ -27,7 +28,7 @@ import org.apache.logging.log4j.Level;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class TileEntityDrawers extends TileEntity implements IDrawerGroup, ISidedInventory
|
||||
public abstract class TileEntityDrawers extends TileEntity implements IDrawerGroupInteractive, ISidedInventory
|
||||
{
|
||||
private IDrawer[] drawers;
|
||||
private IDrawerInventory inventory;
|
||||
@@ -171,14 +172,19 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
return countAdded;
|
||||
}
|
||||
|
||||
public int interactPutItemsIntoSlot (int slot, EntityPlayer player) {
|
||||
int count = 0;
|
||||
|
||||
public int interactPutCurrentItemIntoSlot (int slot, EntityPlayer player) {
|
||||
ItemStack currentStack = player.inventory.getCurrentItem();
|
||||
if (currentStack != null)
|
||||
count += putItemsIntoSlot(slot, currentStack, currentStack.stackSize);
|
||||
return putItemsIntoSlot(slot, currentStack, currentStack.stackSize);
|
||||
|
||||
if (!drawers[slot].isEmpty() && worldObj.getTotalWorldTime() - lastClickTime < 10 && player.getPersistentID().equals(lastClickUUID)) {
|
||||
markDirty();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int interactPutCurrentInventoryIntoSlot (int slot, EntityPlayer player) {
|
||||
int count = 0;
|
||||
|
||||
if (!drawers[slot].isEmpty()) {
|
||||
for (int i = 0, n = player.inventory.getSizeInventory(); i < n; i++) {
|
||||
ItemStack subStack = player.inventory.getStackInSlot(i);
|
||||
if (subStack != null) {
|
||||
@@ -191,11 +197,20 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
}
|
||||
}
|
||||
|
||||
markDirty();
|
||||
return count;
|
||||
}
|
||||
|
||||
public int interactPutItemsIntoSlot (int slot, EntityPlayer player) {
|
||||
int count = 0;
|
||||
if (worldObj.getTotalWorldTime() - lastClickTime < 10 && player.getPersistentID().equals(lastClickUUID))
|
||||
count = interactPutCurrentInventoryIntoSlot(slot, player);
|
||||
else
|
||||
count = interactPutCurrentItemIntoSlot(slot, player);
|
||||
|
||||
lastClickTime = worldObj.getTotalWorldTime();
|
||||
lastClickUUID = player.getPersistentID();
|
||||
|
||||
markDirty();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -337,6 +352,11 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
return drawers[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawerInventory getDrawerInventory () {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDrawerEnabled (int slot) {
|
||||
return getDrawer(slot) != null;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IIngredientHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.renderer;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockController;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.CommonProxy;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ControllerRenderer implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
private static final double unit = .0625f;
|
||||
private ModularBoxRenderer boxRenderer = new ModularBoxRenderer();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
if (!(block instanceof BlockController))
|
||||
return;
|
||||
|
||||
renderInventoryBlock((BlockController) block, metadata, modelId, renderer);
|
||||
}
|
||||
|
||||
private void renderInventoryBlock (BlockController block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
int side = 4;
|
||||
|
||||
boxRenderer.setUnit(unit);
|
||||
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
for (int i = 0; i < 6; i++)
|
||||
boxRenderer.setIcon(block.getIcon(i, metadata), i);
|
||||
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
GL11.glTranslatef(-.5f, -.5f, -.5f);
|
||||
|
||||
renderExterior(block, 0, 0, 0,side, renderer);
|
||||
|
||||
boxRenderer.setUnit(0);
|
||||
boxRenderer.setInteriorIcon(block.getIcon(side, metadata), ForgeDirection.OPPOSITES[side]);
|
||||
|
||||
renderInterior(block, 0, 0, 0, side, renderer);
|
||||
|
||||
GL11.glTranslatef(.5f, .5f, .5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
if (!(block instanceof BlockController))
|
||||
return false;
|
||||
|
||||
return renderWorldBlock(world, x, y, z, (BlockController) block, modelId, renderer);
|
||||
}
|
||||
|
||||
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockController block, int modelId, RenderBlocks renderer) {
|
||||
TileEntityController tile = block.getTileEntity(world, x, y, z);
|
||||
if (tile == null)
|
||||
return false;
|
||||
|
||||
int side = tile.getDirection();
|
||||
|
||||
boxRenderer.setUnit(unit);
|
||||
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
|
||||
for (int i = 0; i < 6; i++)
|
||||
boxRenderer.setExteriorIcon(block.getIcon(world, x, y, z, i), i);
|
||||
|
||||
boxRenderer.setCutIcon(block.getIconTrim(0));
|
||||
boxRenderer.setInteriorIcon(block.getIconTrim(0));
|
||||
|
||||
renderExterior(block, x, y, z, side, renderer);
|
||||
|
||||
boxRenderer.setUnit(0);
|
||||
boxRenderer.setInteriorIcon(block.getIcon(world, x, y, z, side), ForgeDirection.OPPOSITES[side]);
|
||||
|
||||
renderInterior(block, x, y, z, side, renderer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void renderExterior (BlockController block, int x, int y, int z, int side, RenderBlocks renderer) {
|
||||
double depth = 1;
|
||||
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
|
||||
|
||||
switch (side) {
|
||||
case 2:
|
||||
xMin = 0; xMax = 1;
|
||||
zMin = 1 - depth; zMax = 1;
|
||||
break;
|
||||
case 3:
|
||||
xMin = 0; xMax = 1;
|
||||
zMin = 0; zMax = depth;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 1 - depth; xMax = 1;
|
||||
zMin = 0; zMax = 1;
|
||||
break;
|
||||
case 5:
|
||||
xMin = 0; xMax = depth;
|
||||
zMin = 0; zMax = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
boxRenderer.renderExterior(renderer, block, x, y, z, xMin, 0, zMin, xMax, 1, zMax, 0, ModularBoxRenderer.sideCut[side]);
|
||||
}
|
||||
|
||||
private void renderInterior (BlockController block, int x, int y, int z, int side, RenderBlocks renderer) {
|
||||
double unit = .0625;
|
||||
double depth = 1;
|
||||
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
|
||||
|
||||
switch (side) {
|
||||
case 2:
|
||||
xMin = unit; xMax = 1 - unit;
|
||||
zMin = 1 - depth; zMax = 1 - depth + unit;
|
||||
break;
|
||||
case 3:
|
||||
xMin = unit; xMax = 1 - unit;
|
||||
zMin = depth - unit; zMax = depth;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 1 - depth; xMax = 1 - depth + unit;
|
||||
zMin = unit; zMax = 1 - unit;
|
||||
break;
|
||||
case 5:
|
||||
xMin = depth - unit; xMax = depth;
|
||||
zMin = unit; zMax = 1 - unit;
|
||||
break;
|
||||
}
|
||||
|
||||
boxRenderer.renderInterior(renderer, block, x, y, z, xMin, unit, zMin, xMax, 1 - unit, zMax, 0, ModularBoxRenderer.sideCut[side]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory (int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId () {
|
||||
return StorageDrawers.proxy.controllerRenderID;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.jaquadro.minecraft.storagedrawers.core;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersComp;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandard;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.renderer.ControllerRenderer;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.renderer.DrawersRenderer;
|
||||
import com.jaquadro.minecraft.storagedrawers.client.renderer.TileEntityDrawersRenderer;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
@@ -12,8 +13,10 @@ public class ClientProxy extends CommonProxy
|
||||
@Override
|
||||
public void registerRenderers () {
|
||||
drawersRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
controllerRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
RenderingRegistry.registerBlockHandler(drawersRenderID, new DrawersRenderer());
|
||||
RenderingRegistry.registerBlockHandler(controllerRenderID, new ControllerRenderer());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrawersStandard.class, new TileEntityDrawersRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrawersComp.class, new TileEntityDrawersRenderer());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jaquadro.minecraft.storagedrawers.core;
|
||||
public class CommonProxy
|
||||
{
|
||||
public int drawersRenderID = -1;
|
||||
public int controllerRenderID = -1;
|
||||
|
||||
public void registerRenderers ()
|
||||
{ }
|
||||
|
||||
@@ -2,11 +2,14 @@ package com.jaquadro.minecraft.storagedrawers.core;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockCompDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockController;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersComp;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandard;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCompDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemController;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemDrawers;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -19,6 +22,7 @@ public class ModBlocks
|
||||
public static BlockDrawers halfDrawers2;
|
||||
public static BlockDrawers halfDrawers4;
|
||||
public static BlockCompDrawers compDrawers;
|
||||
public static BlockController controller;
|
||||
|
||||
public void init () {
|
||||
fullDrawers2 = new BlockDrawers("fullDrawers2", 2, false);
|
||||
@@ -26,6 +30,7 @@ public class ModBlocks
|
||||
halfDrawers2 = new BlockDrawers("halfDrawers2", 2, true);
|
||||
halfDrawers4 = new BlockDrawers("halfDrawers4", 4, true);
|
||||
compDrawers = new BlockCompDrawers("compDrawers");
|
||||
controller = new BlockController("drawerController");
|
||||
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
|
||||
@@ -45,11 +50,14 @@ public class ModBlocks
|
||||
GameRegistry.registerBlock(halfDrawers4, ItemDrawers.class, "halfDrawers4");
|
||||
GameRegistry.registerTileEntity(TileEntityDrawersStandard.class, ModBlocks.getQualifiedName(halfDrawers4));
|
||||
}
|
||||
|
||||
if (config.isBlockEnabled("compdrawers")) {
|
||||
GameRegistry.registerBlock(compDrawers, ItemCompDrawers.class, "compDrawers");
|
||||
GameRegistry.registerTileEntity(TileEntityDrawersComp.class, ModBlocks.getQualifiedName(compDrawers));
|
||||
}
|
||||
//if (config.isBlockEnabled("controller")) {
|
||||
GameRegistry.registerBlock(controller, ItemController.class, "controller");
|
||||
GameRegistry.registerTileEntity(TileEntityController.class, ModBlocks.getQualifiedName(controller));
|
||||
//}
|
||||
}
|
||||
|
||||
public static String getQualifiedName (Block block) {
|
||||
|
||||
@@ -34,6 +34,9 @@ public class ModRecipes
|
||||
GameRegistry.addRecipe(new ItemStack(ModBlocks.compDrawers, config.getBlockRecipeOutput("compdrawers")), "xxx", "zwz", "xyx",
|
||||
'x', new ItemStack(Blocks.stone), 'y', Items.iron_ingot, 'z', new ItemStack(Blocks.piston), 'w', new ItemStack(ModBlocks.fullDrawers2, 1, OreDictionary.WILDCARD_VALUE));
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(ModBlocks.controller), "xxx", "yzy", "xwx",
|
||||
'x', new ItemStack(Blocks.stone), 'y', Items.comparator, 'z', new ItemStack(ModBlocks.fullDrawers2, 1, OreDictionary.WILDCARD_VALUE), 'w', Items.diamond);
|
||||
|
||||
if (config.isBlockEnabled("fulldrawers2"))
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx",
|
||||
'x', Items.stick, 'y', new ItemStack(ModBlocks.fullDrawers2, 1, OreDictionary.WILDCARD_VALUE));
|
||||
|
||||
@@ -43,18 +43,7 @@ public class StorageInventory implements IDrawerInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side) {
|
||||
int[] autoSides = sideMan.getSlotsForSide(side);
|
||||
for (int aside : autoSides) {
|
||||
if (side == aside)
|
||||
return inventorySlots;
|
||||
}
|
||||
|
||||
return emptySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack item, int side) {
|
||||
public boolean canInsertItem (int slot, ItemStack stack) {
|
||||
if (!StorageDrawers.config.cache.enableSidedInput)
|
||||
return false;
|
||||
|
||||
@@ -71,11 +60,11 @@ public class StorageInventory implements IDrawerInventory
|
||||
if (drawer == null)
|
||||
return false;
|
||||
|
||||
return drawer.canItemBeStored(item);
|
||||
return drawer.canItemBeStored(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack item, int side) {
|
||||
public boolean canExtractItem (int slot, ItemStack stack) {
|
||||
if (!StorageDrawers.config.cache.enableSidedOutput)
|
||||
return false;
|
||||
|
||||
@@ -95,7 +84,28 @@ public class StorageInventory implements IDrawerInventory
|
||||
if (drawer.getStoredItemCount() == 0)
|
||||
return false;
|
||||
|
||||
return drawer.canItemBeExtracted(item);
|
||||
return drawer.canItemBeExtracted(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side) {
|
||||
int[] autoSides = sideMan.getSlotsForSide(side);
|
||||
for (int aside : autoSides) {
|
||||
if (side == aside)
|
||||
return inventorySlots;
|
||||
}
|
||||
|
||||
return emptySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack item, int side) {
|
||||
return canInsertItem(slot, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack item, int side) {
|
||||
return canExtractItem(slot, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemController extends ItemBlock
|
||||
{
|
||||
public ItemController (Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
TileEntityController tile = (TileEntityController) world.getTileEntity(x, y, z);
|
||||
if (tile != null) {
|
||||
if (side > 1)
|
||||
tile.setDirection(side);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add(StatCollector.translateToLocalFormatted("storageDrawers.controller.description"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user