Fixed equipment slot in energizer and enervator being off

This commit is contained in:
Ellpeck 2016-05-03 08:45:01 +02:00
parent d6bc78fffb
commit 6e18866c79
6 changed files with 28 additions and 26 deletions

View file

@ -18,6 +18,7 @@ import invtweaks.api.container.InventoryContainer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -27,9 +28,10 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@InventoryContainer @InventoryContainer
public class ContainerEnergizer extends Container{ public class ContainerEnergizer extends Container{
public static final EntityEquipmentSlot[] VALID_EQUIPMENT_SLOTS = new EntityEquipmentSlot[] {EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};
private TileEntityEnergizer energizer; private TileEntityEnergizer energizer;
public ContainerEnergizer(EntityPlayer player, TileEntityBase tile){ public ContainerEnergizer(final EntityPlayer player, TileEntityBase tile){
this.energizer = (TileEntityEnergizer)tile; this.energizer = (TileEntityEnergizer)tile;
InventoryPlayer inventory = player.inventory; InventoryPlayer inventory = player.inventory;
@ -44,24 +46,24 @@ public class ContainerEnergizer extends Container{
for(int i = 0; i < 9; i++){ for(int i = 0; i < 9; i++){
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155));
} }
final EntityPlayer finalPlayer = player;
for(int i = 0; i < 4; ++i){
final int finalI = i;
this.addSlotToContainer(new Slot(inventory, inventory.getSizeInventory()-1-i, 102, 19+i*18){
@Override
public boolean isItemValid(ItemStack stack){
return stack != null && stack.getItem().isValidArmor(stack, ContainerEnervator.ARMOR_SLOTS[finalI], finalPlayer);
}
for(int k = 0; k < 4; ++k){
final EntityEquipmentSlot slot = VALID_EQUIPMENT_SLOTS[k];
this.addSlotToContainer(new Slot(player.inventory, 36+(3-k), 102, 19+k*18){
@Override @Override
public int getSlotStackLimit(){ public int getSlotStackLimit(){
return 1; return 1;
} }
@Override
public boolean isItemValid(ItemStack stack){
return stack != null && stack.getItem().isValidArmor(stack, slot, player);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public String getSlotTexture(){ public String getSlotTexture(){
return ItemArmor.EMPTY_SLOT_NAMES[finalI]; return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
} }
}); });
} }
@ -74,7 +76,7 @@ public class ContainerEnergizer extends Container{
final int hotbarStart = inventoryEnd+1; final int hotbarStart = inventoryEnd+1;
final int hotbarEnd = hotbarStart+8; final int hotbarEnd = hotbarStart+8;
Slot theSlot = (Slot)this.inventorySlots.get(slot); Slot theSlot = this.inventorySlots.get(slot);
if(theSlot != null && theSlot.getHasStack()){ if(theSlot != null && theSlot.getHasStack()){
ItemStack newStack = theSlot.getStack(); ItemStack newStack = theSlot.getStack();

View file

@ -28,10 +28,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@InventoryContainer @InventoryContainer
public class ContainerEnervator extends Container{ public class ContainerEnervator extends Container{
public static final EntityEquipmentSlot[] ARMOR_SLOTS = new EntityEquipmentSlot[]{EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};
private TileEntityEnervator enervator; private TileEntityEnervator enervator;
public ContainerEnervator(EntityPlayer player, TileEntityBase tile){ public ContainerEnervator(final EntityPlayer player, TileEntityBase tile){
this.enervator = (TileEntityEnervator)tile; this.enervator = (TileEntityEnervator)tile;
InventoryPlayer inventory = player.inventory; InventoryPlayer inventory = player.inventory;
@ -46,24 +45,24 @@ public class ContainerEnervator extends Container{
for(int i = 0; i < 9; i++){ for(int i = 0; i < 9; i++){
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155));
} }
final EntityPlayer finalPlayer = player;
for(int i = 0; i < 4; ++i){
final int finalI = i;
this.addSlotToContainer(new Slot(inventory, inventory.getSizeInventory()-1-i, 102, 19+i*18){
@Override
public boolean isItemValid(ItemStack stack){
return stack != null && stack.getItem().isValidArmor(stack, ARMOR_SLOTS[finalI], finalPlayer);
}
for(int k = 0; k < 4; ++k){
final EntityEquipmentSlot slot = ContainerEnergizer.VALID_EQUIPMENT_SLOTS[k];
this.addSlotToContainer(new Slot(player.inventory, 36+(3-k), 102, 19+k*18){
@Override @Override
public int getSlotStackLimit(){ public int getSlotStackLimit(){
return 1; return 1;
} }
@Override
public boolean isItemValid(ItemStack stack){
return stack != null && stack.getItem().isValidArmor(stack, slot, player);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public String getSlotTexture(){ public String getSlotTexture(){
return ItemArmor.EMPTY_SLOT_NAMES[finalI]; return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
} }
}); });
} }

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.items.base; package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnergizer;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnervator; import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnervator;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
@ -30,7 +31,7 @@ public class ItemArmorAA extends ItemArmor{
} }
public ItemArmorAA(String name, ArmorMaterial material, int type, ItemStack repairItem, EnumRarity rarity){ public ItemArmorAA(String name, ArmorMaterial material, int type, ItemStack repairItem, EnumRarity rarity){
super(material, 0, ContainerEnervator.ARMOR_SLOTS[type]); super(material, 0, ContainerEnergizer.VALID_EQUIPMENT_SLOTS[type]);
this.repairItem = repairItem; this.repairItem = repairItem;
this.name = name; this.name = name;
this.rarity = rarity; this.rarity = rarity;

View file

@ -19,7 +19,7 @@ import java.util.Properties;
public class ThreadSpecialFetcher extends Thread{ public class ThreadSpecialFetcher extends Thread{
public ThreadSpecialFetcher(){ public ThreadSpecialFetcher(){
this.setName(ModUtil.MOD_ID+" Special Fetcher"); this.setName(ModUtil.NAME+" Special Fetcher");
this.setDaemon(true); this.setDaemon(true);
this.start(); this.start();
} }

View file

@ -20,7 +20,7 @@ import java.util.Properties;
public class ThreadUpdateChecker extends Thread{ public class ThreadUpdateChecker extends Thread{
public ThreadUpdateChecker(){ public ThreadUpdateChecker(){
this.setName(ModUtil.MOD_ID+" Update Checker"); this.setName(ModUtil.NAME+" Update Checker");
this.setDaemon(true); this.setDaemon(true);
this.start(); this.start();
} }

View file

@ -4,7 +4,7 @@
"model": "minecraft:cube_bottom_top", "model": "minecraft:cube_bottom_top",
"textures": { "textures": {
"side": "actuallyadditions:blocks/blockHeatCollectorSide", "side": "actuallyadditions:blocks/blockHeatCollectorSide",
"bottom": "actuallyadditions:blocks/blockHeatCollector", "bottom": "actuallyadditions:blocks/blockHeatCollectorBottom",
"top": "actuallyadditions:blocks/blockHeatCollectorTop" "top": "actuallyadditions:blocks/blockHeatCollectorTop"
}, },
"transform": "forge:default-block" "transform": "forge:default-block"