Java 类net.minecraft.entity.passive.AbstractChestHorse 实例源码

项目:CrystalMod    文件:HorseAccessories.java   
public static boolean addEnderChest(AbstractHorse horse){
    if(horse == null || !(horse instanceof AbstractChestHorse) || horse.getGrowingAge() != 0 
|| hasEnderChest(horse)) return false;

    AbstractChestHorse horseChest = (AbstractChestHorse)horse;

    if(horseChest.hasChest()){
        ContainerHorseChest chest = getHorseChest(horse);
        if (!horse.world.isRemote && chest != null)
          {
              for (int i = 0; i < chest.getSizeInventory(); ++i)
              {
                  ItemStack itemstack = chest.getStackInSlot(i);

                  if (!itemstack.isEmpty())
                  {
                      horse.entityDropItem(itemstack, 0.0F);
                  }
              }
          }
    }

    setHasEnderChest(horse, true);
    return true;
  }
项目:Backmemed    文件:GuiScreenHorseInventory.java   
/**
 * Draws the background layer of this container (behind the items).
 */
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.getTextureManager().bindTexture(HORSE_GUI_TEXTURES);
    int i = (this.width - this.xSize) / 2;
    int j = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);

    if (this.horseEntity instanceof AbstractChestHorse)
    {
        AbstractChestHorse abstractchesthorse = (AbstractChestHorse)this.horseEntity;

        if (abstractchesthorse.func_190695_dh())
        {
            this.drawTexturedModalRect(i + 79, j + 17, 0, this.ySize, abstractchesthorse.func_190696_dl() * 18, 54);
        }
    }

    if (this.horseEntity.func_190685_dA())
    {
        this.drawTexturedModalRect(i + 7, j + 35 - 18, 18, this.ySize + 54, 18, 18);
    }

    if (this.horseEntity.func_190677_dK())
    {
        if (this.horseEntity instanceof EntityLlama)
        {
            this.drawTexturedModalRect(i + 7, j + 35, 36, this.ySize + 54, 18, 18);
        }
        else
        {
            this.drawTexturedModalRect(i + 7, j + 35, 0, this.ySize + 54, 18, 18);
        }
    }

    GuiInventory.drawEntityOnScreen(i + 51, j + 60, 17, (float)(i + 51) - this.mousePosx, (float)(j + 75 - 50) - this.mousePosY, this.horseEntity);
}
项目:Backmemed    文件:ModelLlama.java   
/**
 * Sets the models various rotation angles then renders the model.
 */
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    AbstractChestHorse abstractchesthorse = (AbstractChestHorse)entityIn;
    boolean flag = !abstractchesthorse.isChild() && abstractchesthorse.func_190695_dh();
    this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn);

    if (this.isChild)
    {
        float f = 2.0F;
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.0F, this.childYOffset * scale, this.childZOffset * scale);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        float f1 = 0.7F;
        GlStateManager.scale(0.71428573F, 0.64935064F, 0.7936508F);
        GlStateManager.translate(0.0F, 21.0F * scale, 0.22F);
        this.head.render(scale);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        float f2 = 1.1F;
        GlStateManager.scale(0.625F, 0.45454544F, 0.45454544F);
        GlStateManager.translate(0.0F, 33.0F * scale, 0.0F);
        this.body.render(scale);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        GlStateManager.scale(0.45454544F, 0.41322312F, 0.45454544F);
        GlStateManager.translate(0.0F, 33.0F * scale, 0.0F);
        this.leg1.render(scale);
        this.leg2.render(scale);
        this.leg3.render(scale);
        this.leg4.render(scale);
        GlStateManager.popMatrix();
    }
    else
    {
        this.head.render(scale);
        this.body.render(scale);
        this.leg1.render(scale);
        this.leg2.render(scale);
        this.leg3.render(scale);
        this.leg4.render(scale);
    }

    if (flag)
    {
        this.field_191226_i.render(scale);
        this.field_191227_j.render(scale);
    }
}
项目:morecommands    文件:TargetSelector.java   
/**
 * Handles special slots of the horse inventory (Slot 0: Saddle, Slot 1: Armor) and
 * a special slot 99 which must be a chest (sets whether the horse is chested or not)
 * 
 * @param slot the special horse slot (0, 1 or 99)
 * @param horse the horse
 * @param stack the item stack (must be saddle for slot 0, any horse armor for slot 1 and chest for slot 99)
 * @param tag the new nbt tag of the special slot (works only for 0 and 1, e.g. to enchant the armor)
 * @param mergeLists See the "mergeLists" parameter of {@link #nbtMerge(NBTTagCompound, NBTTagCompound, boolean)}
 * @return whether the given data was valid (valid slot, valid item, etc.) and whether the special slots could successfully be handled
 * @throws Exeption if reflective access failed
 */
private static boolean handleHorseSpecialSlots(AbstractHorse horse, int slot, ItemStack stack, NBTTagCompound tag, boolean mergeLists) throws Exception {
    IItemHandler h = horse.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    IItemHandlerModifiable inventory = h instanceof IItemHandlerModifiable ? (IItemHandlerModifiable) h : null;
    if (initChest == null || updateSlots == null || inventory == null) return false;

    if (tag != null) {
        if (slot < inventory.getSlots()) return false;

        if (inventory.getStackInSlot(slot) != ItemStack.EMPTY) {
            stack = inventory.getStackInSlot(slot).copy();
            nbtMerge(stack.getTagCompound(), tag, mergeLists);
            inventory.setStackInSlot(slot, stack);
            updateSlots.invoke(horse);
        }

        return true;
    }

    if (slot == 99 && horse instanceof AbstractChestHorse) {
        if (stack == ItemStack.EMPTY || ((AbstractChestHorse) horse).hasChest()) {
            ((AbstractChestHorse) horse).setChested(false);
            initChest.invoke(horse);
            return true;
        }

        if (stack != ItemStack.EMPTY && stack.getItem() == Item.getItemFromBlock(Blocks.CHEST) && !(horse instanceof AbstractChestHorse)) {
            ((AbstractChestHorse) horse).setChested(true);
            initChest.invoke(horse);
            return true;
        }

        return false;
    }
    else if (slot >= 0 && slot < 2 && slot < inventory.getSlots()) {
        if (slot == 0 && stack != ItemStack.EMPTY && stack.getItem() != Items.SADDLE) return false;
        else if (slot != 1 || (stack == ItemStack.EMPTY || horse.isArmor(stack)) && horse.wearsArmor()) {
            inventory.setStackInSlot(slot, stack == ItemStack.EMPTY ? ItemStack.EMPTY : stack.copy());
            updateSlots.invoke(horse);
            return true;
        }
        else return false;
    }
    else return false;
}
项目:morecommands    文件:CommandOpen.java   
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
    EntityPlayerMP player = getSenderAsEntity(sender.getMinecraftISender(), EntityPlayerMP.class);
    Entity entity = EntityUtils.traceEntity(player, 128D);

    if (params.length == 0 && entity instanceof AbstractChestHorse) {
        ((AbstractChestHorse) entity).openGUI(player);
    }
    else if (params.length == 0 && entity instanceof EntityVillager) {
        player.displayVillagerTradeGui((EntityVillager) entity);
    }
    else if (params.length == 0 && entity instanceof EntityMinecartContainer) {
        player.displayGui((EntityMinecartContainer) entity);
    }
    else {
        if (params.length == 0 || params.length > 2) {
            BlockPos trace; 

            try {trace = params.length > 2 ? getCoordFromParams(sender.getMinecraftISender(), params, 0) : EntityUtils.traceBlock(player, 128D);}
            catch (NumberFormatException nfe) {throw new CommandException("command.open.NAN", sender);}

            if (trace == null)
                throw new CommandException("command.open.noBlock", sender);

            TileEntity te = sender.getWorld().getTileEntity(trace);
            Block block = WorldUtils.getBlock(sender.getWorld(), trace);

            if (te instanceof IInteractionObject)
                player.displayGui((IInteractionObject) te);
            else if (te instanceof IInventory)
                player.displayGUIChest((IInventory) te);
            else if (block == Blocks.ANVIL)
                player.displayGui(new BlockAnvil.Anvil(sender.getWorld(), trace));
            else if (block == Blocks.CRAFTING_TABLE)
                player.displayGui(new BlockWorkbench.InterfaceCraftingTable(sender.getWorld(), trace));
            else 
                throw new CommandException("command.open.invalidBlock", sender);
        }
        else if (params.length > 0) {
            if (params[0].equalsIgnoreCase("enderchest"))
                player.displayGUIChest(player.getInventoryEnderChest());
            else if (params[0].equalsIgnoreCase("enchantment_table") || (params.length > 1 && params[0].equalsIgnoreCase("enchantment") && params[1].equalsIgnoreCase("table"))) {
                final World w = sender.getWorld();

                player.displayGui(new IInteractionObject() {
                    @Override public boolean hasCustomName() {return false;}
                    @Override public String getName() {return "container.enchant";}
                    @Override public ITextComponent getDisplayName() {return new TextComponentTranslation(this.getName());}
                    @Override public String getGuiID() {return "minecraft:enchanting_table";}
                    @Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
                        return new ContainerEnchantment(playerInventory, w, BlockPos.ORIGIN);
                    }
                });
                this.allowedInteractions.put(player, player.openContainer);
            }
            else if (params[0].equalsIgnoreCase("anvil")) {
                player.displayGui(new BlockAnvil.Anvil(sender.getWorld(), BlockPos.ORIGIN)); 
                this.allowedInteractions.put(player, player.openContainer);
            }
            else if (params[0].equalsIgnoreCase("workbench") || params[0].equalsIgnoreCase("crafting_table") || (params.length > 1 && params[0].equalsIgnoreCase("crafting") && params[1].equalsIgnoreCase("table")) ) {
                player.displayGui(new BlockWorkbench.InterfaceCraftingTable(sender.getWorld(), BlockPos.ORIGIN));
                this.allowedInteractions.put(player, player.openContainer);
            }
            else if (params[0].equalsIgnoreCase("furnace") || params[0].equalsIgnoreCase("brewing_stand") || (params.length > 1 && params[0].equalsIgnoreCase("brewing") && params[1].equalsIgnoreCase("stand")))
                throw new CommandException("command.open.cantOpenTEs", sender);
            else
                throw new CommandException("command.open.invalidContainer", sender, params[0]);
        }
        else throw new CommandException("command.generic.invalidUsage", sender, this.getCommandName());
    }

    return null;
}