本文整理了Java中net.minecraft.inventory.Slot
类的一些代码示例,展示了Slot
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Slot
类的具体详情如下:
包路径:net.minecraft.inventory.Slot
类名称:Slot
暂无
代码示例来源:origin: Vazkii/Botania
@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(slotIndex);
if(slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if(slotIndex < 16) {
if(!mergeItemStack(itemstack1, 16, 52, true))
return ItemStack.EMPTY;
} else {
int i = itemstack.getItemDamage();
if(i < 16) {
Slot slot1 = inventorySlots.get(i);
if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true))
return ItemStack.EMPTY;
}
}
if(itemstack1.isEmpty())
slot.putStack(ItemStack.EMPTY);
else slot.onSlotChanged();
if(itemstack1.getCount() == itemstack.getCount())
return ItemStack.EMPTY;
slot.onTake(player, itemstack1);
}
return itemstack;
}
代码示例来源:origin: Vazkii/Botania
public ContainerFlowerBag(InventoryPlayer playerInv, InventoryFlowerBag flowerBagInv) {
int i;
int j;
this.flowerBagInv = flowerBagInv;
for(i = 0; i < 2; ++i)
for(j = 0; j < 8; ++j) {
int k = j + i * 8;
addSlotToContainer(new SlotItemHandler(flowerBagInv, k, 17 + j * 18, 26 + i * 18));
}
for(i = 0; i < 3; ++i)
for(j = 0; j < 9; ++j)
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
for(i = 0; i < 9; ++i) {
if(playerInv.getStackInSlot(i) == flowerBagInv.bag)
addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142));
else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
}
}
代码示例来源:origin: Vazkii/Botania
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
for(int i1 = 0; i1 < 7; ++i1) {
Slot slot = inventorySlots.inventorySlots.get(i1);
if(slot.getHasStack() && slot.getSlotStackLimit() == 1)
drawTexturedModalRect(guiLeft+slot.xPos, guiTop+slot.yPos, 200, 0, 16, 16);
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final ItemStack isA = a.getStack();
final ItemStack isB = b.getStack();
if( !isA.isEmpty() && !a.canTakeStack( this.getInventoryPlayer().player ) )
if( !isB.isEmpty() && !b.canTakeStack( this.getInventoryPlayer().player ) )
if( !isB.isEmpty() && !a.isItemValid( isB ) )
if( !isA.isEmpty() && !b.isItemValid( isA ) )
if( !testA.isEmpty() && testA.getCount() > a.getSlotStackLimit() )
testA.setCount( a.getSlotStackLimit() );
testB = testA.copy();
if( !testB.isEmpty() && testB.getCount() > b.getSlotStackLimit() )
testB.setCount( b.getSlotStackLimit() );
testA = testB.copy();
a.putStack( testA );
b.putStack( testB );
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
if( d.isItemValid( tis ) )
if( d.getHasStack() )
final ItemStack t = d.getStack().copy();
if( maxSize > d.getSlotStackLimit() )
maxSize = d.getSlotStackLimit();
d.putStack( t );
d.onSlotChanged();
if( d.isItemValid( tis ) )
if( d.getHasStack() )
final ItemStack t = d.getStack().copy();
if( d.getSlotStackLimit() < maxSize )
maxSize = d.getSlotStackLimit();
d.putStack( t );
d.onSlotChanged();
if( maxSize > d.getSlotStackLimit() )
代码示例来源:origin: Vazkii/Quark
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(index);
if(index >= 9 && index < 36 && slot != null && slot.getHasStack()) {
ItemStack stack = slot.getStack();
if(!mergeItemStack(stack, 46, 72, false))
return ItemStack.EMPTY;
}
return super.transferStackInSlot(playerIn, index);
}
代码示例来源:origin: ForestryMC/ForestryMC
private static boolean shiftItemStackToRangeOpenSlots(List<Slot> inventorySlots, ItemStack stackToShift, int start, int count) {
if (stackToShift.isEmpty()) {
return false;
}
boolean changed = false;
for (int slotIndex = start; !stackToShift.isEmpty() && slotIndex < start + count; slotIndex++) {
Slot slot = inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot.isEmpty()) {
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
stackInSlot = stackToShift.copy();
stackInSlot.setCount(Math.min(stackToShift.getCount(), max));
stackToShift.shrink(stackInSlot.getCount());
slot.putStack(stackInSlot);
slot.onSlotChanged();
changed = true;
}
}
return changed;
}
代码示例来源:origin: Vazkii/Botania
private static ItemStack getStackUnderMouse() {
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
if(screen instanceof GuiContainer) {
Slot slotUnderMouse = ((GuiContainer) screen).getSlotUnderMouse();
if(slotUnderMouse != null)
return slotUnderMouse.getStack();
}
return jeiPanelSupplier.get();
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public void clear()
{
for( final Slot s : this.craftingSlots )
{
s.putStack( ItemStack.EMPTY );
}
for( final Slot s : this.outputSlots )
{
s.putStack( ItemStack.EMPTY );
}
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public boolean hasFilter(boolean input) {
Slot slot = input ? slotInputFilter : slotOutputFilter;
return slot != null && slot.getHasStack();
}
代码示例来源:origin: Nividica/ThaumicEnergistics
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
if (ForgeUtil.isClient() || index < 0 || index > this.inventorySlots.size())
return super.transferStackInSlot(playerIn, index);
Slot slot = this.inventorySlots.get(index);
if (slot.getHasStack() && !slot.getStack().isEmpty()) {
IAEItemStack remaining = AEUtil.inventoryInsert(this.channel.createStack(slot.getStack()), this.monitor, this.part.source, Actionable.MODULATE);
slot.putStack(remaining == null ? ItemStack.EMPTY : remaining.createItemStack());
this.detectAndSendChanges();
}
return super.transferStackInSlot(playerIn, index);
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void onSlotChanged() {
super.onSlotChanged();
if (!isOpening) {
updateRecipes();
updateSelectedRecipe();
}
}
};
代码示例来源:origin: sinkillerj/ProjectE
@Nonnull
@Override
public ItemStack slotClick(int slot, int button, ClickType flag, EntityPlayer player)
{
if (slot >= 0 && getSlot(slot) instanceof SlotGhost && !getSlot(slot).getStack().isEmpty())
{
getSlot(slot).putStack(ItemStack.EMPTY);
return ItemStack.EMPTY;
} else
{
return super.slotClick(slot, button, flag, player);
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() );
NetworkHandler.instance().sendToServer( p );
if( slot != null )
this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY;
for( final Slot inventorySlot : slots )
if( inventorySlot != null && inventorySlot.canTakeStack(
this.mc.player ) && inventorySlot.getHasStack() && inventorySlot.isSameInventory( slot ) && Container.canAddItemToSlot(
inventorySlot, this.dbl_whichItem, true ) )
代码示例来源:origin: CoFH/ThermalDynamics
@Override
public ItemStack slotClick(int slotId, int mouseButton, ClickType modifier, EntityPlayer player) {
Slot slot = slotId < 0 ? null : this.inventorySlots.get(slotId);
if (slot instanceof SlotFalseCopy) {
if (mouseButton == 2) {
slot.putStack(ItemStack.EMPTY);
slot.onSlotChanged();
} else {
slot.putStack(player.inventory.getItemStack().isEmpty() ? ItemStack.EMPTY : player.inventory.getItemStack().copy());
}
return player.inventory.getItemStack();
}
return super.slotClick(slotId, mouseButton, modifier, player);
}
代码示例来源:origin: ForestryMC/ForestryMC
private static boolean shiftToMachineInventory(List<Slot> inventorySlots, ItemStack stackToShift, int numSlots, boolean mergeOnly) {
for (int machineIndex = playerInventorySize; machineIndex < numSlots; machineIndex++) {
Slot slot = inventorySlots.get(machineIndex);
if (mergeOnly && slot.getStack().isEmpty()) {
continue;
}
if (slot instanceof SlotForestry) {
SlotForestry slotForestry = (SlotForestry) slot;
if (!slotForestry.canShift() || slotForestry.isPhantom()) {
continue;
}
}
if (!slot.isItemValid(stackToShift)) {
continue;
}
if (shiftItemStackToRange(inventorySlots, stackToShift, machineIndex, 1)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: Vazkii/Quark
@Override
public ItemStack onTake(EntityPlayer thePlayer, ItemStack stack) {
finish(thePlayer, stack);
return super.onTake(thePlayer, stack);
}
});
代码示例来源:origin: Azanor/Baubles
@Override
public boolean isItemValid(ItemStack stack)
{
return super.isItemValid(stack);
}
@Override
代码示例来源:origin: GregTechCE/GregTech
private static void fillPhantomSlot(Slot slot, ItemStack stackHeld, int mouseButton) {
if (stackHeld.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
return;
}
int stackSize = mouseButton == 0 ? stackHeld.getCount() : 1;
if (stackSize > slot.getSlotStackLimit()) {
stackSize = slot.getSlotStackLimit();
}
ItemStack phantomStack = stackHeld.copy();
phantomStack.setCount(stackSize);
slot.putStack(phantomStack);
}
代码示例来源:origin: SonarSonic/Calculator
@Override
public void onSlotChange(ItemStack stack1, ItemStack stack2) {
super.onSlotChange(stack1, stack2);
if (player != null) {
/*
int[] unblocked = entity.unblockedList();
if (entity.isBlocked(entity.lastResearch) && entity.lastResearch != 0) {
if (CalculatorRecipes.recipes().discovery(unblocked, entity.lastResearch)) {
FontHelper.sendMessage(FontHelper.translate("research.recipeNew"), entity.getWorld(), player);
}
}
*/
entity.markBlockForUpdate();
entity.getWorld().addBlockEvent(entity.getPos(), entity.getBlockType(), 1, 0);
}
}
内容来源于网络,如有侵权,请联系作者删除!