本文整理匯總了Java中net.minecraft.inventory.Slot類的典型用法代碼示例。如果您正苦於以下問題:Java Slot類的具體用法?Java Slot怎麽用?Java Slot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Slot類屬於net.minecraft.inventory包,在下文中一共展示了Slot類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ContainerProgrammer
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public ContainerProgrammer(InventoryPlayer inventoryPlayer, TileEntityProgrammer te) {
super(te);
addSlotToContainer(new SlotItemHandler(te.getPrimaryInventory(), 0, 326, 15) {
@Override
public boolean isItemValid(@Nonnull ItemStack stack) {
return isProgrammableItem(stack);
}
});
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex) {
addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 95 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
}
}
// Add the player's action bar slots to the container
for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) {
addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 95 + actionBarSlotIndex * 18, 232));
}
}
示例2: ContainerAmmoFurnace
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public ContainerAmmoFurnace(InventoryPlayer playerInventory, IInventory furnaceInventory) {
this.tileFurnace = furnaceInventory;
for (int i = 0; i < 9; i++)
this.addSlotToContainer(new Slot(furnaceInventory, i, 9 + (i % 3) * 18, 17 + (i / 3) * 18));
this.addSlotToContainer(new SlotFurnaceFuel(furnaceInventory, 9, 80, 53));
for (int i = 0; i < 9; i++)
this.addSlotToContainer(new SlotFurnaceOutput(playerInventory.player, furnaceInventory, i + 10,
116 + (i % 3) * 18, 17 + (i / 3) * 18));
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 9; ++j)
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
for (int k = 0; k < 9; ++k)
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
示例3: buildInventoryLayout
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public static void buildInventoryLayout(Container container, InventoryPlayer inventory, int x, int y, boolean freezeSlot, boolean toolBarAfterMainInv)
{
int index = 0;
if(!toolBarAfterMainInv)
addToolbarSlots(container, inventory, x, y, freezeSlot);
for(int i = 0; i < 3; ++i)
{
for(int k = 0; k < 9; ++k)
{
index = k + (i+1) * 9;
addSlotToContainer(container, new Slot(inventory, index, x + k * 18, y + i * 18));
}
}
if(toolBarAfterMainInv)
addToolbarSlots(container, inventory, x, y, freezeSlot);
}
示例4: ContainerOven
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public ContainerOven(IInventory playerInventory, TileOven te) {
this.oven = te;
//input slot
this.addSlotToContainer(new Slot(oven.inventory, 0, 19, 17));
//fuel slot
this.addSlotToContainer(new FilteredSlot(oven.inventory, 1, 19, 53, net.minecraft.tileentity.TileEntityFurnace::isItemFuel));
//jar slot
this.addSlotToContainer(new FilteredSlot(oven.inventory, 2, 69, 53, s -> s.getItem() == ModItems.fume && s.getMetadata() == 1));
//fume slot
this.addSlotToContainer(new OutputSlot(oven.inventory, 3, 128, 53));
//output slot
this.addSlotToContainer(new OutputSlot(oven.inventory, 4, 124, 21));
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int k = 0; k < 9; ++k) {
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
}
示例5: ContainerCreative
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public ContainerCreative(EntityPlayer p_i1086_1_)
{
InventoryPlayer inventoryplayer = p_i1086_1_.inventory;
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(GuiContainerCreative.field_147060_v, i * 9 + j, 9 + j * 18, 18 + i * 18));
}
}
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(inventoryplayer, k, 9 + k * 18, 112));
}
this.scrollTo(0.0F);
}
示例6: ContainerBloomeryFurnace
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public ContainerBloomeryFurnace (InventoryPlayer playerInventory, IInventory containerInventory) {
this.tile = containerInventory;
primarySlot = addSlotToContainer(new Slot(tile, 0, 56, 17));
secondarySlot = addSlotToContainer(new Slot(tile, 1, 35, 17));
fuelSlot = addSlotToContainer(new Slot(tile, 2, 56, 53));
outputSlot = addSlotToContainer(new SlotBloomeryOutput(playerInventory.player, tile, 3, 116, 35));
playerSlots = new ArrayList<>();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++)
playerSlots.add(addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, InventoryX + j * 18, InventoryY + i * 18)));
}
hotbarSlots = new ArrayList<>();
for (int i = 0; i < 9; i++)
hotbarSlots.add(addSlotToContainer(new Slot(playerInventory, i, InventoryX + i * 18, HotbarY)));
}
示例7: ContainerTileCustomMachine
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public ContainerTileCustomMachine(IInventory playerInv, TileCustomMachine tileEntity)
{
super(0,3, 4,40);
setTileEntity(tileEntity);
CustomMachineSlot slotFirst = new CustomMachineSlot((ISidedInventory) tileEntity, 0, 52, 16);
CustomMachineSlot slotSecond = new CustomMachineSlot((ISidedInventory) tileEntity, 1, 80, 16);
CustomMachineSlot slotThird = new CustomMachineSlot((ISidedInventory) tileEntity, 2, 107, 16);
CustomMachineSlot slotOut = new CustomMachineSlot((ISidedInventory) tileEntity, 3, 80, 46);
// Tile Entity, Slot 0-3, Slot IDs 0-3
this.addSlotToContainer(slotFirst);
this.addSlotToContainer(slotSecond);
this.addSlotToContainer(slotThird);
this.addSlotToContainer(slotOut);
// Player Inventory, Slot 4-35, Slot IDs 4-35
for (int y = 0; y < 3; ++y)
for (int x = 0; x < 9; ++x)
this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
// Player Inventory, Slot 0-8, Slot IDs 36-44
for (int x = 0; x < 9; ++x)
this.addSlotToContainer(new Slot(playerInv, x, 8 + x * 18, 142));
}
示例8: transferStackInSlot
import net.minecraft.inventory.Slot; //導入依賴的package包/類
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < 2) {
if (!this.mergeItemStack(itemstack1, 2, this.inventorySlots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
示例9: handleMouseClick
import net.minecraft.inventory.Slot; //導入依賴的package包/類
/**
* Called when the mouse is clicked over a slot or outside the gui.
*/
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType)
{
if (slotIn != null)
{
slotId = slotIn.slotNumber;
}
this.mc.playerController.windowClick(this.inventorySlots.windowId, slotId, clickedButton, clickType, this.mc.thePlayer);
}
示例10: mouseReleased
import net.minecraft.inventory.Slot; //導入依賴的package包/類
@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
Slot slot = this.getSlotUnderMouse();
if (slot != null) {
if (slot instanceof GhostSlot) {
return;
}
}
// TODO Auto-generated method stub
super.mouseReleased(mouseX, mouseY, state);
}
示例11: transferStackInSlot
import net.minecraft.inventory.Slot; //導入依賴的package包/類
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
ItemStack previous = null;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack()) {
ItemStack current = slot.getStack();
previous = current.copy();
if (fromSlot < 9) {
// From TE Inventory to Player Inventory
if (!this.mergeItemStack(current, 9, 45, true))
return null;
} else {
// From Player Inventory to TE Inventory
if (!this.mergeItemStack(current, 0, 9, false))
return null;
}
if (current.stackSize == 0)
slot.putStack((ItemStack) null);
else
slot.onSlotChanged();
if (current.stackSize == previous.stackSize)
return null;
slot.onPickupFromSlot(playerIn, current);
}
return previous;
}
示例12: transferStackInSlot
import net.minecraft.inventory.Slot; //導入依賴的package包/類
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
Slot slot = inventorySlots.get(index);
//System.out.println(index);
if (slot == null || !slot.getHasStack()) {
return null;
}
ItemStack newStack = slot.getStack(), oldStack = newStack.copy();
boolean isMerged = false;
if (index >= 0 && index <= 1) {
isMerged = mergeItemStack(newStack, 2, 38, true);
} else if (index >= 2 && index < 29) {
isMerged = !pictureInSlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
|| mergeItemStack(newStack, 29, 38, false);
} else if (index >= 29 && index < 38) {
isMerged = !pictureInSlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
|| mergeItemStack(newStack, 2, 29, false);
}
if (!isMerged) {
return null;
}
if (newStack.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
slot.onPickupFromSlot(playerIn, newStack);
return oldStack;
}
示例13: renameItem
import net.minecraft.inventory.Slot; //導入依賴的package包/類
private void renameItem()
{
String s = this.nameField.getText();
Slot slot = this.anvil.getSlot(0);
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
{
s = "";
}
this.anvil.updateItemName(s);
this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
示例14: mouseClicked
import net.minecraft.inventory.Slot; //導入依賴的package包/類
public void mouseClicked(int x, int y, int mouseButton, Slot slot) {
if (slot != null) {
if (mouseButton == 0) tryToHackSlot(slot.slotNumber);
if (mouseButton == 1 && slotHacked[slot.slotNumber]) {
boolean alreadyFortifying = false;
for (GuiStatBalloon balloon : balloons) {
if (balloon.slotNumber == slot.slotNumber) {
alreadyFortifying = true;
break;
}
}
if (!alreadyFortifying) {
balloons.add(new GuiStatBalloon(slot.xPos + gui.getGuiLeft() + 8, slot.yPos + gui.getGuiTop() - 5, slot.slotNumber));
}
}
if (mouseButton == 2 && !slotHacked[slot.slotNumber] && ((GuiSecurityStationHacking) gui).hasNukeViruses()) {
int linesBefore = lineList.size();
if (tryToHackSlot(slot.slotNumber)) {
EntityPlayer player = FMLClientHandler.instance().getClient().player;
NetworkHandler.sendToServer(new PacketUseItem(Itemss.NUKE_VIRUS, 1));
PneumaticCraftUtils.consumeInventoryItem(player.inventory, Itemss.NUKE_VIRUS);
for (int i = linesBefore; i < lineList.size(); i++) {
RenderProgressingLine line = lineList.get(i);
line.setProgress(1);
slotHacked[slot.slotNumber] = true;
onSlotHack(slot.slotNumber, true);
}
}
}
}
}
示例15: updateDragSplitting
import net.minecraft.inventory.Slot; //導入依賴的package包/類
private void updateDragSplitting()
{
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (itemstack != null && this.dragSplitting)
{
this.dragSplittingRemnant = itemstack.stackSize;
for (Slot slot : this.dragSplittingSlots)
{
ItemStack itemstack1 = itemstack.copy();
int i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
{
itemstack1.stackSize = itemstack1.getMaxStackSize();
}
if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1))
{
itemstack1.stackSize = slot.getItemStackLimit(itemstack1);
}
this.dragSplittingRemnant -= itemstack1.stackSize - i;
}
}
}