mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
more armor mod stuff
This commit is contained in:
parent
14ac7e644e
commit
39a77a67d8
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.9 KiB |
BIN
src/main/java/assets/hbm/textures/items/insert_esapi.png
Normal file
BIN
src/main/java/assets/hbm/textures/items/insert_esapi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 221 B |
BIN
src/main/java/assets/hbm/textures/items/insert_kevlar.png
Normal file
BIN
src/main/java/assets/hbm/textures/items/insert_kevlar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 334 B |
BIN
src/main/java/assets/hbm/textures/items/insert_sapi.png
Normal file
BIN
src/main/java/assets/hbm/textures/items/insert_sapi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 B |
BIN
src/main/java/assets/hbm/textures/items/insert_xsapi.png
Normal file
BIN
src/main/java/assets/hbm/textures/items/insert_xsapi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 257 B |
@ -1,5 +1,10 @@
|
||||
package com.hbm.handler;
|
||||
|
||||
import com.hbm.items.armor.ItemArmorMod;
|
||||
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ArmorModHandler {
|
||||
|
||||
public static final int helmet_only = 0;
|
||||
@ -10,5 +15,22 @@ public class ArmorModHandler {
|
||||
public static final int cladding = 5;
|
||||
public static final int kevlar = 6;
|
||||
public static final int plating = 7;
|
||||
|
||||
|
||||
public static boolean isApplicable(ItemStack armor, ItemStack mod) {
|
||||
|
||||
if(armor == null || mod == null)
|
||||
return false;
|
||||
|
||||
if(!(armor.getItem() instanceof ItemArmor))
|
||||
return false;
|
||||
|
||||
if(!(mod.getItem() instanceof ItemArmorMod))
|
||||
return false;
|
||||
|
||||
int type = ((ItemArmor)armor.getItem()).armorType;
|
||||
|
||||
ItemArmorMod aMod = (ItemArmorMod)mod.getItem();
|
||||
|
||||
return (type == 0 && aMod.helmet) || (type == 1 && aMod.chestplate) || (type == 2 && aMod.leggings) || (type == 3 && aMod.boots);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,24 @@ public class ContainerArmorTable extends Container {
|
||||
|
||||
public ContainerArmorTable(InventoryPlayer inventory) {
|
||||
|
||||
resetSlots();
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.helmet_only, 26, 27)); // helmet only
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.plate_only, 62, 27)); // chestplate only
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.legs_only, 98, 27)); // leggins only
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.boots_only, 134, 45)); // boots only
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.servos, 134, 81)); //servos/frame
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.cladding, 98, 99)); //radiation cladding
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.kevlar, 62, 99)); //kevlar/sapi/(ERA? :) )
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.plating, 26, 99)); //explosive/heavy plating
|
||||
|
||||
this.addSlotToContainer(new Slot(armor, 0, 44, 63) {
|
||||
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemArmor;
|
||||
}
|
||||
|
||||
public void onSlotChanged() {
|
||||
}
|
||||
});
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
@ -34,6 +51,8 @@ public class ContainerArmorTable extends Container {
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142 + 56));
|
||||
}
|
||||
|
||||
this.onCraftMatrixChanged(this.upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,62 +60,28 @@ public class ContainerArmorTable extends Container {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetSlots() {
|
||||
|
||||
//this.inventorySlots.clear();
|
||||
//this.inventoryItemStacks.clear();
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
|
||||
this.addSlotToContainer(new Slot(armor, 0, 44, 36) {
|
||||
if(!player.worldObj.isRemote) {
|
||||
for(int i = 0; i < this.upgrades.getSizeInventory(); ++i) {
|
||||
ItemStack itemstack = this.upgrades.getStackInSlotOnClosing(i);
|
||||
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemArmor;
|
||||
if(itemstack != null) {
|
||||
player.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSlotChanged() {
|
||||
resetSlots();
|
||||
}
|
||||
});
|
||||
|
||||
ItemStack armor = this.armor.getStackInSlot(0);
|
||||
|
||||
if(armor != null && armor.getItem() instanceof ItemArmor) {
|
||||
|
||||
ItemArmor item = (ItemArmor) armor.getItem();
|
||||
|
||||
if(item.armorType == 0) {
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.helmet_only, 26, 27)); // helmet only
|
||||
}
|
||||
|
||||
if(item.armorType == 1) {
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.plate_only, 62, 27)); // chestplate only
|
||||
}
|
||||
if(item.armorType == 2) {
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.legs_only, 98, 27)); // leggins only
|
||||
}
|
||||
if(item.armorType == 3) {
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.boots_only, 134, 45)); // boots only
|
||||
}
|
||||
|
||||
if(item.armorType == 2 || item.armorType == 3) {
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.servos, 134, 81)); //servos/frame
|
||||
}
|
||||
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.cladding, 98, 99)); //radiation cladding
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.kevlar, 62, 99)); //kevlar/sapi/(ERA? :) )
|
||||
this.addSlotToContainer(new UpgradeSlot(upgrades, ArmorModHandler.plating, 26, 99)); //explosive/heavy plating
|
||||
}
|
||||
|
||||
this.onCraftMatrixChanged(this.upgrades);
|
||||
}
|
||||
|
||||
public static class UpgradeSlot extends Slot {
|
||||
public class UpgradeSlot extends Slot {
|
||||
|
||||
public UpgradeSlot(IInventory inventory, int index, int x, int y) {
|
||||
super(inventory, index, x, y);
|
||||
}
|
||||
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemArmorMod && ((ItemArmorMod)stack.getItem()).type == this.slotNumber;
|
||||
return armor.getStackInSlot(0) != null && stack.getItem() instanceof ItemArmorMod && ((ItemArmorMod)stack.getItem()).type == this.slotNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,39 +2,74 @@ package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.handler.ArmorModHandler;
|
||||
import com.hbm.inventory.container.ContainerArmorTable;
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIArmorTable extends GuiContainer {
|
||||
|
||||
public static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_armor_modifier.png");
|
||||
|
||||
public GUIArmorTable(InventoryPlayer player) {
|
||||
super(new ContainerArmorTable(player));
|
||||
|
||||
public static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_armor_modifier.png");
|
||||
public int left;
|
||||
public int top;
|
||||
|
||||
public GUIArmorTable(InventoryPlayer player) {
|
||||
super(new ContainerArmorTable(player));
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 222;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int mX, int mY) {
|
||||
|
||||
Minecraft.getMinecraft().standardGalacticFontRenderer.drawString("Extended 4-Slot Crafting", 28, 6, 4210752);
|
||||
Minecraft.getMinecraft().standardGalacticFontRenderer.drawString("Standard Inventory", 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float inter, int mX, int mY) {
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int left = (this.width - this.xSize) / 2;
|
||||
int top = (this.height - this.ySize) / 2;
|
||||
|
||||
this.drawTexturedModalRect(left, top, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
guiLeft = (this.width - this.xSize) / 2;
|
||||
guiTop = (this.height - this.ySize) / 2;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int mX, int mY) {
|
||||
|
||||
this.fontRendererObj.drawString("Armor Modification Table", 28, 6, 4210752);
|
||||
this.fontRendererObj.drawString("Inventory", 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float inter, int mX, int mY) {
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
|
||||
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
ItemStack armor = this.inventorySlots.getSlot(8).getStack();
|
||||
|
||||
if(armor != null) {
|
||||
|
||||
if(armor.getItem() instanceof ItemArmor)
|
||||
this.drawTexturedModalRect(guiLeft + 41, guiTop + 60, 176, 74, 22, 22);
|
||||
else
|
||||
this.drawTexturedModalRect(guiLeft + 41, guiTop + 60, 176, 52, 22, 22);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
Slot slot = this.inventorySlots.getSlot(i);
|
||||
drawIndicator(i, slot.xDisplayPosition - 1, slot.yDisplayPosition - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawIndicator(int index, int x, int y) {
|
||||
|
||||
ItemStack mod = this.inventorySlots.getSlot(index).getStack();
|
||||
ItemStack armor = this.inventorySlots.getSlot(8).getStack();
|
||||
|
||||
if(mod == null)
|
||||
return;
|
||||
|
||||
if(ArmorModHandler.isApplicable(armor, mod)) {
|
||||
this.drawTexturedModalRect(guiLeft + x, guiTop + y, 176, 34, 18, 18);
|
||||
} else {
|
||||
this.drawTexturedModalRect(guiLeft + x, guiTop + y, 176, 16, 18, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,16 @@ import net.minecraft.item.Item;
|
||||
public class ItemArmorMod extends Item {
|
||||
|
||||
public final int type;
|
||||
public final boolean helmet;
|
||||
public final boolean chestplate;
|
||||
public final boolean leggings;
|
||||
public final boolean boots;
|
||||
|
||||
public ItemArmorMod(int type) {
|
||||
public ItemArmorMod(int type, boolean helmet, boolean chestplate, boolean leggings, boolean boots) {
|
||||
this.type = type;
|
||||
this.helmet = helmet;
|
||||
this.chestplate = chestplate;
|
||||
this.leggings = leggings;
|
||||
this.boots = boots;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,51 +2,21 @@ package com.hbm.items.special;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.handler.HazmatRegistry;
|
||||
import com.hbm.handler.ArmorModHandler;
|
||||
import com.hbm.items.armor.ItemArmorMod;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemCladding extends Item {
|
||||
public class ItemCladding extends ItemArmorMod {
|
||||
|
||||
float rad;
|
||||
|
||||
public ItemCladding(float rad) {
|
||||
super(ArmorModHandler.cladding, true, true, true, true);
|
||||
this.rad = rad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
|
||||
if(!world.isRemote) {
|
||||
|
||||
boolean used = false;
|
||||
|
||||
for(ItemStack armor : player.inventory.armorInventory) {
|
||||
|
||||
if(armor != null && HazmatRegistry.getCladding(armor) < rad) {
|
||||
|
||||
if(!armor.hasTagCompound())
|
||||
armor.stackTagCompound = new NBTTagCompound();
|
||||
|
||||
armor.stackTagCompound.setFloat("hfr_cladding", rad);
|
||||
|
||||
used = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(used) {
|
||||
world.playSoundAtEntity(player, "hbm:item.repair", 1.0F, 1.0F);
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user