some things

This commit is contained in:
ProfessorProspector 2017-01-07 00:02:57 -08:00
parent 9f74feabff
commit 0f172ddf52
17 changed files with 89 additions and 44 deletions

View file

@ -8,15 +8,9 @@ import techreborn.lib.ModInfo;
public class ArmorSlot extends FilteredSlot {
public ArmorSlot(final EntityEquipmentSlot armorType, final InventoryPlayer inventory, final int index,
final int xPosition, final int yPosition) {
public ArmorSlot(final EntityEquipmentSlot armorType, final InventoryPlayer inventory, final int index, final int xPosition, final int yPosition) {
super(inventory, index, xPosition, yPosition);
this.setFilter(stack -> stack != null && stack.getItem().isValidArmor(stack, armorType, inventory.player));
this.setBackgroundLocation(
new ResourceLocation(ModInfo.MOD_ID, "textures/gui/slots/armor_" + armorType.getName() + ".png"));
}
@Override

View file

@ -2,25 +2,15 @@ package techreborn.client.container.builder.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.energy.CapabilityEnergy;
import reborncore.api.power.IEnergyInterfaceItem;
import techreborn.lib.ModInfo;
public class EnergyChargeSlot extends FilteredSlot {
private static final ResourceLocation TEX = new ResourceLocation(ModInfo.MOD_ID,
"textures/gui/slots/energy_charge.png");
@SuppressWarnings("null")
public EnergyChargeSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition) {
super(inventory, index, xPosition, yPosition);
this.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)
|| stack.getItem() instanceof IEnergyInterfaceItem);
this.setBackgroundLocation(EnergyChargeSlot.TEX);
this.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP) || stack.getItem() instanceof IEnergyInterfaceItem);
}
}

View file

@ -21,6 +21,10 @@ public class FilteredSlot extends Slot {
@Override
public boolean isItemValid(final ItemStack stack) {
return this.filter.test(stack);
try {
return this.filter.test(stack);
} catch (NullPointerException e) {
return true;
}
}
}

View file

@ -0,0 +1,25 @@
package techreborn.client.container.builder.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import techreborn.lib.ModInfo;
public class SpriteSlot extends FilteredSlot {
int stacksize;
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, String sprite, int stacksize) {
super(inventory, index, xPosition, yPosition);
this.setBackgroundLocation(new ResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":textures/gui/slot_sprites/" + sprite + ".png"));
this.stacksize = stacksize;
}
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, String sprite) {
this(inventory, index, xPosition, yPosition, sprite, 64);
}
@Override
public int getSlotStackLimit() {
return stacksize;
}
}