本文整理汇总了Java中net.minecraft.inventory.ContainerWorkbench类的典型用法代码示例。如果您正苦于以下问题:Java ContainerWorkbench类的具体用法?Java ContainerWorkbench怎么用?Java ContainerWorkbench使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContainerWorkbench类属于net.minecraft.inventory包,在下文中一共展示了ContainerWorkbench类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContainer
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
@Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer entityPlayer) {
ContainerWorkbench container = new ContainerWorkbench(playerInventory, this.world, this.position);
for(int i = 0; i < used.length; i++) {
if(used[i] == null) continue;
ItemStack playerStack = entityPlayer.inventory.mainInventory.get(used[i]);
if(playerStack != null && playerStack.getCount() > 0)
{
ItemStack stackUsed = playerStack.copy();
stackUsed.setCount(1);
playerStack.setCount(playerStack.getCount() - 1);
if(playerStack.getCount() == 0)
{
entityPlayer.inventory.mainInventory.remove(used[i]);
}
container.craftMatrix.setInventorySlotContents(i, stackUsed);
}
}
return container;
}
示例2: displayGUIWorkbench
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
public void displayGUIWorkbench(int p_71058_1_, int p_71058_2_, int p_71058_3_)
{
// CraftBukkit start - Inventory open hook
Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_));
if (container == null)
{
return;
}
// CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
示例3: getGridItem
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
public static ItemStack getGridItem(int nr) {
GuiContainer menu = (GuiContainer)getMenu();
Container slots = menu.inventorySlots;
if (menu instanceof GuiCrafting) {
return ((ContainerWorkbench)slots).craftMatrix.getStackInSlot(nr);
} else if (menu instanceof GuiInventory) {
return ((ContainerPlayer)slots).craftMatrix.getStackInSlot(nr);
}
return null;
}
示例4: createItem
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
private void createItem(EntitySheep entity, World worldObj) {
final ContainerWorkbench container = new ContainerWorkbench(new InventoryPlayer(null), worldObj, entity.getPosition());
for (int i = 0; i < 9; ++i) {
container.craftMatrix.setInventorySlotContents(i, itemsConsumed[i]);
}
final CraftingManager instance = CraftingManager.getInstance();
final ItemStack craftedItem = instance.findMatchingRecipe(container.craftMatrix, worldObj);
if (craftedItem != null) {
EntityItem entityItem = new EntityItem(worldObj, entity.posX, entity.posY, entity.posZ, craftedItem);
worldObj.spawnEntityInWorld(entityItem);
entityItem.rotationYaw = entity.renderYawOffset + 180;
entityItem.moveRelative(0, 0.3f, 1);
final ItemStack[] remainingItems = instance.getRemainingItems(container.craftMatrix, worldObj);
for (final ItemStack remainingItem : remainingItems) {
if (remainingItem == null) continue;
entityItem = new EntityItem(worldObj, entity.posX, entity.posY, entity.posZ, remainingItem);
worldObj.spawnEntityInWorld(entityItem);
entityItem.rotationYaw = entity.renderYawOffset + 180;
entityItem.moveRelative(0, 0.3f, 1);
}
}
System.arraycopy(originalCraftingGrid, 0, itemsToCollect, 0, 9);
itemsConsumed = new ItemStack[9];
updateItemsConsumed();
}
示例5: simulateInventoryOf
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
/**
* Simulates an inventory with the given inputs as
* @param inputs The inputs
* @param width The width of the inventory to simulate
* @param height The height of the inventory to simulate
* @return The crafting inventory
*/
public static InventoryCrafting simulateInventoryOf(ItemStack[] inputs, int width, int height) {
if(inputs == null) return null;
// Make a container...
Container c = new ContainerWorkbench(new InventoryPlayer(null), null, BlockPos.ORIGIN);
// Figure out our sizes:
if(width <= 0 && height <= 0) {
width = height = inputs.length > 4 ? 3 : 2;
}
if(width <= 0) {
width = (int)Math.ceil((double)inputs.length / height);
}
if(height <= 0) {
height = (int)Math.ceil((double)inputs.length / width);
}
InventoryCrafting inv = new InventoryCrafting(c, width, height);
for (int i = 0; i < inputs.length; i++) {
inv.setInventorySlotContents(i, inputs[i]);
}
// And pretend we're crafting:
return inv;
}
示例6: displayGUIWorkbench
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
/**
* Displays the crafting GUI for a workbench.
*/
public void displayGUIWorkbench(int par1, int par2, int par3)
{
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
this.openContainer = new ContainerWorkbench(this.inventory, this.worldObj, par1, par2, par3);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
示例7: executeClient
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
@Override
public void executeClient(EntityPlayer player) {
if(player.openContainer instanceof ContainerWorkbench)
{
EventHandler.index = index;
((ContainerWorkbench)player.openContainer).craftResult.setInventorySlotContents(0, stack);
}
}
示例8: executeServer
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
@Override
public void executeServer(EntityPlayer player) {
if(player.openContainer instanceof ContainerWorkbench)
{
((ContainerWorkbench)player.openContainer).craftResult.setInventorySlotContents(0, stack);
PacketHandler.sendPacketToPlayer(new CraftResultPacket(index, stack), (EntityPlayerMP) player);
}
}
示例9: displayGUIWorkbench
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
public void displayGUIWorkbench(int p_71058_1_, int p_71058_2_, int p_71058_3_)
{
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
this.openContainer = new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
示例10: func_71058_b
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
public void func_71058_b(int p_71058_1_, int p_71058_2_, int p_71058_3_) {
this.func_71117_bO();
this.field_71135_a.func_72567_b(new Packet100OpenWindow(this.field_71139_cq, 1, "Crafting", 9, true));
this.field_71070_bA = new ContainerWorkbench(this.field_71071_by, this.field_70170_p, p_71058_1_, p_71058_2_, p_71058_3_);
this.field_71070_bA.field_75152_c = this.field_71139_cq;
this.field_71070_bA.func_75132_a(this);
}
示例11: displayGUIWorkbench
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
/**
* Displays the crafting GUI for a workbench.
*/
public void displayGUIWorkbench(int par1, int par2, int par3)
{
this.incrementWindowID();
this.playerNetServerHandler.sendPacketToPlayer(new Packet100OpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
this.openContainer = new ContainerWorkbench(this.inventory, this.worldObj, par1, par2, par3);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
示例12: onTooltip
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
if (ItemStack.areItemStacksEqual(lastOutput, event.getItemStack())) {
if ((event.getEntityPlayer().openContainer instanceof ContainerWorkbench
&& ((ContainerWorkbench) event.getEntityPlayer().openContainer).craftResult.getStackInSlot(0) == event.getItemStack())
|| (event.getEntityPlayer().openContainer instanceof ContainerPlayer
&& ((ContainerPlayer) event.getEntityPlayer().openContainer).craftResult.getStackInSlot(0) == event.getItemStack())) {
event.getToolTip().add(Lang.RECIPE_CLEAR.get());
}
}
}
示例13: doesRecipeExist
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
public boolean doesRecipeExist(ICraftingPatternMAC pattern)
{
InventoryCrafting inv = new InventoryCrafting(new ContainerWorkbench(new InventoryPlayer(null), gridTE.getWorld(), 0, 0, 0)
{
public void onCraftMatrixChanged(IInventory par1IInventory)
{
}
}, 3, 3);
for (int i = 0; i < pattern.getCraftingMatrix().length; i++)
{
inv.setInventorySlotContents(i, pattern.getCraftingMatrix()[i]);
}
ItemStack thing = CraftingManager.getInstance().findMatchingRecipe(inv, gridTE.getWorld());
return ItemStack.areItemStacksEqual(thing, pattern.getOutput());
}
示例14: createContainer
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
return new ContainerWorkbench(playerInventory, this.world, this.position);
}
示例15: GuiCrafting
import net.minecraft.inventory.ContainerWorkbench; //导入依赖的package包/类
public GuiCrafting(InventoryPlayer playerInv, World worldIn, BlockPos blockPosition)
{
super(new ContainerWorkbench(playerInv, worldIn, blockPosition));
}