use of powercrystals.minefactoryreloaded.tile.base.TileEntityFactory in project MineFactoryReloaded by powercrystals.
the class BlockFactoryMachine method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entity, ItemStack stack) {
if (entity == null) {
return;
}
TileEntity te = world.getBlockTileEntity(x, y, z);
if (stack.getTagCompound() != null) {
stack.getTagCompound().setInteger("x", x);
stack.getTagCompound().setInteger("y", y);
stack.getTagCompound().setInteger("z", z);
te.readFromNBT(stack.getTagCompound());
}
if (te instanceof TileEntityFactory && ((TileEntityFactory) te).canRotate()) {
int facing = MathHelper.floor_double((entity.rotationYaw * 4F) / 360F + 0.5D) & 3;
if (facing == 0) {
((TileEntityFactory) te).rotateDirectlyTo(3);
} else if (facing == 1) {
((TileEntityFactory) te).rotateDirectlyTo(4);
} else if (facing == 2) {
((TileEntityFactory) te).rotateDirectlyTo(2);
} else if (facing == 3) {
((TileEntityFactory) te).rotateDirectlyTo(5);
}
if (te instanceof TileEntityFactoryInventory) {
if (stack.hasDisplayName()) {
((TileEntityFactoryInventory) te).setInvName(stack.getDisplayName());
}
}
}
}
use of powercrystals.minefactoryreloaded.tile.base.TileEntityFactory in project MineFactoryReloaded by powercrystals.
the class BlockRedNetPanel method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entity, ItemStack stack) {
if (entity == null) {
return;
}
TileEntity te = world.getBlockTileEntity(x, y, z);
if (stack.getTagCompound() != null) {
stack.getTagCompound().setInteger("x", x);
stack.getTagCompound().setInteger("y", y);
stack.getTagCompound().setInteger("z", z);
te.readFromNBT(stack.getTagCompound());
}
if (te instanceof TileEntityFactory && ((TileEntityFactory) te).canRotate()) {
int facing = MathHelper.floor_double((entity.rotationYaw * 4F) / 360F + 0.5D) & 3;
if (facing == 0) {
((TileEntityFactory) te).rotateDirectlyTo(3);
} else if (facing == 1) {
((TileEntityFactory) te).rotateDirectlyTo(4);
} else if (facing == 2) {
((TileEntityFactory) te).rotateDirectlyTo(2);
} else if (facing == 3) {
((TileEntityFactory) te).rotateDirectlyTo(5);
}
}
}
Aggregations