Search in sources :

Example 1 with TileEntity

use of net.minecraft.tileentity.TileEntity in project BetterStorage by copygirl.

the class ClientProxy method drawBlockHighlight.

@SubscribeEvent
public void drawBlockHighlight(DrawBlockHighlightEvent event) {
    EntityPlayer player = event.player;
    World world = player.worldObj;
    MovingObjectPosition target = WorldUtils.rayTrace(player, event.partialTicks);
    if ((target == null) || (target.typeOfHit != MovingObjectType.BLOCK))
        return;
    int x = target.blockX;
    int y = target.blockY;
    int z = target.blockZ;
    AxisAlignedBB box = null;
    Block block = world.getBlock(x, y, z);
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (block instanceof TileArmorStand)
        box = getArmorStandHighlightBox(player, world, x, y, z, target.hitVec);
    else if (block == Blocks.iron_door)
        box = getIronDoorHightlightBox(player, world, x, y, z, target.hitVec, block);
    else if (tileEntity instanceof IHasAttachments)
        box = getAttachmentPointsHighlightBox(player, tileEntity, target);
    if (box == null)
        return;
    double xOff = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.partialTicks;
    double yOff = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.partialTicks;
    double zOff = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks;
    box.offset(-xOff, -yOff, -zOff);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
    GL11.glLineWidth(2.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(false);
    RenderGlobal.drawOutlinedBoundingBox(box, -1);
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    event.setCanceled(true);
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) TileArmorStand(net.mcft.copy.betterstorage.tile.stand.TileArmorStand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) World(net.minecraft.world.World) IHasAttachments(net.mcft.copy.betterstorage.attachment.IHasAttachments) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with TileEntity

use of net.minecraft.tileentity.TileEntity in project BluePower by Qmunity.

the class BlockContainerBase method getIcon.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    if (textures == null)
        return super.getIcon(world, x, y, z, side);
    TileEntity te = get(world, x, y, z);
    RendererBlockBase.EnumFaceType faceType = EnumFaceType.SIDE;
    boolean powered = false;
    boolean ejecting = false;
    if (te instanceof IRotatable) {
        ForgeDirection rotation = ((IRotatable) te).getFacingDirection();
        if (rotation.ordinal() == side)
            faceType = EnumFaceType.FRONT;
        if (rotation.getOpposite().ordinal() == side)
            faceType = EnumFaceType.BACK;
    }
    if (te instanceof IBluePowered) {
        powered = ((IBluePowered) te).isPowered();
    }
    if (te instanceof IEjectAnimator) {
        ejecting = ((IEjectAnimator) te).isEjecting();
    }
    return getIcon(faceType, ejecting, powered, side, te);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFaceType(com.bluepowermod.client.render.RendererBlockBase.EnumFaceType) IBluePowered(com.bluepowermod.tile.IBluePowered) IRotatable(com.bluepowermod.tile.IRotatable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IEjectAnimator(com.bluepowermod.tile.IEjectAnimator) RendererBlockBase(com.bluepowermod.client.render.RendererBlockBase) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with TileEntity

use of net.minecraft.tileentity.TileEntity in project BluePower by Qmunity.

the class BlockContainerBase method onBlockPlacedBy.

/**
     * Method to detect how the block was placed, and what way it's facing.
     */
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack iStack) {
    BPApi.getInstance().loadSilkySettings(world, x, y, z, iStack);
    TileEntity te = get(world, x, y, z);
    if (te instanceof IRotatable) {
        ((IRotatable) te).setFacingDirection(ForgeDirectionUtils.getDirectionFacing(player, canRotateVertical()).getOpposite());
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IRotatable(com.bluepowermod.tile.IRotatable)

Example 4 with TileEntity

use of net.minecraft.tileentity.TileEntity in project BluePower by Qmunity.

the class BlockIgniter method rotateBlock.

@Override
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
    TileEntity te = worldObj.getTileEntity(x, y, z);
    if (te instanceof IRotatable) {
        IRotatable rotatable = (IRotatable) te;
        ForgeDirection dir = rotatable.getFacingDirection();
        Block target = worldObj.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
        if (target == Blocks.fire || target == Blocks.portal) {
            worldObj.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, Blocks.air);
        }
        dir = dir.getRotation(axis);
        if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN || canRotateVertical()) {
            rotatable.setFacingDirection(dir);
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IRotatable(com.bluepowermod.tile.IRotatable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block)

Example 5 with TileEntity

use of net.minecraft.tileentity.TileEntity in project BluePower by Qmunity.

the class MessageSyncMachineBacklog method handleClientSide.

@Override
public void handleClientSide(EntityPlayer player) {
    TileEntity te = player.worldObj.getTileEntity(x, y, z);
    if (te instanceof TileMachineBase) {
        ((TileMachineBase) te).setBacklog(stacks);
        GuiContainerBase gui = (GuiContainerBase) ClientProxy.getOpenedGui();
        if (gui != null)
            gui.redraw();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GuiContainerBase(uk.co.qmunity.lib.client.gui.GuiContainerBase) TileMachineBase(com.bluepowermod.tile.TileMachineBase)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)822 ItemStack (net.minecraft.item.ItemStack)149 BlockPos (net.minecraft.util.math.BlockPos)130 Block (net.minecraft.block.Block)83 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)76 EnumFacing (net.minecraft.util.EnumFacing)62 ArrayList (java.util.ArrayList)61 IBlockState (net.minecraft.block.state.IBlockState)61 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 IInventory (net.minecraft.inventory.IInventory)49 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)44 World (net.minecraft.world.World)43 EntityItem (net.minecraft.entity.item.EntityItem)39 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)35 FluidStack (net.minecraftforge.fluids.FluidStack)29 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 HashMap (java.util.HashMap)25 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)23 AMVector3 (am2.api.math.AMVector3)21 Entity (net.minecraft.entity.Entity)21