Jump to content

UberAffe

Forge Modder
  • Posts

    316
  • Joined

  • Last visited

Everything posted by UberAffe

  1. Ok so I have all of that in place now but there is one problem. ISmartItemModel extends IBakedModel not IFlexibleBakedModel and bake wants an IFlexibleBakedModel. Do I just need to update my forge version to fix this (im using 1764)?
  2. Maybe I don't need it, I still get confused with minecrafts single item instance for multiple ItemStack thing. So let me restate what I am trying to accomplish. I am trying to allow players to design new Items during the game. Any player with a sufficiently high level will be able to create an ItemStack that uses whichever Item they selected. Each Item that gets designed will be a variant of one of the cores, the only core available right now is MeleeCore which is used for items that act like swords. Variants of Cores have the same functionality but use variant specific models/damage/durability values. What is working with my current code: In-game creation of new core variants Save/Load of core variants In-game creation of ItemStack based on specific variant (has correct damage values) When I create an ItemStack using the default core it stays in the players inventory between logout and login. When I create an ItemStack using a variant of the core it gets lost between logout and login. I believe this means that I will need to switch things up so that I always use the default core but with different NBTs that have all the information that would otherwise have been in the variant core.
  3. I put a breakpoint in handleItemState and it never gets called so no. This is the only error I can find in the log
  4. IDraftable But I think DraftingItemCore is the one you actually want to see For completeness here is MeleeCore
  5. postInit because I'm a noob when it comes to this, moved to preInit and both places now use Refs.modelResourceLocation, I just moved the variable from DraftableSmartItemModel to Refs. These are in DraftableReg @SideOnly(Side.CLIENT) public static IFlexibleBakedModel GetModel(String draftItem) { return models.get(draftItem); } public static void RegisterDraftable(IDraftable draftable){ LogHelper.info("Registering Draftable :" + draftable.GetName()); knowledgeBase.put(draftable.GetName(), draftable); } @SideOnly(Side.CLIENT) public static void RegisterDraftableModel(IDraftable draftable){ LogHelper.info("Registering Model for :" + draftable.GetName()); models.put(draftable.GetName(), new DraftableBakedModel(draftable)); } My proxies have a Register method that gets used to call either one or both of these register methods. I put a breakpoint in GetModel and it doesn't get called, so something is still wrong with how I am assigning my DraftableSmartItemModel to the items.
  6. Doesn't minecraft handle saving the players inventory though? This is how I am creating the ItemStack to give to the player public ItemStack CreateItem() { LogHelper.info("creating " + name); ItemStack toReturn = new ItemStack(this, 1, 0); NBTTagCompound tag = new NBTTagCompound(); tag.setString(Refs.DRAFTABLE, name); toReturn.setTagCompound(tag); return toReturn; }
  7. If by pre-generated you mean during pre-postInit no. The available instances get created by the player in-game, some will be loaded from a file and could be generated during pre-postInit, the only way to make all of them available during pre-postInit would be to force a server restart each time they add an instance which I do not want to do. I have this in my ClientProxy#postInit ModelResourceLocation itemModel = Refs.modelResourceLocation; ModelLoader.setCustomModelResourceLocation(MeleeCore.meleeCore, 0, itemModel); This is what I have for the ModelBakeEvent @SideOnly(Side.CLIENT) @SubscribeEvent public void onModelBakeEvent(ModelBakeEvent event) { Object obj = event.modelRegistry.getObject(DraftableSmartItemModel.modelResourceLocation); if(obj instanceof IBakedModel) { event.modelRegistry.putObject(DraftableSmartItemModel.modelResourceLocation, new DraftableSmartItemModel()); } } Here is what I have for ISmartItemModel: public class DraftableSmartItemModel implements ISmartItemModel{ public static final ModelResourceLocation modelResourceLocation = new ModelResourceLocation(Refs.MODID + ":draftable_Item","inventory"); // this file doesn't exist @Override public IFlexibleBakedModel handleItemState(ItemStack stack) { IFlexibleBakedModel model = null; if(stack.getTagCompound().hasKey(Refs.DRAFTABLE) && DraftableReg.Exists(stack.getTagCompound().getString(Refs.DRAFTABLE))) model = DraftableReg.getModel(stack.getTagCompound().getString(Refs.DRAFTABLE)); return model; } } This is in the item class(I have my own registry of instances of this class) public ItemStack CreateItem() { LogHelper.info("creating " + name); ItemStack toReturn = new ItemStack(this, 1, 0); NBTTagCompound tag = new NBTTagCompound(); tag.setString(Refs.DRAFTABLE, name); toReturn.setTagCompound(tag); return toReturn; } The models are just showing up as purple and black boxes. Is there something wrong with how I am assigning the models to the items?
  8. 1. So you mean surround all that with an if(event.type == ElementType.ALL) { //my code } 2. Alright, I'll switch that to post. 3. I really have no idea but I cant think of anywhere else in my code that might be causing this. The only other part of my code this touchs is ILuxin#GetColor which for all instances is a single line method that looks like this public int[] GetColor(){return new int[]{255,0,0,255};} So after applying 1,2 The bars are staying the correct color but when I scroll through the hotbar any time I come across an item the bars completely disappear for a short time(1.5 - 2 seconds). I Also tried removing my receiveCanceled=false but that didn't change anything. is that something that might be getting caused by using ElementType.All?
  9. Yes to the first question and it's working to the point that the code is getting run and isn't crashing anything.
  10. you check this twice: ID == HelpFulMod.guiIDHelpFulTable but you just need to figure out which condition is failing and why
  11. well first you can remove the if statement in both methods since you have the condition in your ? condition. But I would recommend splitting it up into separate if statements so that you can put a break point in on each condition because one of them is failing when it shouldn't be.
  12. I have an item type which generates an IFlexibleBakedModel based on it's nbt information. I have that model stored so that it only needs to get generated once. But how do I actually go about using that model when the item is rendered? Edit: Ended up updating to 1.9
  13. Update: if i create an itemstack with the variable meleeCore instead of this it will persist between logout and login. meleeCore is the instance of this class that gets registered as an item.
  14. So I started a new world and the bars were displaying properly. I created one of my items and then only the luxin type that was used to create that item displayed properly and all of the others changed hue. I then killed a chicken with my item, got 2 feathers and all of the bars display correctly again. If I throw one or both of the feathers out of my inventory all but that one bar get messed up. Picking up the feathers fixes the display. I am so confused...
  15. New problem, the items seem to not be getting saved/loaded between logins. updated code @Override public ItemStack CreateItem() { LogHelper.info("creating " + name); return new ItemStack(this, 1, 0); } All the other code should still be the same, and I am currently getting the correct version of the item when I call this method. Can you see any reason why this item would disappear between logout and login?
  16. I have some hud "mana bar" type things that I am displaying but there are some odd things going on. 1. If I do not have an item in my hand all the bars go black 2. The colors don't look like they do when I pull the values from here This is my hud overlay class public class CustomHud{ private static LuxinBarRenderer[] bar_Lux; public CustomHud(){ Minecraft mc = Minecraft.getMinecraft(); Collection<ILuxin> luxin = LuxinReg.RegisteredLuxin.values(); bar_Lux = new LuxinBarRenderer[luxin.size()]; int index = 0; for(ILuxin lux : luxin) { bar_Lux[index] = new LuxinBarRenderer(lux.GetName(), mc, index, lux.GetColor()); index++; } } @SubscribeEvent(receiveCanceled=false) public void onEvent(RenderGameOverlayEvent.Pre event) { renderHud(); } public void renderHud() { for( LuxinBarRenderer rend : bar_Lux) rend.RenderLuxinBar(); } } This is the LuxinBarRenderer class public class LuxinBarRenderer { private final static int BAR_WIDTH = 81; private final static int BAR_HEIGHT = 9; private final static int BAR_SPACING = 3; private String lux; private Minecraft mc; private int iteration; private int[] RGB; public LuxinBarRenderer(String lux, Minecraft mc, int iteration, int[] RGB) { this.lux = lux; this.mc = mc; this.iteration = iteration; this.RGB = RGB; } public void RenderLuxinBar() { EntityPlayerSP player = mc.thePlayer; if(player == null) return; IDrafter drafter = DraftingProvider.get(player); if( drafter == null && !(drafter instanceof DefaultDrafter)) return; DefaultDrafter prop = (DefaultDrafter) drafter; float avail = prop.GetAvailableLuxin().get(lux); float cap = prop.GetMaxLuxin().get(lux); float percent = cap / avail; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushMatrix(); GL11.glColor4f((float)RGB[0]/255, (float)RGB[1]/255, (float)RGB[2]/255, .6f); int top = BAR_SPACING + (iteration * (BAR_SPACING + BAR_HEIGHT)); int left = BAR_SPACING; GL11.glBegin(GL11.GL_LINE_LOOP); { GL11.glVertex2i(left, top); GL11.glVertex2i(left + BAR_WIDTH, top); GL11.glVertex2i(left + BAR_WIDTH, top + BAR_HEIGHT); GL11.glVertex2i(left, top + BAR_HEIGHT); } GL11.glEnd(); GL11.glColor4f((float)RGB[0]/255, (float)RGB[1]/255, (float)RGB[2]/255, 1f); GL11.glBegin(GL11.GL_QUADS); { int right = left + (int)(new Float(BAR_WIDTH) / percent); GL11.glVertex2i(left, top); GL11.glVertex2i(left, top + BAR_HEIGHT); GL11.glVertex2i(right, top + BAR_HEIGHT); GL11.glVertex2i(right, top); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glPopAttrib(); } } Any idea what would be cause these issues?
  17. Alright so I was thinking too hard about this and over complicating things. In my #CreateItem() all I needed to do was return new ItemStack(this, 1, 0) because the object this method is getting called on already has everything it needs. Sorry for my dumbs and thanks for the help!
  18. So should I be using something like meleeCore.updateItemStackNBT(SaveAsNBT()); return new ItemStack(meleeCore, 1, 0); That seems like it would mess with all meleeCore items but maybe I'm wrong.
  19. I guess I kinda hid the problem in the comments. This method isn't returning the "item" i am expecting @Override // this is from DraftingItemCore public ItemStack CreateItem() { LogHelper.info("creating " + name); // this prints out the name I expect return new ItemStack(meleeCore, 1, 0, SaveAsNBT()); } The name that I print to the log for my test item is "Bluex32" and that gets printed out here but ItemStack drafted = toDraft.CreateItem(); LogHelper.info(((IDraftable)drafted.getItem()).GetName() + " Created"); when I run this code in my draftingmanager it prints out "defaultmelee" which tells me that I am creating the default item and it isn't getting the information from the nbt I create.
  20. Ah in that case I am at a loss, but if you figure it out let us know. I already have a capability in mind that I would like to add to vanilla blocks.
  21. This is class structure I am using IDraftable Abstract DraftingItemCore extends Item implements IDraftable MeleeCore extends DraftingItemCore Here is the relevant code from MeleeCore public static final MeleeCore meleeCore = new MeleeCore(); public MeleeCore(String name, CoreType type, DraftableMap map) { partMap = map; coreType = type; this.name = name; setProperties(); } private MeleeCore(){ partMap = new DraftableMap(); coreType = CoreType.MELEECORE; name = "defaultmelee"; } @Override // this is from DraftingItemCore public ItemStack CreateItem() { LogHelper.info("creating " + name); // this prints out the name I expect return new ItemStack(meleeCore, 1, 0, SaveAsNBT()); } @Override // this is from IDraftable public NBTTagCompound SaveAsNBT() { NBTTagCompound toReturn = new NBTTagCompound(); toReturn.setString("name", name); toReturn.setString("coreType", coreType.toString()); toReturn.setTag("partMap", partMap.SaveAsNBT()); return toReturn; } This is my registration with minecraft which happens in CommonProxy#preInit GameRegistry.registerItem(MeleeCore.meleeCore, Refs.MODID + "_" + MeleeCore.meleeCore.GetName()); I have my own registry for all available IDraftable instances which looks like this: public final class DraftableReg { private static HashMap<String, IDraftable> knowledgeBase = new HashMap<String, IDraftable>(); public static void RegisterDraftable(IDraftable draftable, World world){ if(!world.isRemote) { LogHelper.info("Registering Draftable :" + draftable.GetName()); knowledgeBase.put(draftable.GetName(), draftable); } } public static IDraftable GetDraftable(String name){ return knowledgeBase.containsKey(name)? knowledgeBase.get(name): null; } } This is the code that is getting run when the player attempts to create an IDraftable public class DraftingManager { public static void PerformDrafting(EntityPlayer player) { IDrafter drafter = DraftingProvider.get(player); if(drafter == null) return; IDraftable toDraft = DraftableReg.GetDraftable(drafter.GetSelectedDraftable()); if(toDraft == null) return; ItemStack held = player.getHeldItem(); LogHelper.info("attempting draft of " + toDraft.GetName()); // this uses the name I expect if(held == null) { if(drafter.AttemptDrafting(toDraft.GetCost())) { ItemStack drafted = toDraft.CreateItem(); LogHelper.info(((IDraftable)drafted.getItem()).GetName() + " Created"); // this uses defaultmelee as the name player.setCurrentItemOrArmor(player.inventory.currentItem, drafted); } try{ drafter.dataChanged(player); // updates client with capability changes } catch(Exception e) { LogHelper.warn("Drafting errored"); System.out.println(e.getMessage()); } } } } I am probably doing some step wrong in the creating of nbt based items but I'm missing what that is. Any help is appreciated.
  22. UberAffe

    FDL

  23. Based on Log events that I have put into my save and load methods it seems like capabilities for entities only get loaded once and then the work the same way as the IEEP system did in that each entity instance works with its own capability object. Any functional code (the code that actually uses skills) you would use in your IEEP can be copy pasted into capability.
  24. Forgot about the event phase, but I cant find a getKeyIsPressed anywhere(I am in 1.8.9) I switched to isKeyDown and that seems to be working how I want it to.
×
×
  • Create New...

Important Information

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