本文整理汇总了Java中net.minecraft.inventory.ContainerEnchantment类的典型用法代码示例。如果您正苦于以下问题:Java ContainerEnchantment类的具体用法?Java ContainerEnchantment怎么用?Java ContainerEnchantment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContainerEnchantment类属于net.minecraft.inventory包,在下文中一共展示了ContainerEnchantment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GuiEnchantmentWrapper
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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;
}
示例2: playerHasContainerOpen
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
/**
* 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());
}
}
示例3: cycleHint
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
/**
* 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();
}
示例4: displayGUIEnchantment
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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);
}
示例5: GuiEnchantment
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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_;
}
示例6: GuiEnchantment
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable nameable)
{
super(new ContainerEnchantment(inventory, worldIn));
this.playerInventory = inventory;
this.container = (ContainerEnchantment)this.inventorySlots;
this.nameable = nameable;
}
示例7: displayGUIEnchantment
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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);
}
示例8: tableUpdated
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
/**
* 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);
}
示例9: TableState
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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;
}
}
}
示例10: displayGUIEnchantment
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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);
}
示例11: func_71002_c
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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);
}
示例12: displayGUIEnchantment
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
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);
}
示例13: createContainer
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
return new ContainerEnchantment(playerInventory, this.worldObj, this.pos);
}
示例14: createContainer
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
return new ContainerEnchantment(playerInventory, this.world, this.pos);
}
示例15: execute
import net.minecraft.inventory.ContainerEnchantment; //导入依赖的package包/类
@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;
}