Jump to content

AshIndigo

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by AshIndigo

  1. 735 lines Is your code all in one class??? Jesus
  2. Check your profile for forge first and make sure it is on an applicable forge version and if need be reinstall forge
  3. Kind of late but I have some form of internet now so I'll just leave this here. First of all update to the latest forge otherwise this may not work at all. 1st step: Set your color somewhere using ItemArmor#setColor 2nd step: Override hasOverlay, hasColor, setColor, and getColor to remove the ArmorMaterial.LEATHER check which will let you supply your own stats. 3rd step: Override getArmorTexture but you have to supply a different texture based on the type string. (I wont be supplying direct code but if something is confusing let me know)
  4. 1.7.10 isn't supported update to 1.10.2 then ask.
  5. I managed to get it working while I didn't have internet so I'll just mark it as solved.
  6. ((ItemArmor) result.getItem()).setColor(result, 25555555); I completely forgot that existed. And for setColor I'm just setting the material to ItemArmor.ArmorMaterial.LEATHER for now. I'll override right now.
  7. My IRecipe class also contains code for the recipes for other items which aren't relevant to the armor so I just posted the main part where the NBT is set. if (invCraft.getStackInSlot(0).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(1).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(2).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(3).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(5).getItem() == AlloycraftItems.alloy) { ItemStack alloy1 = invCraft.getStackInSlot(0); ItemStack alloy2 = invCraft.getStackInSlot(1); ItemStack alloy3 = invCraft.getStackInSlot(2); ItemStack alloy4 = invCraft.getStackInSlot(3); ItemStack alloy5 = invCraft.getStackInSlot(5); int prop1 = (int) Math.sqrt(alloy1.getTagCompound().getInteger("Strength") + alloy2.getTagCompound().getInteger("Strength") + alloy3.getTagCompound().getInteger("Strength") + alloy4.getTagCompound().getInteger("Strength") + alloy5.getTagCompound().getInteger("Strength")); int prop2 = (int) Math.sqrt(alloy1.getTagCompound().getInteger("Durability") + alloy2.getTagCompound().getInteger("Durability") + alloy3.getTagCompound().getInteger("Durability") + alloy4.getTagCompound().getInteger("Durability") + alloy5.getTagCompound().getInteger("Durability")); int prop3 = (int) Math.sqrt(alloy1.getTagCompound().getInteger("Enchantability") + alloy2.getTagCompound().getInteger("Enchantability") + alloy3.getTagCompound().getInteger("Enchantability") + alloy4.getTagCompound().getInteger("Enchantability") + alloy5.getTagCompound().getInteger("Enchantability")); result = new ItemStack(AlloycraftItems.alloyhelmet, 1); ((ItemArmor) result.getItem()).setColor(result, 25555555); result.setTagCompound(new NBTTagCompound()); result.getTagCompound().setInteger("Strength", prop1); result.getTagCompound().setInteger("Durability", prop2); result.getTagCompound().setInteger("Enchantability", prop3); ((ItemArmor) result.getItem()).setColor(result, new Color(result.getTagCompound().getInteger("Strength"), result.getTagCompound().getInteger("Durability"), result.getTagCompound().getInteger("Enchantability")).getRGB()); return result; } } } } }
  8. I do have recipes in my IRecipe class which will set the tag for the three integers.
  9. I'm probably missing something here but I've been calling setColor in onCreated. Should I b calling it on the client only? ((ItemArmor) stack.getItem()).setColor(stack, new Color(stack.getTagCompound().getInteger("Strength"), stack.getTagCompound().getInteger("Durability"), stack.getTagCompound().getInteger("Enchantability")).getRGB());
  10. I had this issue to when trying to update forge to 1.10.2 and I was able to fix it by entering this command into my cmd prompt set JAVA_HOME="(put your jdk dir here)"
  11. Just learned that EnumChatFormatting doesnt exist anymore after trying to find it, it's now called TextFormatting.
  12. I'm using ItemArmor#setColor in the onCreated method, and I just overrode hasColor and made it return true. But the armor stays the same with no color. Should I just be creating the display and color tag myself instead of using vanilla methods to do it?
  13. So I want to make custom dyeable armor i.e leather armor but whenever I try to set the color with Item#onCreated the armor stays white with seemingly no overlay. Here is my code package com.ashindigo.alloycraft.items; import java.awt.Color; import java.util.List; import com.ashindigo.alloycraft.AlloycraftMain; import com.ashindigo.utils.UtilsArmor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; // TODO Add wearing color public class AlloyArmor extends ItemArmor { public AlloyArmor(String name, ArmorMaterial material, EntityEquipmentSlot type, String modid) { super(ItemArmor.ArmorMaterial.LEATHER, 0, type); setCreativeTab(AlloycraftMain.alloycrafttab); GameRegistry.register(this, new ResourceLocation(modid, name)); maxStackSize = 1; this.setUnlocalizedName(modid + "_" + name); } @Override public void onCreated(ItemStack stack, World world, EntityPlayer player) { // stack.getTagCompound().getInteger("Strength"), stack.getTagCompound().getInteger("Durability"), stack.getTagCompound().getInteger("Enchantability") ((ItemArmor) stack.getItem()).setColor(stack, new Color( stack.getTagCompound().getInteger("Strength"), stack.getTagCompound().getInteger("Durability"), stack.getTagCompound().getInteger("Enchantability")).getRGB()); if ( ((ItemArmor) stack.getItem()).hasOverlay(stack)) // Allow this for anything, not only cloth { int i = ((ItemArmor) stack.getItem()).getColor(stack); float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; System.out.println("Has Overlay!"); System.out.println(f); System.out.println(f1); System.out.println(f2); } System.out.println(this.getColor(stack)); if (stack.getTagCompound() == null) { stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setInteger("Durability", 0); stack.getTagCompound().setInteger("Enchantability", 0); stack.getTagCompound().setInteger("Strength", 0); } } public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if (itemStack.getTagCompound() != null) { par3List.add("§4Strength: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Strength"))); par3List.add("§2Durability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Durability"))); par3List.add("§1Enchantability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Enchantability"))); } } @Override public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { return "textures/models/armor/" + "leather_layer" + "_" + (armorType.getSlotIndex() == 2 ? "2" : "1") + ".png"; } /* @Override public boolean hasOverlay(ItemStack stack) { return true; } */ }
  14. Bump? I don't know if I need a custom renderer for this...
  15. Check my thread on it with some help I got it to work on my items
  16. If all fails just redownload the MDK and copy your files in.
  17. I've been trying to replicate Leather armors ability to color itself but use my own textures and colors but the armor is always white. package com.ashindigo.alloycraft.items; import java.awt.Color; import java.util.List; import com.ashindigo.alloycraft.AlloycraftMain; import com.ashindigo.utils.UtilsArmor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; // TODO Add wearing color public class AlloyArmor extends ItemArmor { public AlloyArmor(String name, ArmorMaterial material, EntityEquipmentSlot type, String modid) { super(ItemArmor.ArmorMaterial.LEATHER, 0, type); setCreativeTab(AlloycraftMain.alloycrafttab); GameRegistry.register(this, new ResourceLocation(modid, name)); maxStackSize = 1; this.setUnlocalizedName(modid + "_" + name); } @Override public void onCreated(ItemStack stack, World world, EntityPlayer player) { // stack.getTagCompound().getInteger("Strength"), stack.getTagCompound().getInteger("Durability"), stack.getTagCompound().getInteger("Enchantability") ((ItemArmor) stack.getItem()).setColor(stack, 0x000000); System.out.println(this.getColor(stack)); if (stack.getTagCompound() == null) { stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setInteger("Durability", 0); stack.getTagCompound().setInteger("Enchantability", 0); stack.getTagCompound().setInteger("Strength", 0); } } public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if (itemStack.getTagCompound() != null) { par3List.add("§4Strength: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Strength"))); par3List.add("§2Durability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Durability"))); par3List.add("§1Enchantability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Enchantability"))); } } @Override public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { return "textures/models/armor/" + "leather_layer" + "_" + (armorType.getSlotIndex() == 2 ? "2" : "1") + ".png"; } } (I know I have my texture set to leather but thats just for LayerArmorBase#renderArmorLayer to work until I get actual textures.)
  18. I had readded this since I removed before since it didnt work and put it in the wrong method oops. Ill just edit my post to fix that real quick. The GL11 call was me trying to set the color of the item but this is my first time with gl11
  19. I'm trying to set the color of an ItemStack based on 3 nbt int (Corresponding to rgb) But I cant seem to figure out how to change the color ingame. package com.ashindigo.alloycraft.items; import java.awt.Color; import java.util.List; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GLContext; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; public class AlloyItem extends Item { public AlloyItem(String modid, String name){ super(); setUnlocalizedName(modid + "_" + name); setCreativeTab(CreativeTabs.MISC); GameRegistry.register(this, new ResourceLocation(modid, name)); maxStackSize = 1; } @Override public void onCreated(ItemStack itemstack, World world, EntityPlayer player) { GL11.glColor3d(255, 255, 255); if (itemstack.getTagCompound() == null) { itemstack.setTagCompound(new NBTTagCompound()); itemstack.getTagCompound().setInteger("Durability", 0); itemstack.getTagCompound().setInteger("Enchantability", 0); itemstack.getTagCompound().setInteger("Strength", 0); } ItemColors itemcolors = new ItemColors(); itemcolors.registerItemColorHandler(new IItemColor() { public int getColorFromItemstack(ItemStack stack, int tintIndex) { return tintIndex > 0 ? -1 : ((ItemArmor)stack.getItem()).getColor(stack); } }, new Item[] {this}); } public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if (itemStack.getTagCompound() != null) { par3List.add("§4Strength: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Strength"))); par3List.add("§2Durability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Durability"))); par3List.add("§1Enchantability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Enchantability"))); } } @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { //GL11.glBegin(0); GL11.glColor3d(255, 255, 255); //GL11.glEnd(); } } } But if I try to launch with the OpenGL code then I crash with this stacktrace Caused by: java.lang.RuntimeException: No OpenGL context found in the current thread. at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) ~[lwjgl-2.9.4-nightly-20150209.jar:?] at org.lwjgl.opengl.GL11.glColor3d(GL11.java:867) ~[lwjgl-2.9.4-nightly-20150209.jar:?] at com.ashindigo.alloycraft.items.AlloyItem.onUpdate(AlloyItem.java:58) ~[AlloyItem.class:?] at net.minecraft.item.ItemStack.updateAnimation(ItemStack.java:526) ~[itemStack.class:?] at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:389) ~[inventoryPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:559) ~[EntityPlayer.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2218) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?] at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) ~[NetHandlerPlayServer.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:215) ~[NetworkDispatcher$1.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) ~[NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) ~[NetworkSystem.class:?] ... 5 more And the ItemColor#registerItemColorHandler fails too
  20. Wouldn't it be easier to use the block states file and just set the bar to a different texture/model? Though if your trying to make it dynamic then I cant be much help.
  21. Thank you for the help guys I got it working now and I guess I should reread some java guides too.
  22. So I changed my code to use local variables but I cant convert from ItemStack to void. ForgeRecipes package com.ashindigo.alloycraft.lib; import com.ashindigo.alloycraft.AlloycraftItems; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class ForgeRecipes { public ForgeRecipes() { } public static ItemStack getSmeltingResult(Item item, Item item2) { return getOutput(item, item2); } public static ItemStack getOutput(Item item, Item item2) { // TODO get nbt setup if (item == Items.iron_ingot && item2 == AlloycraftItems.alloy || item == AlloycraftItems.alloy && item2 == Items.iron_ingot) { ItemStack itemstack = new ItemStack(AlloycraftItems.alloy, 2); itemstack = itemstack.getTagCompound().setInteger("", 5) return itemstack; } return null; } }
  23. Sorry I probably should have worded it better its late. But the method ive been trying to set nbt with is this return new ItemStack(AlloycraftItems.alloy, 2).stackTagCompound.setInteger("", 5); but I can't use it because I can't return a void statement which is the .setInteger method. I was wondering if there is an alternate way to change the nbt data from the result.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.