Jump to content

hugo_the_dwarf

Members
  • Posts

    334
  • Joined

  • Last visited

Everything posted by hugo_the_dwarf

  1. Yup was me just being dumb. Changed it so everything that is not a player or a villager and is EntityLivingBase to get my capability. But where the information is updated (stat rolling etc) which is in the LivingEvent.LivingUpdateEvent I check to see if the targetTasks is not empty Thanks for the help guys
  2. Well, if that's the case it's fairly simple, Create the capability, have it store a list or array of ItemStack, make sure it reads and writes the NBT correctly (for saving) then use packets to update the client (server will have all the info, so need to send that to the client so they know what items they have. Important for your GUI to render) However someone might know a better way for syncing it as you might be able to use the container system? (someone verfiy, I haven't dealt with containers in a long time) there are several examples around on capabilities now, you can even look at my source code in my sig to see how I have my capabilities setup. They don't store ItemStacks, but it can be easily done.
  3. Edit, ok nvm just remembered that the AttachCapabilities event triggers way before an entity is even finished being made, so explains the null. Just have to move some logic around one sec
  4. Little Vague, Would you be able to supply the story for this? aka "I would like to use XYZ to store Items within a Capability for Players, so then I will do something with said items" Is there a reason why the default Player Inventory is not sufficient?
  5. I'm getting this Error, when trying to use my check for the AI tasks Code in question: @SubscribeEvent public void onAddCapabilitiesEntity(AttachCapabilitiesEvent<Entity> e) { if (canHaveAttributes(e.getObject())) { EntityLivingBase ent = (EntityLivingBase) e.getObject(); if (ent instanceof EntityPlayer) e.addCapability(CapPlayerExtraProvider.KEY, new CapPlayerExtraProvider(ent)); else if (ent instanceof IMob || entityCanAttack(ent)) e.addCapability(CapMobExtraProvider.KEY, new CapMobExtraProvider(ent)); e.addCapability(CapAttributeProvider.KEY, new CapAttributeProvider(ent)); } } ........ public static boolean entityCanAttack(Entity entity) { if (entity instanceof EntityLiving) { EntityLiving ent = (EntityLiving) entity; for (EntityAITaskEntry task : ent.tasks.taskEntries) { Console.out().println(ent.getName()); Console.out().println(task.action.getClass().getName()); if (task.action instanceof EntityAIAttackMelee || task.action instanceof EntityAIAttackRanged || task.action instanceof EntityAIAttackRangedBow || task.action instanceof EntityAINearestAttackableTarget || task.action instanceof EntityAIZombieAttack || task.action instanceof EntityAIOwnerHurtByTarget) return true; } } return false; } Mainly it's erroring on when I'm trying to loop through the tasks. EDIT line 66 is "for (EntityAITaskEntry task : ent.tasks.taskEntries)" in "public static boolean entityCanAttack(Entity entity)"
  6. Thanks I will look into that, Seems Tasks are a EntityLiving, had to root around the classes.
  7. Checked that, there seems to be some issue tho with a few of the other person's mod. Some mobs have that Attribute, but it's 0. But they are hostile, Some that are passive have it and it's 1. not good. I will at least keep my check for "instanceof IMob" as it covers a large blanket of the correct mobs. I've noticed that Iron Golems don't have the attribute. But that's fine as since they are Vanilla I can just toss in "instanceof EntityIronGolem" no big deal (was going to custom cater their stats anyways so that's a double bonus) Is there anyway to see or check if they have an AI task of attacking? or attacking back? EDIT: Your suggestion was very helpful, but it seems some of the mobs added are not following a generic path
  8. With my mod I have attributes and other capabilites attached to hostile mobs, but not passive ones (Villagers, pigs, etc) this is so I can make anything that counts as an enemy have random strengths. Now I thought it'd be as easy as just checking if it implements IMob however testing with another mod (that adds many more creatures) some of them did not get my new stats. Is there a way where I can check "If(EntityLivingBase.CanAttackOthers)" rather "If(EntityLivingBase instanceof IMob)" Now things like a Pig which never ever attacks anyone or anything will never get it, but something like the Iron Golem where it's mostly passive but can attack if something is near or if a player hits it should get it.
  9. I had this working once before the "Blocks and Items and everything needs to be a JSON" I got it from looking at Tinker's Constructs code on how they handle their tools (they do alot more than just custom handle and end) at some point I might have a gander at their code again and see how they updated it to work with 1.10.2+
  10. Does the "EntityMob.class#attackEntityAsMob" help? or already looked at that class?
  11. before that happens, You register them with the same id of 0, I personally prefer to use this method for ID's that I don't need to remember int id = 0; EntityRegistry.registerModEntity(rscrl, EntitySphere.class, rscrl.toString(), id++, Exampled.getInstance(), 128, 214, true); EDIT: just to be clear make sure if a "register" method has a param called "ID" or something that sounds like it needs to be "Unique" ensure that it is indeed unique. EDIT2: I also included my method into one of your registers, and bolded it for easier detection
  12. Would it have to be hard coded? Or could an event be used to check "Does the mob hold a weapon, mimic 'player' damage type"? Just a curious bystander
  13. Welcome, if anything else creeps up let us know.
  14. Update some of your methods that "send a packet" to include a EntityPlayer param, and in your PlayerTick events you can get the player from there if (!player.worldObj.isRemote) essence.mainUpdate(player); ^^^ Journey.wrapper.sendTo(new MessageEssenceBar(essence, regenDelay == 0),(EntityPlayerMP)player); or you can just declare an Entity obj in the Essence class and give your provider a constructor or have it call capability.entity = event.entity then in main updates you just check to see if the entities worldObj is not remote (server) and sendTo from there. Since I can't physically see the ghosting or debug and step through (I might just do a pull and run it personally soon enough) to see what it really could be. EDIT: looks like you have a Console.out somewhere sending out the values which is nice, as I can see numbers flying all over. If I can locate that spot I can try having the console also pump out hopefully any other helpful information.
  15. I've noticed in your Essence class you use Journey.wrapper.sendToAll() just curious if you mean to do that. Because you register your Capability on "Everything" not just players. But I don't see any "generic" entity tick so it rules out the fact that a random mob could be "sending" it's data to everyone. However that sendToAll() will cause issues because you use your clientProxy to "handle" the data by getting the minecraft.thePlayer which If player 1 ticked and updated, server sends data to all, player 2 now thinks "player 1s" stats are his (then player 2 gets ticked, and server updates all players again player 1 now thinks player 2's stats are his) if you make sure in the player tick event you can just use Journey.wrapper.sendTo(message,(EntityPlayerMP) player); and it will send it to the correct player rather than all players. I'm still digging through some of your code.
  16. Looks like you've made some progress which is good. Do you have your project on a public repo? (GitHub, Bitbucket) I'd be happy to assist the best I can, if you like you can have a look at my capability system https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master packages are named in meaningful ways Was those 3 posted blocks of code you're only changes? or have you updated your bar tick code since then?
  17. I believe the Cactus block and sugercane have a ticks randomly still. have a look at those two block classes
  18. which name? the JSON? the .obj? filename? in mod code, JSON value, something in the .obj file.
  19. You have two randoms: nextInt(3)nextInt(1) == 0 ? 1 : -1result 010 0-10 111 1-1-1 212 2-1-2 As you can see the 0 appears twice in the result column as opposed to every other number, hence it has a higher chance of appearing. actually since I'm using rand.nextInt(2) == 0 ? 1 : -1; which is a ternary so the random will return 0 or 1. If it is == 0 return 1, else -1 so even if I had rand.nextInt(50) == 0 ? 1 : -1; it would most likely be -1 more often as it could be != 0 as it has more options to pick from (0 to 49) But after I got up and left I figured Dracos is the best choice as my given example that I posted it'd be easier to just add 1, and it'd even it all out rand.nextInt(11) - 5; would give a range of -5 to +5 (including 0) or simply "rand.nextInt((range * 2) + 1) - range;"
  20. not that I'm against Dracos Approach of rand.nextInt(10) - 5; as it looks like a very elegant solution done with less code and cpu But nextInt() goes from 0 (inclusive) and to the bound (exclusive basically bound - 1) so really the outcomes are (if the bound is 10): -5 0 -4 1 -3 2 -2 3 -1 4 0 5 1 6 2 7 3 8 4 9 And just a question regarding my method (as it appears as a horrible approach) how does it "Generate 0 more often" 0 * anything is going to be 0. But if the random gave you a 0, you got a 0. if you got a 1, it might be +pos or -neg same with any other number given. I wouldn't think it would return more 0's unless it's the fact that the bound is so low (0 to 4) that 0 is a higher possibility, but if the goal was to only move randomly 4 blocks left/right and 4 blocks forward/back my method would keep it as 4. where subtracting the number would allow the negative to have a -1 head start?
  21. Add some break points, then slowly debug it (step into) and find where it roughly appears to be recursively calling net.minecraft.nbt.NBTTagCompound.copy at lines 523 17 525
  22. You could subscribe to a tick event, preferably a playertick event. and in there check for if(player had special potion effect && player.world.time % 20 == 0) do teleport logic; The game is in a constant loop, and each loop is more or less a tick, 20 MC ticks are roughly 1 second RL time. A tick event as it seems is run every tick. So instead of a for loop that will run x amount of times teleporting in a single game loop, you space it out every 20 ticks
  23. you will have to give the player some sort of state (capability, or a combo of effects) that you can reference, then every player tick (or intervals of ticks) while the player is in the state apply your teleporting. And yes Random().nextInt() only takes postitives, however you can make the negative with another random playerX + New Random().nextInt(5) * (New Random.nextInt(2) == 0 ? 1 : -1) more or less the above will get a random of 0-4 then multiply by 1 or -1 if the random returns 0 or 1 making that 0-4 value negative or leaving it positive also it should be Random rand = new Random(); then call rand.nextInt(); EDIT: Also don't use my example of new Random().nextInt(); it's better to declare an instance like above "Random rand = new Random();" and call it, or get the RNG from the player most entities have a function called "getRNG()" which returns a Random so you can use player.getRNG().nextInt();
  24. Some how I feel like there is something scaling up everything by 2 GL11.glScalef(x, y, z); Also regarding the fluid bar not being in the center each time, you should be able to use this.guiLeft and this.guiTop to get obviously the starting point of the left and top of when the GUI is drawn. Which is normally the ScaledResolution.getScaledWidth() / 2 - sizex / 2 it's better to add and subtract locations from guiLeft and guiTop for relative locations. If you have a hard point sometimes resizing the screen or changing the GUI Scale in the MC options > video settings can throw it off. For some of my HUD stuff in my mod I use ScaledResolution res = event.getResolution(); int bottomScreen = res.getScaledHeight(), halfHeight = bottomScreen / 2; int rightScreen = res.getScaledWidth(), halfWidth = rightScreen / 2; as I don't have a gui to get the left and top from. just the raw screen EDIT: as for the color, try hard setting it 0xFF0000 < Red if it's still white there could be a location where a GL11.glColor4f() is being used. I found that drawing colored text would change it, forcing me to reset my GL color back to a solid white before drawing anymore textures.
  25. try this.drawRect((this.sizex / 2) - (18/2), top, (this.sizex / 2) + (18/2), top + 60, color); I had to subtract left from right to get 18, and top from bottom for 60. For small objects like bars and that make sure you store their dims (height width)
×
×
  • Create New...

Important Information

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