本文整理汇总了Java中net.minecraft.inventory.Slot.onSlotChange方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.onSlotChange方法的具体用法?Java Slot.onSlotChange怎么用?Java Slot.onSlotChange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.Slot
的用法示例。
在下文中一共展示了Slot.onSlotChange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
@Nonnull
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
Slot srcSlot = inventorySlots.get(slot);
if (srcSlot == null || !srcSlot.getHasStack()) {
return ItemStack.EMPTY;
}
ItemStack srcStack = srcSlot.getStack();
ItemStack copyOfSrcStack = srcStack.copy();
if (slot < playerSlotsStart) {
if (!mergeItemStack(srcStack, playerSlotsStart, playerSlotsStart + 36, false))
return ItemStack.EMPTY;
} else {
if (!mergeItemStack(srcStack, 0, playerSlotsStart, false))
return ItemStack.EMPTY;
}
srcSlot.onSlotChange(srcStack, copyOfSrcStack);
if (srcStack.isEmpty()) {
srcSlot.putStack(ItemStack.EMPTY);
} else {
srcSlot.onSlotChanged();
}
srcSlot.onTake(player, srcStack);
return copyOfSrcStack;
}
示例2: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotIndex) {
ItemStack stack = ItemStack.EMPTY;
Slot srcSlot = inventorySlots.get(slotIndex);
if (srcSlot != null && srcSlot.getHasStack()) {
ItemStack stackInSlot = srcSlot.getStack();
stack = stackInSlot.copy();
if (slotIndex == 0) {
if (!mergeItemStack(stackInSlot, 1, 36, false)) return ItemStack.EMPTY;
srcSlot.onSlotChange(stackInSlot, stack);
} else if (isProgrammableItem(stack)) {
if (!mergeItemStack(stackInSlot, 0, 1, false)) return ItemStack.EMPTY;
srcSlot.onSlotChange(stackInSlot, stack);
}
if (stackInSlot.isEmpty()) {
srcSlot.putStack(ItemStack.EMPTY);
} else {
srcSlot.onSlotChanged();
}
if (stackInSlot.getCount() == stack.getCount()) return ItemStack.EMPTY;
srcSlot.onTake(par1EntityPlayer, stackInSlot);
}
return stack;
}
示例3: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) {
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(slotNumber);
if(slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
itemstack = slotStack.copy();
if(slotNumber == 0) {
if(!this.mergeItemStack(slotStack, 5, 41, true)) {
return null;
}
slot.onSlotChange(slotStack, itemstack);
} else if(!this.mergeItemStack(slotStack, 5, 41, false)) {
return null;
}
if(slotStack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if(slotStack.stackSize == itemstack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, slotStack);
}
return itemstack;
}
示例4: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
final Slot slot = inventorySlots.get(slotIndex);
ItemStack copy = ItemStack.EMPTY;
if (slot != null && slot.getHasStack()) {
final ItemStack original = slot.getStack();
copy = original.copy();
if (slotIndex == 0) {
if (!mergeItemStack(original, 5, 41, true)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
} else if (slotIndex > 5) {
if (original.getCount() == 1 && !mergeItemStack(original, 0, 5, false)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
} else {
if (!mergeItemStack(original, 5, 41, true)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
}
if (original.getCount() == 0) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
if (original.getCount() == copy.getCount()) return ItemStack.EMPTY;
slot.onTake(player, original);
}
return copy;
}
示例5: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
final Slot slot = inventorySlots.get(slotIndex);
ItemStack copy = ItemStack.EMPTY;
if (slot != null && slot.getHasStack()) {
final ItemStack original = slot.getStack();
copy = original.copy();
if (slotIndex == 0) {
if (!mergeItemStack(original, 19, 55, true)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
} else if (slotIndex > 19) {
if (original.getCount() == 1 && !mergeItemStack(original, 0, 1, false)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
} else {
if (!mergeItemStack(original, 19, 55, true)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
}
if (original.getCount() == 0) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
if (original.getCount() == copy.getCount()) return ItemStack.EMPTY;
slot.onTake(player, original);
}
return copy;
}
示例6: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
protected boolean transferStackInSlot(Slot slot, int index, ItemStack stack1, ItemStack stack)
{
if (isOutputSlot(index))
{
if (!this.mergeItemStack(stack1, type.getNumSlots(), type.getNumSlots() + 36, true))
return true;
slot.onSlotChange(stack1, stack);
} else if (!isInputSlot(index) && !isFuelSlot(index))
{
if (!FurnaceRecipes.instance().getSmeltingResult(stack1).isEmpty())
{
if (!this.mergeItemStack(stack1, 0, type.getFirstFuelSlot(), false))
return true;
} else if (TileEntityFurnace.isItemFuel(stack1))
{
if (!this.mergeItemStack(stack1, type.getFirstFuelSlot(), type.getFirstOutputSlot(0), false))
return true;
} else if (index >= type.getNumSlots() && index < type.getNumSlots() + 27)
{
if (!this.mergeItemStack(stack1, type.getNumSlots() + 27, type.getNumSlots() + 36, false))
return true;
} else if (index >= type.getNumSlots() + 27 && index < type.getNumSlots() + 36 && !this.mergeItemStack(stack1, type.getNumSlots(), type.getNumSlots() + 27, false))
return true;
} else if (!this.mergeItemStack(stack1, type.getNumSlots(), type.getNumSlots() + 36, false))
return true;
return false;
}
示例7: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
@Override
@Nullable
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 == 0) {
if (!this.mergeItemStack(itemstack1, 1, 28, true))
return ItemStack.EMPTY;
slot.onSlotChange(itemstack1, itemstack);
} else if (index >= 1 && index < 28) {
if (!this.mergeItemStack(itemstack1, 0, 1, false))
return ItemStack.EMPTY;
} else if (!this.mergeItemStack(itemstack1, 1, 28, false))
return ItemStack.EMPTY;
if (itemstack1.isEmpty())
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (itemstack1.getCount() ==itemstack.getCount())
return ItemStack.EMPTY;
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例8: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
{
ItemStack itemstackCopy = null;
Slot slot = (Slot)inventorySlots.get(slotId);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack = slot.getStack();
itemstackCopy = itemstack.copy();
if (slotId == SLOT_OUTPUT)
{
if (!mergeItemStack(itemstack, SLOT_PAN + 1, 39, true))
{
return null;
}
slot.onSlotChange(itemstack, itemstackCopy);
}
else if (slotId != SLOT_INPUT && slotId != SLOT_FUEL && slotId != SLOT_PAN)
{
if (itemstack.getItem() instanceof ItemPan)
{
if (!mergeItemStack(itemstack, SLOT_PAN, SLOT_PAN + 1, false))
{
return null;
}
}
else if (TileEntityCampfire.isItemFuel(itemstack))
{
if (!mergeItemStack(itemstack, SLOT_FUEL, SLOT_FUEL + 1, false))
{
return null;
}
}
else if (CampfireRecipeHandler.instance().getSmeltingResult(itemstack) != null)
{
if (!mergeItemStack(itemstack, SLOT_INPUT, SLOT_INPUT + 1, false))
{
return null;
}
}
else if (slotId > SLOT_OUTPUT && slotId < 30)
{
if (!mergeItemStack(itemstack, 30, 39, false))
{
return null;
}
}
else if (slotId >= 30 && slotId < 39 &&
!mergeItemStack(itemstack, SLOT_PAN + 1, 30, false))
{
return null;
}
}
else if (!mergeItemStack(itemstack, SLOT_PAN + 1, 39, false))
{
return null;
}
if (itemstack.getCount() == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (itemstack.getCount() == itemstackCopy.getCount())
{
return null;
}
slot.onTake(player, itemstack);
}
return itemstackCopy;
}
示例9: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int par2)
{
ItemStack itemstack = null;
Slot slot = (Slot)inventorySlots.get(par2);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par2 == 2)
{
if (!mergeItemStack(itemstack1, 3, 39, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (par2 != 1 && par2 != 0)
{
if (KilnRecipeHandler.instance().getSmeltingResult(itemstack1) != null)
{
if (!mergeItemStack(itemstack1, 0, 1, false))
{
return null;
}
}
else if (FuelRegistry.getBurnTime(FuelConsumerType.KILN, itemstack1) > 0)
{
if (!mergeItemStack(itemstack1, 1, 2, false))
{
return null;
}
}
else if (par2 >= 3 && par2 < 30)
{
if (!mergeItemStack(itemstack1, 30, 39, false))
{
return null;
}
}
else if (par2 >= 30 && par2 < 39 && !mergeItemStack(itemstack1, 3, 30, false))
{
return null;
}
}
else if (!mergeItemStack(itemstack1, 3, 39, false))
{
return null;
}
if (itemstack1.getCount() == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount())
{
return null;
}
slot.onTake(player, itemstack1);
}
return itemstack;
}
示例10: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < 9)
{
if (!this.mergeItemStack(itemstack1, 9, 45, true))
{
return ItemStack.EMPTY;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (index >= 9)
{
if (TileEntityFurnace.getItemBurnTime(itemstack1) > 0)
{
if (!this.mergeItemStack(itemstack1, 0, 9, false))
{
return ItemStack.EMPTY;
}
}
else if (index >= 9 && index < 36)
{
if (!this.mergeItemStack(itemstack1, 36, 45, false))
{
return ItemStack.EMPTY;
}
}
else if (index >= 36 && index < 45 && !this.mergeItemStack(itemstack1, 9, 36, false))
{
return ItemStack.EMPTY;
}
}
else if (!this.mergeItemStack(itemstack1, 9, 36, false))
{
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount())
{
return ItemStack.EMPTY;
}
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例11: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index == 1 || index == 2)
{
if (!this.mergeItemStack(itemstack1, 3, 39, true))
{
return ItemStack.EMPTY;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (index != 0)
{
if (itemstack1.getItem() instanceof ItemBlock)
{
for(ItemStack stack : ores)
if(OreDictionary.itemMatches(stack, itemstack1, false))
{
if (!this.mergeItemStack(itemstack1, 0, 1, false))
{
return ItemStack.EMPTY;
}
break;
}
}
else if (index >= 3 && index < 30)
{
if (!this.mergeItemStack(itemstack1, 30, 39, false))
{
return ItemStack.EMPTY;
}
}
else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
{
return ItemStack.EMPTY;
}
}
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount())
{
return ItemStack.EMPTY;
}
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例12: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index == 1)
{
if (!this.mergeItemStack(itemstack1, 2, 38, true))
{
return ItemStack.EMPTY;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (index != 0)
{
boolean flag = false;
int[] ids = OreDictionary.getOreIDs(itemstack1);
for(int id: ids)
if(OreDictionary.getOreName(id).contains("food")){
flag = true;
break;
}
if ((itemstack1.getItem() instanceof ItemFood || flag) && !FurnaceRecipes.instance().getSmeltingResult(itemstack1).isEmpty())
{
if (!this.mergeItemStack(itemstack1, 0, 1, false))
{
return ItemStack.EMPTY;
}
}
else if (index >= 2 && index < 29)
{
if (!this.mergeItemStack(itemstack1, 29, 38, false))
{
return ItemStack.EMPTY;
}
}
else if (index >= 29 && index < 38 && !this.mergeItemStack(itemstack1, 2, 29, false))
{
return ItemStack.EMPTY;
}
}
else if (!this.mergeItemStack(itemstack1, 2, 38, false))
{
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount())
{
return ItemStack.EMPTY;
}
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例13: 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, 3, 39, true)) {
return ItemStack.EMPTY;
}
slot.onSlotChange(itemstack1, itemstack);
} else if (index != 1 && index != 0) {
if (CraftiniumSmeltRegistry.findMatching(itemstack1, playerIn.world, this.forge) != null) {
if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
return ItemStack.EMPTY;
}
} else if (TileEntityFurnace.isItemFuel(itemstack1)) {
if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
return ItemStack.EMPTY;
}
} else if (index >= 3 && index < 30) {
if (!this.mergeItemStack(itemstack1, 30, 39, false)) {
return ItemStack.EMPTY;
}
} else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount()) {
return ItemStack.EMPTY;
}
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例14: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int fromId)
{
ItemStack movedStackDupe = null;
Slot slot = (Slot)inventorySlots.get(fromId);
if (slot != null && slot.getHasStack())
{
ItemStack movedStack = slot.getStack();
movedStackDupe = movedStack.copy();
if (fromId == TileEntitySmelter.OUTPUT)
{
if (!mergeItemStack(movedStack, 4, 40, true))
{
return null;
}
slot.onSlotChange(movedStack, movedStackDupe);
}
else if (fromId != TileEntitySmelter.FUEL && fromId != TileEntitySmelter.INPUT &&
fromId != TileEntitySmelter.BOOSTER)
{
if (SmelterRecipeHandler.instance().getSmeltingResult(movedStack) != null)
{
if (!mergeItemStack(movedStack, TileEntitySmelter.INPUT, TileEntitySmelter.INPUT + 1, false))
{
return null;
}
}
else if (movedStack.getItem() == Item.getItemFromBlock(Blocks.GRAVEL))
{
if (!mergeItemStack(movedStack, TileEntitySmelter.BOOSTER, TileEntitySmelter.BOOSTER + 1, false))
{
return null;
}
}
else if (FuelRegistry.getBurnTime(FuelConsumerType.SMELTER, movedStack) > 0)
{
if (!mergeItemStack(movedStack, TileEntitySmelter.FUEL, TileEntitySmelter.FUEL + 1, false))
{
return null;
}
}
else if (fromId >= 4 && fromId < 31)
{
if (!mergeItemStack(movedStack, 31, 40, false))
{
return null;
}
}
else if (fromId >= 31 && fromId < 40 && !mergeItemStack(movedStack, 4, 31, false))
{
return null;
}
}
else if (!mergeItemStack(movedStack, 4, 40, false))
{
return null;
}
if (movedStack.getCount() == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (movedStack.getCount() == movedStackDupe.getCount())
{
return null;
}
slot.onTake(player, movedStack);
}
return movedStackDupe;
}
示例15: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Called when a player shift-clicks on a slot. You must override this or
* you will crash when someone does that. I am not touching this code.
*/
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
{
ItemStack itemstack = null;
Slot slot = (Slot)inventorySlots.get(slotId);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (slotId == 0)
{
if (!mergeItemStack(itemstack1, 10, 46, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (slotId >= 10 && slotId < 37)
{
if (!mergeItemStack(itemstack1, 37, 46, false))
{
return null;
}
}
else if (slotId >= 37 && slotId < 46)
{
if (!mergeItemStack(itemstack1, 10, 37, false))
{
return null;
}
}
else if (!mergeItemStack(itemstack1, 10, 46, false))
{
return null;
}
if (itemstack1.getCount() == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount())
{
return null;
}
slot.onTake(player, itemstack1);
}
return itemstack;
}