本文整理匯總了Java中net.minecraft.inventory.SlotCrafting類的典型用法代碼示例。如果您正苦於以下問題:Java SlotCrafting類的具體用法?Java SlotCrafting怎麽用?Java SlotCrafting使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SlotCrafting類屬於net.minecraft.inventory包,在下文中一共展示了SlotCrafting類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ContainerStorageCoreCrafting
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
public ContainerStorageCoreCrafting(EntityPlayer player, World world,
int x, int y, int z) {
super(player, world, x, y, z);
this.worldObj = world;
this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 116, 117));
int i;
int j;
for (i = 0; i < 3; ++i)
{
for (j = 0; j < 3; ++j)
{
this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 44 + j * 18, 99 + i * 18));
}
}
this.onCraftMatrixChanged(this.craftMatrix);
}
示例2: slotClick
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
@Override
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer playerIn) {
if (mode == 0 && clickedButton == 0) {
if (slotId >= 0 && inventorySlots.size() > slotId) {
Slot slotObject = inventorySlots.get(slotId);
if (slotObject != null) {
if (slotObject instanceof SlotCrafting) {
ItemStack[] recipe = new ItemStack[9];
for (int i=0; i<9; i++) {
recipe[i] = this.craftMatrix.getStackInSlot(i);
}
ItemStack result = super.slotClick(slotId, clickedButton, mode, playerIn);
if (result != null) {
tryToPopulateCraftingGrid(recipe, playerIn);
}
return result;
}
}
}
}
return super.slotClick(slotId, clickedButton, mode, playerIn);
}
示例3: slotClick
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
// if (clickTypeIn == ClickType.QUICK_CRAFT) {
if (slotId >= 0 && slotId < inventorySlots.size()) {
Slot slotObject = inventorySlots.get(slotId);
if (slotObject != null && slotObject instanceof SlotCrafting) { // user clicked on result slot
ItemStack[] recipe = new ItemStack[9];
for (int i = 0; i < 9; i++) {
recipe[i] = this.craftMatrix.getStackInSlot(i);
}
ItemStack result = super.slotClick(slotId, dragType, clickTypeIn, player);
if (result != null) {
tryToPopulateCraftingGrid(recipe, player);
}
return result;
}
}
// }
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
示例4: sendSlotContents
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
/**
* Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
* contents of that slot. Args: Container, slot number, slot contents
*/
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
{
if (!this.isChangingQuantityOnly)
{
this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(containerToSend.windowId, slotInd, stack));
}
}
}
示例5: sendSlotContents
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
/**
* Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
* contents of that slot.
*/
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
{
if (!this.isChangingQuantityOnly)
{
this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
}
}
}
示例6: ContainerSimpleWorkbench
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
public ContainerSimpleWorkbench(InventoryPlayer invPlayer, World world, BlockPos loc)
{
worldObj = world;
pos = loc;
addSlotToContainer(new SlotCrafting(invPlayer.player, craftMatrix, craftResult, 0, 124, 35));
int l;
int i1;
for (l = 0; l < 3; ++l)
{
for (i1 = 0; i1 < 3; ++i1)
{
addSlotToContainer(new Slot(craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18));
}
}
for (l = 0; l < 3; ++l)
{
for (i1 = 0; i1 < 9; ++i1)
{
addSlotToContainer(new Slot(invPlayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18));
}
}
for (l = 0; l < 9; ++l)
{
addSlotToContainer(new Slot(invPlayer, l, 8 + l * 18, 142));
}
onCraftMatrixChanged(craftMatrix);
}
示例7: transferStackInSlot
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber)
{
Slot slot = (Slot) this.inventorySlots.get(slotNumber);
if (slot != null && slot.getHasStack())
{
ItemStack stack = slot.getStack();
if (!(slot instanceof SlotAccessory) && !(slot instanceof SlotCrafting))
{
int newSlotIndex = -1;
if (AetherAPI.getInstance().isAccessory(stack))
{
newSlotIndex = this.getAccessorySlot(AetherAPI.getInstance().getAccessory(stack).getAccessoryType());
}
if (newSlotIndex != -1)
{
Slot accessorySlot = this.inventorySlots.get(newSlotIndex);
if (accessorySlot.isItemValid(stack))
{
accessorySlot.putStack(stack);
slot.putStack((ItemStack) null);
}
return stack;
}
}
}
return super.transferStackInSlot(player, slotNumber);
}
示例8: GoCraftContainer
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
public GoCraftContainer(InventoryPlayer playerInventory, World worldIn, BlockPos posIn)
{
this.worldObj = worldIn;
this.pos = posIn;
this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35));
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 30 + j * 18, 17 + i * 18));
}
}
for (int k = 0; k < 3; ++k)
{
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18));
}
}
for (int l = 0; l < 9; ++l)
{
this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142));
}
this.onCraftMatrixChanged(this.craftMatrix);
}
示例9: ContainerStorageCoreCrafting
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
public ContainerStorageCoreCrafting(EntityPlayer player, World world, int x, int y, int z) {
super(player, world, x, y, z);
this.worldObj = world;
this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 116, 117));
int i;
int j;
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 44 + j * 18, 99 + i * 18));
}
}
this.onCraftMatrixChanged(this.craftMatrix);
}
示例10: onMessage
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
@Override
public IMessage onMessage(MessageScanSlot message, MessageContext ctx) {
EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
Container container = entityPlayer.openContainer;
if (container != null && message.getSlotNumber() >= 0 && message.getSlotNumber() < container.inventorySlots.size()) {
Slot slot = (Slot) container.inventorySlots.get(message.getSlotNumber());
if (slot.getStack() != null && slot.canTakeStack(entityPlayer) && !(slot instanceof SlotCrafting)) {
ItemStack itemStack = slot.getStack();
ScanResult scan = new ScanResult((byte) 1, Item.getIdFromItem(itemStack.getItem()), itemStack.getItemDamage(), null, "");
ScanManager.completeScan(entityPlayer, scan, "@");
}
}
return null;
}
示例11: MCCraftingGrid
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
private MCCraftingGrid(InventoryCrafting inventory) {
this.inventory = inventory;
width = height = (int) Math.sqrt(inventory.getSizeInventory());
items = new nova.core.item.Item[width * height];
original = new ItemStack[items.length];
itemCount = 0;
update();
Container container = ReflectionUtil.getCraftingContainer(inventory);
if (container != null) {
@SuppressWarnings("unchecked")
List<Slot> slots = container.inventorySlots;
EntityPlayer playerOrig = null;
Optional<Player> player = Optional.empty();
for (Slot slot : slots) {
if (slot instanceof SlotCrafting) {
playerOrig = ReflectionUtil.getCraftingSlotPlayer((SlotCrafting) slot);
player = WrapUtility.getNovaPlayer(playerOrig);
if (player.isPresent()) {
break;
}
}
}
this.playerOrig = playerOrig;
this.player = player;
} else {
playerOrig = null;
player = Optional.empty();
}
}
示例12: getCraftingSlotPlayer
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) {
try {
return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot);
} catch (IllegalAccessException ex) {
Game.logger().error("could not get inventory eventhandler");
return null;
}
}
示例13: MCCraftingGrid
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
private MCCraftingGrid(InventoryCrafting inventory) {
this.inventory = inventory;
width = height = (int) Math.sqrt(inventory.getSizeInventory());
items = new nova.core.item.Item[width * height];
original = new net.minecraft.item.ItemStack[items.length];
itemCount = 0;
update();
Container container = ReflectionUtil.getCraftingContainer(inventory);
if (container != null) {
@SuppressWarnings("unchecked")
List<Slot> slots = container.inventorySlots;
EntityPlayer playerOrig = null;
Optional<Player> player = Optional.empty();
for (Slot slot : slots) {
if (slot instanceof SlotCrafting) {
playerOrig = ReflectionUtil.getCraftingSlotPlayer((SlotCrafting) slot);
player = WrapUtility.getNovaPlayer(playerOrig);
if (player.isPresent()) {
break;
}
}
}
this.playerOrig = playerOrig;
this.player = player;
} else {
playerOrig = null;
player = Optional.empty();
}
}
示例14: ContainerWorkBench
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
public ContainerWorkBench(InventoryPlayer inventoryPlayer, TileEntityWorkbench te) {
craftMatrix = new InventoryWorkbench(this, te);
this.world = inventoryPlayer.player.world;
this.player = inventoryPlayer.player;
this.setTile(te);
tileEntity = te;
this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 136, 35));
int slot = 0;
//inpt on left
int xPrefix = Const.PAD, yPrefix = 27;
int rows = TileEntityWorkbench.ROWS;
int cols = TileEntityWorkbench.COLS;
//crafting in the middle
rows = cols = 3;
xPrefix = (screenSize.width() / 2 - (Const.SQ * 3) / 2);//(GuiWorkbench.WIDTH / 2 - (Const.SQ * 3) / 2);
yPrefix = 20;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
addSlotToContainer(new Slot(this.craftMatrix, slot,
xPrefix + j * Const.SQ,
yPrefix + i * Const.SQ));
slot++;
}
}
// commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
this.onCraftMatrixChanged(this.craftMatrix);
}
示例15: sendSlotContents
import net.minecraft.inventory.SlotCrafting; //導入依賴的package包/類
/**
* Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
* contents of that slot. Args: Container, slot number, slot contents
*/
public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack)
{
if (!(par1Container.getSlot(par2) instanceof SlotCrafting))
{
if (!this.isChangingQuantityOnly)
{
this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(par1Container.windowId, par2, par3ItemStack));
}
}
}