本文整理汇总了Java中net.minecraft.inventory.Slot.onSlotChanged方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.onSlotChanged方法的具体用法?Java Slot.onSlotChanged怎么用?Java Slot.onSlotChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.Slot
的用法示例。
在下文中一共展示了Slot.onSlotChanged方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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(!mergeItemStack(itemstack1, 0, 1, false)){
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
示例2: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index)
{
Slot slot = this.inventorySlots.get(index);
if(slot == null || !slot.getHasStack())
return ItemStack.EMPTY;
ItemStack originalItem = slot.getStack();
ItemStack copyItem = originalItem.copy();
if(index >= 36) //Item is in our container, try placing in player's inventory.
{
if(!this.mergeItemStack(originalItem, 0, 36, true))
return ItemStack.EMPTY;
}
else
{
if(!this.mergeItemStack(originalItem, 36, this.inventorySlots.size(), false))
return ItemStack.EMPTY;
}
if(copyItem.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if(originalItem.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if(copyItem.getCount() == originalItem.getCount())
return ItemStack.EMPTY;
slot.onTake(player, copyItem);
return originalItem;
}
示例3: slotClickPhantom
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Nonnull
private ItemStack slotClickPhantom(Slot slot, int dragType, ClickType clickType, EntityPlayer player) {
ItemStack stack = ItemStack.EMPTY;
if (clickType == ClickType.CLONE && dragType == 2) {
// middle-click: clear slot
if (((IPhantomSlot) slot).canAdjust()) {
slot.putStack(ItemStack.EMPTY);
}
} else if ((clickType == ClickType.PICKUP || clickType == ClickType.QUICK_MOVE) && (dragType == 0 || dragType == 1)) {
// left or right-click...
InventoryPlayer playerInv = player.inventory;
slot.onSlotChanged();
ItemStack stackSlot = slot.getStack();
ItemStack stackHeld = playerInv.getItemStack();
stack = stackSlot.copy();
if (stackSlot.isEmpty()) {
if (!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) {
fillPhantomSlot(slot, stackHeld, clickType, dragType);
}
} else if (stackHeld.isEmpty()) {
adjustPhantomSlot(slot, clickType, dragType);
slot.onTake(player, playerInv.getItemStack());
} else if (slot.isItemValid(stackHeld)) {
if (canStacksMerge(stackSlot, stackHeld)) {
adjustPhantomSlot(slot, clickType, dragType);
} else {
fillPhantomSlot(slot, stackHeld, clickType, dragType);
}
}
}
return stack;
}
示例4: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
ItemStack previous = ItemStack.EMPTY;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack()) {
ItemStack current = slot.getStack();
previous = current.copy();
if (fromSlot < this.handler.getSlots()) {
// From the block breaker inventory to player's inventory
if (!this.mergeItemStack(current, handler.getSlots(), handler.getSlots() + 36, true))
return ItemStack.EMPTY;
} else {
// From the player's inventory to block breaker's inventory
if (current.getItem() == Items.ENCHANTED_BOOK) {
if (!this.mergeItemStack(current, 9, handler.getSlots(), false))
return ItemStack.EMPTY;
}
if (!this.mergeItemStack(current, 0, handler.getSlots(), false))
return ItemStack.EMPTY;
}
if (current.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (current.getCount() == previous.getCount())
return null;
slot.onTake(playerIn, current);
}
return previous;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int fromSlot)
{
ItemStack previous = null;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack())
{
ItemStack current = slot.getStack();
previous = current.copy();
// Custom behaviour //
if (fromSlot < 3)
{
// From TE Inventory to Player Inventory
if (!this.mergeItemStack(current, startPlayerIndex, endPlayerIndex, true))
return null;
}
else
{
// From Player Inventory to TE Inventory
if (!this.mergeItemStack(current, startContainerIndex, endContainerIndex, false))
return null;
}
// Custom behaviour //
if (current.stackSize == 0)
slot.putStack(null);
else
slot.onSlotChanged();
if (current.stackSize == previous.stackSize)
return null;
slot.onPickupFromSlot(entityPlayer, current);
}
return previous;
}
示例9: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
@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 < this.villagerInventory.getSizeInventory())
{
if (!this.mergeItemStack(itemstack1, this.villagerInventory.getSizeInventory(), this.inventorySlots.size(), true))
{
return ItemStack.EMPTY;
}
}
else if (!this.mergeItemStack(itemstack1, 0, this.villagerInventory.getSizeInventory(), false))
{
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
}
return itemstack;
}
示例10: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
@Nonnull
public ItemStack transferStackInSlot (EntityPlayer player, int slotIndex) {
@Nonnull ItemStack itemStack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(slotIndex);
// Assume inventory and hotbar slot IDs are contiguous
int inventoryStart = playerSlots.get(0).slotNumber;
int hotbarStart = hotbarSlots.get(0).slotNumber;
int hotbarEnd = hotbarSlots.get(hotbarSlots.size() - 1).slotNumber + 1;
if (slot != null && slot.getHasStack()) {
@Nonnull ItemStack slotStack = slot.getStack();
itemStack = slotStack.copy();
// Try merge output into inventory and signal change
if (slotIndex == outputSlot.slotNumber) {
if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, true))
return ItemStack.EMPTY;
slot.onSlotChange(slotStack, itemStack);
}
// Try merge stacks within inventory and hotbar spaces
else if (slotIndex >= inventoryStart && slotIndex < hotbarEnd) {
boolean merged = false;
if (TileBloomeryFurnace.isItemFuel(slotStack))
merged = mergeItemStack(slotStack, fuelSlot.slotNumber, fuelSlot.slotNumber + 1, false);
else if (TileBloomeryFurnace.isItemPrimaryInput(slotStack))
merged = mergeItemStack(slotStack, primarySlot.slotNumber, primarySlot.slotNumber + 1, false);
else if (TileBloomeryFurnace.isItemSecondaryInput(slotStack))
merged = mergeItemStack(slotStack, secondarySlot.slotNumber, secondarySlot.slotNumber + 1, false);
if (!merged) {
if (slotIndex >= inventoryStart && slotIndex < hotbarStart) {
if (!mergeItemStack(slotStack, hotbarStart, hotbarEnd, false))
return ItemStack.EMPTY;
} else if (slotIndex >= hotbarStart && slotIndex < hotbarEnd && !this.mergeItemStack(slotStack, inventoryStart, hotbarStart, false))
return ItemStack.EMPTY;
}
}
// Try merge stack into inventory
else if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, false))
return ItemStack.EMPTY;
if (slotStack.isEmpty())
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (slotStack.getCount() == itemStack.getCount())
return ItemStack.EMPTY;
slot.onTake(player, slotStack);
}
return itemStack;
}
示例11: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
Slot slot = inventorySlots.get(index);
if (slot == null || !slot.getHasStack())
{
return null;
}
ItemStack newStack = slot.getStack(), oldStack = newStack.copy();
boolean isMerged = false;
if (index >= 0 && index <= 2)
{
isMerged = mergeItemStack(newStack, 3, 39, true);
}else if (index >= 3 && index < 30)
{
isMerged = ! betterySlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
|| !filmSlot.getHasStack() && mergeItemStack(newStack, 1, 2, false)
|| mergeItemStack(newStack, 30, 39, false);
}else if (index >= 30 && index < 39)
{
isMerged = !betterySlot.getHasStack()&& newStack.stackSize <= 1&& mergeItemStack(newStack, 0, 1, false)
|| !filmSlot.getHasStack() && mergeItemStack(newStack, 1, 2, false)
|| mergeItemStack(newStack, 3, 30, false);
}
if (!isMerged)
{
return null;
}
if (newStack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
slot.onPickupFromSlot(playerIn, newStack);
return oldStack;
}
示例12: 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;
}
示例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();
boolean changed = false;
if (index >= 0 && index < 36) {
if(this.mergeItemStack(itemstack1, 36, inventorySlots.size(), false)) {
changed = true;
}
}
if(!changed) {
if (index >= 0 && index < 27) {
if (!this.mergeItemStack(itemstack1, 27, 36, false)) {
return ItemStack.EMPTY;
}
} else if (index >= 27 && index < 36) {
if (!this.mergeItemStack(itemstack1, 0, 27, false)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemstack1, 0, 36, false)) {
return ItemStack.EMPTY;
}
}
if (itemstack1.getCount() == 0) {
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包/类
/**
* 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;
}
示例15: 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;
}