- 86
- 0
По какому принципу переписывать transferStackInSlot? Нужно ли переписывать mergeItemStack? если да то зачем и как?
Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if (slot < 10) {
if (!this.mergeItemStack(stackInSlot, 0, 35, true)) {
return null;
}
}
else
{
if(stackInSlot.getItem() == ItemList.ItemUbgreyd)
{
if(!this.mergeItemStack(stackInSlot, 5, 9, false))
{
return null;
}
}
else if(stackInSlot.getItem() == ItemList.ItemPowerStorege)
{
if(!this.mergeItemStack(stackInSlot, 0, 1, false))
{
return null;
}
}
else
{
if(FluidContainerRegistry.isFilledContainer(stackInSlot))
{
if(!this.mergeItemStack(stackInSlot, 1, 3, false))
{
return null;
}
}
}
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack(null);
} else {
slotObject.onSlotChanged();
}
if (stackInSlot.stackSize == stack.stackSize) {
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if (slot < 10) {
if (!this.mergeItemStack(stackInSlot, 10, 36 + 10, true)) {
return null;
}
slotObject.onSlotChange(stack, stackInSlot); //Решение проблемы
}
else
{
if(stackInSlot.getItem() == ItemList.ItemUbgreyd)
{
if(!this.mergeItemStack(stackInSlot, 5, 9, false))
{
return null;
}
}
else if(stackInSlot.getItem() instanceof IBCEnergyStorageItem)
{
if(!this.mergeItemStack(stackInSlot, 0, 1, false))
{
return null;
}
}
else
{
if(FluidContainerRegistry.isFilledContainer(stackInSlot))
{
if(!this.mergeItemStack(stackInSlot, 1, 3, false))
{
return null;
}
}
}
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack(null);
} else {
slotObject.onSlotChanged();
}
if (stackInSlot.stackSize == stack.stackSize) {
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}