Search in sources :

Example 1 with ItemSkull

use of net.minecraft.item.ItemSkull in project BuildCraft by BuildCraft.

the class EntityRobot method interact.

@Override
protected boolean interact(EntityPlayer player) {
    ItemStack stack = player.getCurrentEquippedItem();
    if (stack == null || stack.getItem() == null) {
        return false;
    }
    RobotEvent.Interact robotInteractEvent = new RobotEvent.Interact(this, player, stack);
    MinecraftForge.EVENT_BUS.post(robotInteractEvent);
    if (robotInteractEvent.isCanceled()) {
        return false;
    }
    if (player.isSneaking() && stack.getItem() instanceof IToolWrench) {
        RobotEvent.Dismantle robotDismantleEvent = new RobotEvent.Dismantle(this, player);
        MinecraftForge.EVENT_BUS.post(robotDismantleEvent);
        if (robotDismantleEvent.isCanceled()) {
            return false;
        }
        onRobotHit(false);
        if (worldObj.isRemote) {
            ((IToolWrench) stack.getItem()).wrenchUsed(player, this);
        }
        return true;
    } else if (wearables.size() < MAX_WEARABLES && stack.getItem().isValidArmor(stack, 0, this)) {
        if (!worldObj.isRemote) {
            wearables.add(stack.splitStack(1));
            syncWearablesToClient();
        } else {
            player.swingItem();
        }
        return true;
    } else if (wearables.size() < MAX_WEARABLES && stack.getItem() instanceof IRobotOverlayItem && ((IRobotOverlayItem) stack.getItem()).isValidRobotOverlay(stack)) {
        if (!worldObj.isRemote) {
            wearables.add(stack.splitStack(1));
            syncWearablesToClient();
        } else {
            player.swingItem();
        }
        return true;
    } else if (wearables.size() < MAX_WEARABLES && stack.getItem() instanceof ItemSkull) {
        if (!worldObj.isRemote) {
            ItemStack skullStack = stack.splitStack(1);
            initSkullItem(skullStack);
            wearables.add(skullStack);
            syncWearablesToClient();
        } else {
            player.swingItem();
        }
        return true;
    } else {
        return super.interact(player);
    }
}
Also used : IToolWrench(buildcraft.api.tools.IToolWrench) IRobotOverlayItem(buildcraft.api.robots.IRobotOverlayItem) ItemStack(net.minecraft.item.ItemStack) RobotEvent(buildcraft.api.events.RobotEvent) ItemSkull(net.minecraft.item.ItemSkull)

Example 2 with ItemSkull

use of net.minecraft.item.ItemSkull in project Tropicraft by Tropicraft.

the class RenderBambooItemFrame method renderItem.

private void renderItem(EntityBambooItemFrame itemFrame) {
    ItemStack itemstack = itemFrame.getDisplayedItem();
    if (!itemstack.isEmpty()) {
        EntityItem entityitem = new EntityItem(itemFrame.world, 0.0D, 0.0D, 0.0D, itemstack);
        Item item = entityitem.getItem().getItem();
        entityitem.getItem().setCount(1);
        entityitem.hoverStart = 0.0F;
        GlStateManager.pushMatrix();
        GlStateManager.disableLighting();
        int i = itemFrame.getRotation();
        if (item instanceof net.minecraft.item.ItemMap) {
            i = i % 4 * 2;
        }
        GlStateManager.rotate((float) i * 360.0F / 8.0F, 0.0F, 0.0F, 1.0F);
        if (item instanceof net.minecraft.item.ItemMap) {
            this.renderManager.renderEngine.bindTexture(MAP_BACKGROUND_TEXTURES);
            GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
            float f = 0.0078125F;
            GlStateManager.scale(f, f, f);
            GlStateManager.translate(-64.0F, -64.0F, 0.0F);
            MapData mapdata = Items.FILLED_MAP.getMapData(entityitem.getItem(), itemFrame.world);
            GlStateManager.translate(0.0F, 0.0F, -1.0F);
            if (mapdata != null) {
                this.mc.entityRenderer.getMapItemRenderer().renderMap(mapdata, true);
            }
        } else {
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
            if (!this.itemRenderer.shouldRenderItemIn3D(entityitem.getItem()) || item instanceof ItemSkull) {
                GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            }
            GlStateManager.pushAttrib();
            RenderHelper.enableStandardItemLighting();
            this.itemRenderer.renderItem(entityitem.getItem(), ItemCameraTransforms.TransformType.FIXED);
            RenderHelper.disableStandardItemLighting();
            GlStateManager.popAttrib();
        }
        GlStateManager.enableLighting();
        GlStateManager.popMatrix();
    }
}
Also used : EntityItem(net.minecraft.entity.item.EntityItem) Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.RenderItem) MapData(net.minecraft.world.storage.MapData) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) ItemSkull(net.minecraft.item.ItemSkull)

Aggregations

ItemSkull (net.minecraft.item.ItemSkull)2 ItemStack (net.minecraft.item.ItemStack)2 RobotEvent (buildcraft.api.events.RobotEvent)1 IRobotOverlayItem (buildcraft.api.robots.IRobotOverlayItem)1 IToolWrench (buildcraft.api.tools.IToolWrench)1 RenderItem (net.minecraft.client.renderer.RenderItem)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Item (net.minecraft.item.Item)1 MapData (net.minecraft.world.storage.MapData)1