use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class HackableMobSpawner method isHacked.
public static boolean isHacked(IBlockAccess world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null) {
NBTTagCompound tag = new NBTTagCompound();
te.writeToNBT(tag);
if (tag.hasKey("RequiredPlayerRange") && tag.getShort("RequiredPlayerRange") == 0)
return true;
}
return false;
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class LogisticsManager method getRequestedAmount.
public static int getRequestedAmount(SemiBlockLogistics requester, ItemStack providingStack) {
TileEntity te = requester.getTileEntity();
if (!(te instanceof IInventory))
return 0;
int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.stackSize;
if (requestedAmount == 0)
return 0;
providingStack = providingStack.copy();
providingStack.stackSize = requestedAmount;
ItemStack remainder = providingStack.copy();
remainder.stackSize += requester.getIncomingItems(providingStack);
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
remainder = IOHelper.insert(te, remainder, d, true);
if (remainder == null)
break;
}
if (remainder != null)
providingStack.stackSize -= remainder.stackSize;
if (providingStack.stackSize <= 0)
return 0;
return providingStack.stackSize;
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class LogisticsManager method getRequestedAmount.
public static int getRequestedAmount(SemiBlockLogistics requester, FluidStack providingStack) {
int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.amount;
if (requestedAmount == 0)
return 0;
providingStack = providingStack.copy();
providingStack.amount = requestedAmount;
FluidStack remainder = providingStack.copy();
remainder.amount += requester.getIncomingFluid(remainder.getFluid());
TileEntity te = requester.getTileEntity();
if (te instanceof IFluidHandler) {
IFluidHandler fluidHandler = (IFluidHandler) te;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
int fluidFilled = fluidHandler.fill(d, remainder, false);
if (fluidFilled > 0) {
remainder.amount -= fluidFilled;
break;
}
}
}
providingStack.amount -= remainder.amount;
if (providingStack.amount <= 0)
return 0;
return providingStack.amount;
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class BlockAphorismTile method onBlockPlacedBy.
/**
* Called when the block is placed in the world.
*/
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack iStack) {
super.onBlockPlacedBy(world, x, y, z, entityLiving, iStack);
int meta = world.getBlockMetadata(x, y, z);
if (meta < 2) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityAphorismTile) {
((TileEntityAphorismTile) te).textRotation = (((int) entityLiving.rotationYaw + 45) / 90 + 2) % 4;
}
}
if (world.isRemote && entityLiving instanceof EntityPlayer) {
((EntityPlayer) entityLiving).openGui(PneumaticCraft.instance, EnumGuiId.APHORISM_TILE.ordinal(), world, x, y, z);
}
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class BlockOmnidirectionalHopper method rotateBlock.
@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection face) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityOmnidirectionalHopper) {
TileEntityOmnidirectionalHopper teOh = (TileEntityOmnidirectionalHopper) te;
if (player != null && player.isSneaking()) {
int newMeta = (world.getBlockMetadata(x, y, z) + 1) % 6;
if (newMeta == teOh.getDirection().ordinal())
newMeta = (newMeta + 1) % 6;
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
} else {
int newRotation = (teOh.getDirection().ordinal() + 1) % 6;
if (newRotation == world.getBlockMetadata(x, y, z))
newRotation = (newRotation + 1) % 6;
teOh.setDirection(ForgeDirection.getOrientation(newRotation));
}
return true;
}
return false;
}
Aggregations