This commit is contained in:
modmuss50 2017-12-17 21:43:12 +00:00
parent 7f289e2356
commit ee075feea9
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
3 changed files with 26 additions and 16 deletions

View file

@ -32,19 +32,31 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class IconSupplier {
public static String armour_head_name = "techreborn:gui/slot_sprites/armour_head";
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite armour_head;
public static String armour_chest_name = "techreborn:gui/slot_sprites/armour_chest";
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite armour_chest;
public static String armour_legs_name = "techreborn:gui/slot_sprites/armour_legs";
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite armour_legs;
public static String armour_feet_name = "techreborn:gui/slot_sprites/armour_feet";
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite armour_feet;
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void preTextureStitch(TextureStitchEvent.Pre event) {
TextureMap map = event.getMap();
armour_head = map.registerSprite(new ResourceLocation("techreborn:gui/slot_sprites/armour_head"));
armour_chest = map.registerSprite(new ResourceLocation("techreborn:gui/slot_sprites/armour_chest"));
armour_legs = map.registerSprite(new ResourceLocation("techreborn:gui/slot_sprites/armour_legs"));
armour_feet = map.registerSprite(new ResourceLocation("techreborn:gui/slot_sprites/armour_feet"));
armour_head = map.registerSprite(new ResourceLocation(armour_head_name));
armour_chest = map.registerSprite(new ResourceLocation(armour_chest_name));
armour_legs = map.registerSprite(new ResourceLocation(armour_legs_name));
armour_feet = map.registerSprite(new ResourceLocation(armour_feet_name));
}
}

View file

@ -24,7 +24,6 @@
package techreborn.client.container.builder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import org.apache.commons.lang3.Range;
@ -95,26 +94,26 @@ public final class ContainerPlayerInventoryBuilder {
}
private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart,
final EntityEquipmentSlot slotType, final TextureAtlasSprite sprite) {
final EntityEquipmentSlot slotType, final String sprite) {
this.parent.parent.slots.add(new SpriteSlot(this.parent.player, index, xStart, yStart, sprite, 1)
.setFilter(stack -> stack.getItem().isValidArmor(stack, slotType, this.parent.player.player)));
return this;
}
public ContainerPlayerArmorInventoryBuilder helmet(final int xStart, final int yStart) {
return this.armor(this.parent.player.getSizeInventory() - 2, xStart, yStart, EntityEquipmentSlot.HEAD, IconSupplier.armour_head);
return this.armor(this.parent.player.getSizeInventory() - 2, xStart, yStart, EntityEquipmentSlot.HEAD, IconSupplier.armour_head_name);
}
public ContainerPlayerArmorInventoryBuilder chestplate(final int xStart, final int yStart) {
return this.armor(this.parent.player.getSizeInventory() - 3, xStart, yStart, EntityEquipmentSlot.CHEST, IconSupplier.armour_chest);
return this.armor(this.parent.player.getSizeInventory() - 3, xStart, yStart, EntityEquipmentSlot.CHEST, IconSupplier.armour_chest_name);
}
public ContainerPlayerArmorInventoryBuilder leggings(final int xStart, final int yStart) {
return this.armor(this.parent.player.getSizeInventory() - 4, xStart, yStart, EntityEquipmentSlot.LEGS, IconSupplier.armour_legs);
return this.armor(this.parent.player.getSizeInventory() - 4, xStart, yStart, EntityEquipmentSlot.LEGS, IconSupplier.armour_legs_name);
}
public ContainerPlayerArmorInventoryBuilder boots(final int xStart, final int yStart) {
return this.armor(this.parent.player.getSizeInventory() - 5, xStart, yStart, EntityEquipmentSlot.FEET, IconSupplier.armour_feet);
return this.armor(this.parent.player.getSizeInventory() - 5, xStart, yStart, EntityEquipmentSlot.FEET, IconSupplier.armour_feet_name);
}
public ContainerPlayerArmorInventoryBuilder complete(final int xStart, final int yStart) {

View file

@ -24,7 +24,6 @@
package techreborn.client.container.builder.slot;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -35,13 +34,13 @@ public class SpriteSlot extends FilteredSlot {
private final String spriteName;
int stacksize;
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final TextureAtlasSprite sprite, final int stacksize) {
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite, final int stacksize) {
super(inventory, index, xPosition, yPosition);
this.spriteName = sprite.getIconName();
this.spriteName = sprite;
this.stacksize = stacksize;
}
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final TextureAtlasSprite sprite) {
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite) {
this(inventory, index, xPosition, yPosition, sprite, 64);
}