Fix more bugs
This commit is contained in:
@@ -11,6 +11,8 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class ContainerBase extends Container {
|
||||
private TileBase tile;
|
||||
private EntityPlayer player;
|
||||
@@ -58,7 +60,7 @@ public abstract class ContainerBase extends Container {
|
||||
Slot slot = id >= 0 ? getSlot(id) : null;
|
||||
|
||||
if (slot instanceof SlotFilter) {
|
||||
if (((SlotFilter) slot).isWithSize()) {
|
||||
if (((SlotFilter) slot).allowsSize()) {
|
||||
if (clickType == ClickType.QUICK_MOVE) {
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else if (!player.inventory.getItemStack().isEmpty()) {
|
||||
@@ -106,14 +108,14 @@ public abstract class ContainerBase extends Container {
|
||||
protected ItemStack mergeItemStackToSpecimen(ItemStack stack, int begin, int end) {
|
||||
for (int i = begin; i < end; ++i) {
|
||||
if (API.instance().getComparer().isEqualNoQuantity(getStackFromSlot(getSlot(i)), stack)) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = begin; i < end; ++i) {
|
||||
Slot slot = getSlot(i);
|
||||
|
||||
if (getStackFromSlot(slot) == null && slot.isItemValid(stack)) {
|
||||
if (getStackFromSlot(slot).isEmpty() && slot.isItemValid(stack)) {
|
||||
slot.putStack(ItemHandlerHelper.copyStackWithSize(stack, 1));
|
||||
slot.onSlotChanged();
|
||||
|
||||
@@ -124,6 +126,7 @@ public abstract class ContainerBase extends Container {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private ItemStack getStackFromSlot(Slot slot) {
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ContainerInterface extends ContainerBase {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotFilter(tile.getExportSpecimenItems(), i, 8 + (18 * i), 54, SlotFilter.SPECIMEN_SIZE));
|
||||
addSlotToContainer(new SlotFilter(tile.getExportSpecimenItems(), i, 8 + (18 * i), 54, SlotFilter.FILTER_ALLOW_SIZE));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ContainerProcessingPatternEncoder extends ContainerBase {
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 9 * 2; ++i) {
|
||||
addSlotToContainer(new SlotFilter(encoder.getConfiguration(), i, x, y, SlotFilter.SPECIMEN_SIZE));
|
||||
addSlotToContainer(new SlotFilter(encoder.getConfiguration(), i, x, y, SlotFilter.FILTER_ALLOW_SIZE));
|
||||
|
||||
x += 18;
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class SlotFilter extends SlotItemHandler {
|
||||
public static final int SPECIMEN_SIZE = 1;
|
||||
public static final int SPECIMEN_BLOCK = 2;
|
||||
public static final int FILTER_ALLOW_SIZE = 1;
|
||||
public static final int FILTER_ALLOW_BLOCKS = 2;
|
||||
|
||||
private int flags = 0;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SlotFilter extends SlotItemHandler {
|
||||
@Override
|
||||
public boolean isItemValid(@Nonnull ItemStack stack) {
|
||||
if (super.isItemValid(stack)) {
|
||||
if (isBlockOnly()) {
|
||||
if (allowsBlocks()) {
|
||||
return stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlockSpecial || stack.getItem() instanceof IPlantable || stack.getItem() instanceof ItemSkull;
|
||||
}
|
||||
|
||||
@@ -50,19 +50,19 @@ public class SlotFilter extends SlotItemHandler {
|
||||
|
||||
@Override
|
||||
public void putStack(@Nonnull ItemStack stack) {
|
||||
if (!stack.isEmpty() && !isWithSize()) {
|
||||
if (!stack.isEmpty() && !allowsSize()) {
|
||||
stack.setCount(1);
|
||||
}
|
||||
|
||||
super.putStack(stack);
|
||||
}
|
||||
|
||||
public boolean isWithSize() {
|
||||
return (flags & SPECIMEN_SIZE) == SPECIMEN_SIZE;
|
||||
public boolean allowsSize() {
|
||||
return (flags & FILTER_ALLOW_SIZE) == FILTER_ALLOW_SIZE;
|
||||
}
|
||||
|
||||
public boolean isBlockOnly() {
|
||||
return (flags & SPECIMEN_BLOCK) == SPECIMEN_BLOCK;
|
||||
public boolean allowsBlocks() {
|
||||
return (flags & FILTER_ALLOW_BLOCKS) == FILTER_ALLOW_BLOCKS;
|
||||
}
|
||||
|
||||
public static IBlockState getBlockState(IBlockAccess world, BlockPos pos, ItemStack stack) {
|
||||
|
||||
@@ -26,13 +26,13 @@ public class SlotFilterType extends SlotFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithSize() {
|
||||
return super.isWithSize() && type.getType() != IType.FLUIDS;
|
||||
public boolean allowsSize() {
|
||||
return super.allowsSize() && type.getType() != IType.FLUIDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockOnly() {
|
||||
return super.isBlockOnly() && type.getType() == IType.ITEMS;
|
||||
public boolean allowsBlocks() {
|
||||
return super.allowsBlocks() && type.getType() == IType.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user