This commit is contained in:
Raoul Van den Berge
2016-05-05 14:22:45 +02:00
parent 84bef30003
commit e67cced0ed
3 changed files with 26 additions and 4 deletions

View File

@@ -3,8 +3,6 @@ package refinedstorage.container.slot;
import net.minecraft.item.ItemStack;
import refinedstorage.RefinedStorageItems;
import java.util.Arrays;
public class UpgradeItemValidator implements IItemValidator {
private int[] allowedUpgrades;
@@ -14,6 +12,14 @@ public class UpgradeItemValidator implements IItemValidator {
@Override
public boolean isValid(ItemStack stack) {
return stack.getItem() == RefinedStorageItems.UPGRADE && Arrays.asList(allowedUpgrades).contains(stack.getMetadata());
if (stack.getItem() == RefinedStorageItems.UPGRADE) {
for (int upgrade : allowedUpgrades) {
if (upgrade == stack.getMetadata()) {
return true;
}
}
}
return false;
}
}

View File

@@ -133,7 +133,7 @@ public class ItemWirelessGrid extends ItemEnergyContainer {
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (!world.isRemote && getDimensionId(stack) == player.dimension) {
if (!world.isRemote && hasValidNBT(stack) && getDimensionId(stack) == player.dimension) {
TileEntity tile = world.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)));
if (tile instanceof TileController) {
@@ -191,6 +191,22 @@ public class ItemWirelessGrid extends ItemEnergyContainer {
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
if (oldStack.getItem() == newStack.getItem()) {
if (hasValidNBT(oldStack) && hasValidNBT(newStack)) {
int x1 = getX(oldStack);
int y1 = getY(oldStack);
int z1 = getZ(oldStack);
int dim1 = getDimensionId(oldStack);
int x2 = getX(newStack);
int y2 = getY(newStack);
int z2 = getZ(newStack);
int dim2 = getDimensionId(newStack);
if (x1 == x2 && y1 == y2 && z1 == z2 && dim1 == dim2) {
return false;
}
}
}
return slotChanged;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB