Java 类net.minecraft.inventory.ContainerEnchantment 实例源码

项目:EnchantmentRevealer    文件:GuiEnchantmentWrapper.java   
public GuiEnchantmentWrapper(
        InventoryPlayer inventory, World worldIn, EnchantmentWorker worker, BlockPos pos) {
    super(inventory, worldIn, inventory);
    try {
        ContainerEnchantment containerWrapper =
                new ContainerEnchantmentWrapper(inventory, worldIn, worker, pos);
        inventorySlots = containerWrapper;
        containerField.set(this, containerWrapper);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    for (int i = 0; i < 3; ++i) {
        tooltipText[i] = new ArrayList<String>();
    }
    this.worker = worker;
    this.inventory = inventory;
}
项目:EnchantView    文件:EnchantView.java   
/**
 * This is the main event ticker. It only ticks when the player has an open container so we can rule out other ticks.
 * The player usually has an open container (the inventory) but we can simple check for that and return.
 * This also ticks once per player rather than once per World or once per MinecraftServer, so it provides an extra layer of convenience.
 */
@SubscribeEvent
public void playerHasContainerOpen(PlayerOpenContainerEvent event){
    UUID uuid = event.getEntityPlayer().getUniqueID();
    // If the inventory is not a crafting inventory then clear stuff.
    if (!(event.getEntityPlayer().openContainer instanceof ContainerEnchantment)){
        purgeUUID(uuid);
        return;
    }
    ContainerEnchantment container = (ContainerEnchantment)event.getEntityPlayer().openContainer;

    if (!tickTimes.containsKey(uuid)){
        tickTimes.put(uuid, 0L);
    }
    // We set it to zero and immediately increment it so waiting a second
    // is guaranteed. This is simpler than just setting it to one.
    tickTimes.put(uuid, tickTimes.get(uuid) + 1L);

    // We have to check for OnCraftMatrixChanged manually.
    TableState state = new TableState(container);
    if (!prevTableStates.containsKey(uuid) || !prevTableStates.get(uuid).equals(state)){
        prevTableStates.put(uuid, state);
        tableUpdated(event.getEntityPlayer());
    }

    // 20 ticks is one second.
    if (tickTimes.get(uuid) % 20L == 0L){
        cycleHint(event.getEntityPlayer());
    }
}
项目:EnchantView    文件:EnchantView.java   
/**
 * This cycles the hints once per second.
 * It might be less than once per second on laggy servers, because it's technically once per 20 ticks.
 * @param player The player whose tick we must cycle
 */
private void cycleHint(EntityPlayer player){
    UUID uuid = player.getUniqueID();
    ContainerEnchantment container = (ContainerEnchantment)player.openContainer;
    int[][] enchantClues = this.enchantmentClues.get(uuid);
    int[][] worldClues = this.worldClues.get(uuid);
    if (enchantClues == null || worldClues == null){
        return;
    }
    for (int j = 0; j < 3; j++){
        int[] currEnchantClues = enchantClues[j];
        int[] currWorldClues = worldClues[j];
        if (currEnchantClues == null || currWorldClues == null){
            return;
        }
        container.enchantClue[j] = currEnchantClues[(int)((tickTimes.get(uuid) / 20L) % (long)currEnchantClues.length)];
        container.worldClue[j] = currWorldClues[(int)((tickTimes.get(uuid) / 20L) % (long)currWorldClues.length)];
    }
    container.detectAndSendChanges();
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIEnchantment(int p_71002_1_, int p_71002_2_, int p_71002_3_, String p_71002_4_)
{
    // CraftBukkit start - Inventory open hook
    Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_));

    if (container == null)
    {
        return;
    }

    // CraftBukkit end
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, p_71002_4_ == null ? "" : p_71002_4_, 9, p_71002_4_ != null));
    this.openContainer = container; // CraftBukkit - Use container we passed to event
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:DecompiledMinecraft    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable p_i45502_3_)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.field_175380_I = p_i45502_3_;
}
项目:BaseClient    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable p_i45502_3_)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.field_175380_I = p_i45502_3_;
}
项目:BaseClient    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable p_i45502_3_)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.field_175380_I = p_i45502_3_;
}
项目:Backmemed    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable nameable)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.nameable = nameable;
}
项目:CustomWorldGen    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable nameable)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.nameable = nameable;
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
public void displayGUIEnchantment(int par1, int par2, int par3, String par4Str)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, par4Str == null ? "" : par4Str, 9, par4Str != null));
    this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, par1, par2, par3);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:EnchantView    文件:EnchantView.java   
/**
 * If we've detected an update in the craft matrix, we refresh the xp seed as well.
 * One of the features of this mod is to rerandomize every time, like it used to.
 * @param player The player whose table was updated
 */
private void tableUpdated(EntityPlayer player){

    UUID uuid = player.getUniqueID();

    // This causes a change of the tooltip immediately. 
    tickTimes.put(uuid, 0L);

    // This causes rerandomization of the XP Seed.
    player.removeExperienceLevel(0);

    ContainerEnchantment container = (ContainerEnchantment)player.openContainer;
    container.xpSeed = player.getXPSeed();
    int[][] enchantClues = new int[3][];
    int[][] worldClues = new int[3][];
    for (int j = 0; j < 3; j++) {
        if (container.enchantLevels[j] > 0) {
            // func_178148_a, a, getEnchantmentList
            List<EnchantmentData> list = ThebombzenAPI.invokePrivateMethod(container, ContainerEnchantment.class, new String[]{"getEnchantmentList", "a", "func_178148_a"}, new Class<?>[]{ItemStack.class, int.class, int.class}, container.tableInventory.getStackInSlot(0), j, container.enchantLevels[j]);

            if (list != null && !list.isEmpty()) {
                enchantClues[j] = new int[list.size()];
                worldClues[j] = new int[list.size()];
                for (int i = 0; i < list.size(); i++){
                    EnchantmentData enchantmentdata = list.get(i);
                    enchantClues[j][i] = Enchantment.getEnchantmentID(enchantmentdata.enchantmentobj);
                    worldClues[j][i] = enchantmentdata.enchantmentLevel;
                }
            } else {
                enchantClues[j] = null;
                worldClues[j] = null;
            }
        }
    }
    this.enchantmentClues.put(uuid, enchantClues);
    this.worldClues.put(uuid, worldClues);
}
项目:EnchantView    文件:TableState.java   
public TableState(ContainerEnchantment container){
    System.arraycopy(container.enchantLevels, 0, this.enchantLevels, 0, 3);
    for (int i = 0; i < 2; i++){
        ItemStack stack = container.tableInventory.getStackInSlot(i);
        if (stack == null){
            items[i] = "";
            damages[i] = 0;
            sizes[i] = 0;
        } else {
            items[i] = Item.REGISTRY.getNameForObject(stack.getItem()).toString();
            damages[i] = stack.getItemDamage();
            sizes[i] = stack.stackSize;
        }
    }
}
项目:ExpandedRailsMod    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable nameable)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.nameable = nameable;
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void displayGUIEnchantment(int p_71002_1_, int p_71002_2_, int p_71002_3_, String p_71002_4_)
{
    this.getNextWindowId();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, p_71002_4_ == null ? "" : p_71002_4_, 9, p_71002_4_ != null));
    this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
public void func_71002_c(int p_71002_1_, int p_71002_2_, int p_71002_3_, String p_71002_4_) {
   this.func_71117_bO();
   this.field_71135_a.func_72567_b(new Packet100OpenWindow(this.field_71139_cq, 4, p_71002_4_ == null?"":p_71002_4_, 9, p_71002_4_ != null));
   this.field_71070_bA = new ContainerEnchantment(this.field_71071_by, this.field_70170_p, p_71002_1_, p_71002_2_, p_71002_3_);
   this.field_71070_bA.field_75152_c = this.field_71139_cq;
   this.field_71070_bA.func_75132_a(this);
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
public void displayGUIEnchantment(int par1, int par2, int par3, String par4Str)
{
    this.incrementWindowID();
    this.playerNetServerHandler.sendPacketToPlayer(new Packet100OpenWindow(this.currentWindowId, 4, par4Str == null ? "" : par4Str, 9, par4Str != null));
    this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, par1, par2, par3);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:BetterNutritionMod    文件:EntityPlayerMP.java   
public void displayGUIEnchantment(int par1, int par2, int par3, String par4Str)
{
    this.incrementWindowID();
    this.playerNetServerHandler.sendPacketToPlayer(new Packet100OpenWindow(this.currentWindowId, 4, par4Str == null ? "" : par4Str, 9, par4Str != null));
    this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, par1, par2, par3);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addCraftingToCrafters(this);
}
项目:DecompiledMinecraft    文件:TileEntityEnchantmentTable.java   
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    return new ContainerEnchantment(playerInventory, this.worldObj, this.pos);
}
项目:DecompiledMinecraft    文件:TileEntityEnchantmentTable.java   
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    return new ContainerEnchantment(playerInventory, this.worldObj, this.pos);
}
项目:BaseClient    文件:TileEntityEnchantmentTable.java   
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    return new ContainerEnchantment(playerInventory, this.worldObj, this.pos);
}
项目:BaseClient    文件:TileEntityEnchantmentTable.java   
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    return new ContainerEnchantment(playerInventory, this.worldObj, this.pos);
}
项目:Backmemed    文件:TileEntityEnchantmentTable.java   
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    return new ContainerEnchantment(playerInventory, this.world, this.pos);
}
项目:CustomWorldGen    文件:TileEntityEnchantmentTable.java   
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    return new ContainerEnchantment(playerInventory, this.worldObj, this.pos);
}
项目: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;
}
项目:Resilience-Client-Source    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5, String par6Str)
{
    super(new ContainerEnchantment(par1InventoryPlayer, par2World, par3, par4, par5));
    this.field_147075_G = (ContainerEnchantment)this.field_147002_h;
    this.field_147079_H = par6Str;
}
项目:Cauldron    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer p_i1090_1_, World p_i1090_2_, int p_i1090_3_, int p_i1090_4_, int p_i1090_5_, String p_i1090_6_)
{
    super(new ContainerEnchantment(p_i1090_1_, p_i1090_2_, p_i1090_3_, p_i1090_4_, p_i1090_5_));
    this.field_147075_G = (ContainerEnchantment)this.inventorySlots;
    this.field_147079_H = p_i1090_6_;
}
项目:Cauldron    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer p_i1090_1_, World p_i1090_2_, int p_i1090_3_, int p_i1090_4_, int p_i1090_5_, String p_i1090_6_)
{
    super(new ContainerEnchantment(p_i1090_1_, p_i1090_2_, p_i1090_3_, p_i1090_4_, p_i1090_5_));
    this.field_147075_G = (ContainerEnchantment)this.inventorySlots;
    this.field_147079_H = p_i1090_6_;
}
项目:RuneCraftery    文件:SlotEnchantmentTable.java   
SlotEnchantmentTable(ContainerEnchantment p_i1809_1_, String p_i1809_2_, boolean p_i1809_3_, int p_i1809_4_) {
   super(p_i1809_2_, p_i1809_3_, p_i1809_4_);
   this.field_70484_a = p_i1809_1_;
}
项目:RuneCraftery    文件:SlotEnchantment.java   
SlotEnchantment(ContainerEnchantment p_i1810_1_, IInventory p_i1810_2_, int p_i1810_3_, int p_i1810_4_, int p_i1810_5_) {
   super(p_i1810_2_, p_i1810_3_, p_i1810_4_, p_i1810_5_);
   this.field_75227_a = p_i1810_1_;
}
项目:RuneCraftery    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer p_i1090_1_, World p_i1090_2_, int p_i1090_3_, int p_i1090_4_, int p_i1090_5_, String p_i1090_6_) {
   super(new ContainerEnchantment(p_i1090_1_, p_i1090_2_, p_i1090_3_, p_i1090_4_, p_i1090_5_));
   this.field_74215_y = (ContainerEnchantment)this.field_74193_d;
   this.field_94079_C = p_i1090_6_;
}
项目:RuneCraftery    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5, String par6Str)
{
    super(new ContainerEnchantment(par1InventoryPlayer, par2World, par3, par4, par5));
    this.containerEnchantment = (ContainerEnchantment)this.inventorySlots;
    this.field_94079_C = par6Str;
}
项目:BetterNutritionMod    文件:GuiEnchantment.java   
public GuiEnchantment(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5, String par6Str)
{
    super(new ContainerEnchantment(par1InventoryPlayer, par2World, par3, par4, par5));
    this.containerEnchantment = (ContainerEnchantment)this.inventorySlots;
    this.field_94079_C = par6Str;
}