net.minecraft.tileentity.TileEntityHopper Java Examples
The following examples show how to use
net.minecraft.tileentity.TileEntityHopper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TileEntityTreeFarm.java From AdvancedMod with GNU General Public License v3.0 | 7 votes |
private void cutTree(){ if(inventory != null) { Block block = worldObj.getBlock(xCoord, yCoord + 2, zCoord); int offsetY = yCoord + 2; while(block.getMaterial() == Material.wood) { List<ItemStack> items = block.getDrops(worldObj, xCoord, offsetY, zCoord, worldObj.getBlockMetadata(xCoord, offsetY, zCoord), 0); for(ItemStack item : items) { ItemStack remainder = TileEntityHopper.func_145889_a(inventory, item, 0); if(remainder != null) { worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord + 0.5, yCoord + 2.5, zCoord + 0.5, remainder)); } } worldObj.setBlock(xCoord, offsetY, zCoord, Blocks.air); offsetY++; block = worldObj.getBlock(xCoord, offsetY, zCoord); } } }
Example #2
Source File: BlockElevatorBase.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block){ super.onNeighborBlockChange(world, x, y, z, block); TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityElevatorBase) { TileEntityElevatorBase thisTe = (TileEntityElevatorBase)te; if(thisTe.isCoreElevator()) { TileEntityElevatorBase teAbove = getCoreTileEntity(world, x, y, z); if(teAbove != null && teAbove != thisTe) { for(int i = 0; i < thisTe.getSizeInventory(); i++) { ItemStack item = thisTe.getStackInSlot(i); if(item != null) { ItemStack leftover = TileEntityHopper.func_145889_a(teAbove, item, 0); thisTe.setInventorySlotContents(i, null); if(leftover != null) { EntityItem entity = new EntityItem(world, teAbove.xCoord + 0.5, teAbove.yCoord + 1.5, teAbove.zCoord + 0.5, leftover); world.spawnEntityInWorld(entity); } } } } } } }
Example #3
Source File: MCUtil.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Nullable public static TileEntityHopper getHopper(World world, BlockPos pos) { Chunk chunk = world.getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4); if (chunk != null && chunk.getBlockState(pos).getBlock() == Blocks.HOPPER) { TileEntity tileEntity = chunk.getTileEntity(pos, Chunk.EnumCreateEntityType.IMMEDIATE); if (tileEntity instanceof TileEntityHopper) { return (TileEntityHopper) tileEntity; } } return null; }
Example #4
Source File: StorageESPMod.java From ForgeHax with MIT License | 5 votes |
private int getTileEntityColor(TileEntity tileEntity) { if (tileEntity instanceof TileEntityChest || tileEntity instanceof TileEntityDispenser || tileEntity instanceof TileEntityShulkerBox) { return Colors.ORANGE.toBuffer(); } else if (tileEntity instanceof TileEntityEnderChest) { return Colors.PURPLE.toBuffer(); } else if (tileEntity instanceof TileEntityFurnace) { return Colors.GRAY.toBuffer(); } else if (tileEntity instanceof TileEntityHopper) { return Colors.DARK_RED.toBuffer(); } else { return -1; } }
Example #5
Source File: CapabilityMinecartDestination.java From Signals with GNU General Public License v3.0 | 5 votes |
/** * * @param cart * @return true if there was a valid hopper (not necessarily if extracted an item) */ private boolean extractFuelFromHopper(EntityMinecart cart, BlockPos pos){ boolean foundHopper = false; for(EnumFacing dir : EnumFacing.VALUES) { BlockPos neighbor = pos; for(int offsetTimes = 0; offsetTimes < (dir == EnumFacing.UP ? 2 : 1); offsetTimes++) { neighbor = neighbor.offset(dir); TileEntity te = cart.world.getTileEntity(neighbor); if(te instanceof TileEntityHopper) { EnumFacing hopperDir = cart.world.getBlockState(neighbor).getValue(BlockHopper.FACING); if(hopperDir.getOpposite() == dir) { TileEntityHopper hopper = (TileEntityHopper)te; for(int i = 0; i < hopper.getSizeInventory(); i++) { ItemStack stack = hopper.getStackInSlot(i); if(!stack.isEmpty() && getFuelInv().isItemValidForSlot(0, stack)) { ItemStack inserted = stack.copy(); inserted.setCount(1); ItemStack left = ItemHandlerHelper.insertItemStacked(getEngineItemHandler(), inserted, false); if(left.isEmpty()) { stack.shrink(1); hopper.markDirty(); return true; } } } foundHopper = true; } } } } return foundHopper; }
Example #6
Source File: PneumaticCraftUtils.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static ItemStack exportStackToInventory(TileEntity te, ItemStack stack, ForgeDirection side){ if(te instanceof IInventory) { return TileEntityHopper.func_145889_a((IInventory)te, stack, side.ordinal()); } else { stack = ModInteractionUtils.getInstance().exportStackToTEPipe(te, stack, side); stack = ModInteractionUtils.getInstance().exportStackToBCPipe(te, stack, side); return stack; } }
Example #7
Source File: CraftHopper.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftHopper(final Block block) { super(block, TileEntityHopper.class); }
Example #8
Source File: CraftHopper.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftHopper(final Material material, final TileEntityHopper te) { super(material, te); }
Example #9
Source File: CraftHopper.java From Thermos with GNU General Public License v3.0 | 4 votes |
public CraftHopper(final Block block) { super(block); hopper = (TileEntityHopper) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ()); }
Example #10
Source File: PneumaticCraftUtils.java From PneumaticCraft with GNU General Public License v3.0 | 2 votes |
/** * Transfers the given stack to the given inventory. The returned stack is the leftover if there is any. * @param inv * @param stack * @return */ public static ItemStack exportStackToInventory(IInventory inv, ItemStack stack, ForgeDirection side){ return TileEntityHopper.func_145889_a(inv, stack, side.ordinal()); }