use of net.minecraftforge.common.ForgeDirection in project MineFactoryReloaded by powercrystals.
the class MFRUtil method directionsWithoutConveyors.
public static ForgeDirection[] directionsWithoutConveyors(World world, int x, int y, int z) {
ArrayList<ForgeDirection> nonConveyors = new ArrayList<ForgeDirection>();
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
BlockPosition bp = new BlockPosition(x, y, z);
bp.orientation = direction;
bp.moveForwards(1);
TileEntity te = world.getBlockTileEntity(bp.x, bp.y, bp.z);
if (te == null || !(te instanceof TileEntityConveyor)) {
nonConveyors.add(direction);
}
}
return nonConveyors.toArray(new ForgeDirection[nonConveyors.size()]);
}
use of net.minecraftforge.common.ForgeDirection in project MineFactoryReloaded by powercrystals.
the class BlockRailCargoPickup method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (world.isRemote || !(entity instanceof EntityMinecartContainer)) {
return;
}
IInventoryManager minecart = InventoryManager.create((EntityMinecartContainer) entity, ForgeDirection.UNKNOWN);
for (Entry<ForgeDirection, IInventory> inventory : UtilInventory.findChests(world, x, y, z).entrySet()) {
IInventoryManager chest = InventoryManager.create(inventory.getValue(), inventory.getKey().getOpposite());
for (Entry<Integer, ItemStack> contents : chest.getContents().entrySet()) {
if (contents.getValue() == null) {
continue;
}
ItemStack stackToAdd = contents.getValue().copy();
ItemStack remaining = minecart.addItem(stackToAdd);
if (remaining != null) {
stackToAdd.stackSize -= remaining.stackSize;
if (stackToAdd.stackSize > 0) {
chest.removeItem(stackToAdd.stackSize, stackToAdd);
}
} else {
chest.removeItem(stackToAdd.stackSize, stackToAdd);
break;
}
}
}
}
use of net.minecraftforge.common.ForgeDirection in project MineFactoryReloaded by powercrystals.
the class BlockRedNetCable method breakBlock.
@Override
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te instanceof TileEntityRedNetCable && ((TileEntityRedNetCable) te).getNetwork() != null) {
((TileEntityRedNetCable) te).getNetwork().setInvalid();
}
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
BlockPosition bp = new BlockPosition(x, y, z);
bp.orientation = d;
bp.moveForwards(1);
world.notifyBlockOfNeighborChange(bp.x, bp.y, bp.z, MineFactoryReloadedCore.rednetCableBlock.blockID);
world.notifyBlocksOfNeighborChange(bp.x, bp.y, bp.z, MineFactoryReloadedCore.rednetCableBlock.blockID);
}
super.breakBlock(world, x, y, z, id, meta);
}
Aggregations