Improve specimen behaviour, fixes #486
This commit is contained in:
@@ -54,30 +54,28 @@ public abstract class ContainerBase extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack slotClick(int id, int clickedButton, ClickType clickType, EntityPlayer player) {
|
public ItemStack slotClick(int id, int dragType, ClickType clickType, EntityPlayer player) {
|
||||||
Slot slot = id >= 0 ? getSlot(id) : null;
|
Slot slot = id >= 0 ? getSlot(id) : null;
|
||||||
|
|
||||||
if (slot instanceof SlotSpecimen) {
|
if (slot instanceof SlotSpecimen) {
|
||||||
if (((SlotSpecimen) slot).isWithSize()) {
|
if (((SlotSpecimen) slot).isWithSize()) {
|
||||||
if (slot.getStack() != null) {
|
|
||||||
if (clickType == ClickType.QUICK_MOVE) {
|
if (clickType == ClickType.QUICK_MOVE) {
|
||||||
slot.putStack(null);
|
slot.putStack(null);
|
||||||
} else {
|
} else if (player.inventory.getItemStack() != null) {
|
||||||
|
int amount = player.inventory.getItemStack().stackSize;
|
||||||
|
|
||||||
|
slot.putStack(ItemHandlerHelper.copyStackWithSize(player.inventory.getItemStack(), amount));
|
||||||
|
} else if (slot.getHasStack()) {
|
||||||
int amount = slot.getStack().stackSize;
|
int amount = slot.getStack().stackSize;
|
||||||
|
|
||||||
if (clickedButton == 0) {
|
if (dragType == 0) {
|
||||||
amount = Math.max(1, amount - 1);
|
amount = Math.max(1, amount - 1);
|
||||||
} else if (clickedButton == 1) {
|
} else if (dragType == 1) {
|
||||||
amount = Math.min(64, amount + 1);
|
amount = Math.min(64, amount + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
slot.getStack().stackSize = amount;
|
slot.getStack().stackSize = amount;
|
||||||
}
|
}
|
||||||
} else if (player.inventory.getItemStack() != null) {
|
|
||||||
int amount = player.inventory.getItemStack().stackSize;
|
|
||||||
|
|
||||||
slot.putStack(ItemHandlerHelper.copyStackWithSize(player.inventory.getItemStack(), clickedButton == 1 ? 1 : amount));
|
|
||||||
}
|
|
||||||
} else if (player.inventory.getItemStack() == null) {
|
} else if (player.inventory.getItemStack() == null) {
|
||||||
slot.putStack(null);
|
slot.putStack(null);
|
||||||
} else if (slot.isItemValid(player.inventory.getItemStack())) {
|
} else if (slot.isItemValid(player.inventory.getItemStack())) {
|
||||||
@@ -97,7 +95,7 @@ public abstract class ContainerBase extends Container {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.slotClick(id, clickedButton, clickType, player);
|
return super.slotClick(id, dragType, clickType, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -36,7 +36,15 @@ public class SlotSpecimen extends SlotItemHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack) {
|
public boolean isItemValid(ItemStack stack) {
|
||||||
return super.isItemValid(stack) && (isBlockOnly() ? (stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlockSpecial || stack.getItem() instanceof IPlantable || stack.getItem() instanceof ItemSkull) : true);
|
if (super.isItemValid(stack)) {
|
||||||
|
if (isBlockOnly()) {
|
||||||
|
return stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlockSpecial || stack.getItem() instanceof IPlantable || stack.getItem() instanceof ItemSkull;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user