Search in sources :

Example 6 with TileEntityFactory

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());
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFactory(powercrystals.minefactoryreloaded.tile.base.TileEntityFactory) TileEntityFactoryInventory(powercrystals.minefactoryreloaded.tile.base.TileEntityFactoryInventory)

Example 7 with TileEntityFactory

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);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFactory(powercrystals.minefactoryreloaded.tile.base.TileEntityFactory)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)7 TileEntityFactory (powercrystals.minefactoryreloaded.tile.base.TileEntityFactory)7 PlayerInteractEvent (net.minecraftforge.event.entity.player.PlayerInteractEvent)2 TileEntityRedNetHistorian (powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetHistorian)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 ITankContainerBucketable (powercrystals.minefactoryreloaded.core.ITankContainerBucketable)1 TileEntityFactoryInventory (powercrystals.minefactoryreloaded.tile.base.TileEntityFactoryInventory)1 TileEntityConveyor (powercrystals.minefactoryreloaded.tile.conveyor.TileEntityConveyor)1 TileEntityAutoJukebox (powercrystals.minefactoryreloaded.tile.machine.TileEntityAutoJukebox)1 TileEntityRedNetCable (powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable)1 TileEntityRedNetLogic (powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetLogic)1