Jump to content

HalestormXV

Forge Modder
  • Posts

    328
  • Joined

  • Last visited

Everything posted by HalestormXV

  1. I understand. Well judging by your examples it would seem a combination of both might be the best option. The NBT data can be used on the itemstack to give it some fancy properties and set an owner and all that good stuff. However it appears for my design to work I will need to use IExtendedEntityProperties. Perhaps a nudge in the right direction? I have read over your tutorial and I created my class here: http://pastebin.com/J6c1ZUPf Already registered via my main class and what not. So I would essentially need to create a tag for every one of my entities, correct? I can then use the single boolean and change it to true once an entity has been summoned. Write that to the player NBT file, then in the itemclass file check that boolean and if it is returning true prevent them from summoning the entity again? Or am I totally off-base. I apologize for all these questions but I am still learning and this has been incredibly helpful. I want to actually learn how to do this hence why i am researching all these tutorials and such but I do need some guidance from my superiors. I know that everything works on the NBT side of things as opening up my .dat file shows the new category has been created an all 12 values are added in that new category and are all set to false. What I can't seem to figure out is how to make it so that the flag gets set to true in the item onUse function so that they cannot be double summoned by the same player. And I can't figure it out because that part is using the reflection block and I don't know howt o make it auto determine which flag it needs to set to true depending on the key you are using. IE: Using Key with a damage value of 6 is the Aries key. I need to make sure that when you use that key that the ariesIsActive gets set to true in the player's NBT data.
  2. Alright, well the way it is supposed to work is you have the Item of summoning. You use it to summon your entity. By summoning your entity that item is now your's and bound to you and your "contract" is formed. The player is supposed to be able to summon that entity so long as they have that item. Now the NBT tag method seems to do exactly that. However, you bring up a valid point. If the item is duplicated (via dupe bug) or if I do decide to make them craftable they can summon them with one of each item, since, as you stated, each stack has its own NBT. I am interested in this IExtendedEntityProperties though. That seems to make a safeguard against potential dupe bugs with other mods. I am however, totally unfamiliar with it. I actually came across your tutorials: https://github.com/coolAlias/Forge_Tutorials/blob/master/EventHandlerTutorial.java https://github.com/coolAlias/Forge_Tutorials/blob/master/IExtendedEntityPropertiesTutorial.java http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-x-1-8-customizing-packet-handling-with Would these be what I have to look into? Ideally all I want to do is have the code say, I'm already summoned by you and you can't summon me again while I am out here. Furthermore, if you managed to dupe my item I still don't want you to summon me if I have already been summoned by you and am active. Would it be perhaps easier/more effective or efficient just to make sure that a player cannot have more than one of the item in their inventory and if they do take out the duplicate? Or maybe even better? If the entity is already spawned and summoned and you use the item again it gets rid of the entity and sets it dead? Although that still doesn't handle, multi item multi summon.
  3. The keyActive was actually something I was using to test and decided against it. I just forgot to take it out. Although you bring up a good point with setting the key active for one player and not the other. This way each summon is almost "unique." So that one players doesn't have 4 Aries running around as that would be just odd. So that is something I would like to implement. I am not that familar with item NBT just yet. Although I did read this tutorial: http://www.minecraftforge.net/wiki/Creating_NBT_for_items So am I correct in assuming that I could add itemstack.stackTagCompound = new NBTTagCompound(); itemstack.stackTagCompound.setString("Owner", player.getUniqueID().toString()); itemstack.stackTagCompound.setBoolean("Active", false); into my item class? And then possibly have an boolean activeKey = itemstack.stackTagCompound.getBoolean("Active"); if (!activeKey) //Execute summoning code here (Reflection code block that we worked out above) else Send chat: You already have a creature out. My question though is how would I start this up. These items aren't craftable. They are rewards. So to that end I can't use the "onCreate" method to set up the NBT data. However if I try to add in the NBT setup into the onUse method it will just overwrite itself with the new data every time it is right clicked, correct? If there really is no way around this I don't mind making the items craftable at all, if it would make things that much easier. Another thought that occurred to me, is in-since this item has subtypes will that cause any issues with NBT? Granted each key is a MaxStack of 1. So you won't be able to stack them but that also just popped into my head while reading the above tutorial. It seemed like it wasn't subtype friendly?
  4. Alright so after taking in all of your comments and looking at some tutorials I finished up the code. It "SEEMS" to be functioning as it should. Here is the link to the whole code: http://pastebin.com/FCMm79uB Here is the link to block using reflection: http://pastebin.com/SyLqQaPP Now although this works from what I can tell, would it be SMP friendly? IS there anything that maybe my nooby eyes are missing? Do the calculations seem correct, in terms that the costs will always have fresh values? Secondly, diesieben07 I know you were suggesting NOT to call or store the class in the array but I couldn't figure out what you mean by only storing each class's constructor since the code uses the .getConstructor Perhaps you or someone can show an example of what you meant? This is my first time working with this reflection and I do see incredibly how much it cleaned the code up. So any more help and/or feedback is appreciated.
  5. alright so currently this is the entire itemClass file: http://pastebin.com/px29McDj So ideally with the reflection way. I would essentially replace all of those if checks in the onUse boolean with the reflection ways above?
  6. I understand reflection is very powerful however in doing my research I have also read that it can be quite difficult. Now I do want to learn as I am still new to all of this. Can you provide an example of how this may look? I did do my own research to and found this video which seems to explain the basics nicely: I also understand that reflection may be resource heavy? Although I imagine with a situation where tehre are 12 different subsets of an item that probably won't even be recognized. And I also stumbled onto this: http://www.minecraftforge.net/wiki/Using_Access_Transformers (not needed for this though from what I understand)
  7. Alright, I have some code here that works fine as is. But I want to make it a bit more efficient and cleaner. Currently there is an item with 12 different subtypes and the each item has a different effect. Specifically each item summons a different entity. Here is a portion of the code now: http://pastebin.com/Dn7kzbzu I know for a fact I can probably for loop this and it will be nicer to look at and probably more efficient. Any ideas on how I can go about For looping that? Now I know for loops are elementary in most cases. But I can't quite figure it out because I want to make sure it calculates the values properly. As you can tell each summon has a different cost attributed to it that is dynamic based on the summoner's EXP. Any help is appreciated. I could always go the "if way" but perhaps a for loop I think would be more effective, quicker and efficient? Or maybe it isn't possible to handle all of it in a loop but perhaps a private function for the calculations?
  8. Alright, so after searching the forums and following various tutorials and getting help from the community here I am happy to say that my Custom Dimension is almost done. Multiple Biomes, Awesome looking Terrain Gen and Caves. Only my custom mobs spawning in them and not vanilla mobs. A constant Twilight state so there is no day and night cycle. So everything is looking good. Probably the last thing I need some help with is Tree Generation. Now I did some searching on these boards and I found a variety of different threads that ask the same question. How do you generate trees in your custom biomes. Some threads say to use a method similar to oreGeneration, others say to do it in the decorator. I tried both and must be missing something. I already have my tree generation code here: http://pastebin.com/mNV9PpJP I just can't figure out where or how to call this. I thought it would be in the BiomeDecoratorHelper I have here: http://pastebin.com/xhApWrRg See the comment i put in /** Generates Celestial Trees **/ and the code to go along with it. But as it turns out, no trees get generated. Now just as an FYI, yes there is a custom topblock however that custom topblock is capable and able to grow trees on it as my saplings that represent those trees grow just fine. So what am I missing? Am I trying to put it in the wrong place? Is the code supposed to go in my chunkProvider instead? Any help is appreciated as I am approaching the last step to finishing up this dimension, or at least I think I am.
  9. Well to be quite honest I am a noob and litereally just learning how to work with dimensions and listeners and didn't realize that I could remove them from my dimension or know how to do it lol. Because I thought if I removed them from the spawn list that it would remove my custom entities also. (Since they too spawn in the overworld biome types like .forest and .desert, etc. etc.) Tips on how to accomplish it? Is it done in the custom biome code?
  10. Alright so I have seen the pure power of the listeners and decided to try and dive into them. I created two listeners and I already know they are TERRIBLY inefficient. I am watching my log and am seeing that the server is running way far behind. I know it is my own fault and I expect and that is why I am posting here. Perhaps someone can guide me in the right direction/ help me optimize this. As it stands now these listerners seem to actually work which I was quite shocked by since it was the first time I attempted to work with a listener. Here are the two listeners: Dimension Listener - This listener is meant to inflict damage on a player every 4 seconds if they are no wearing the correct set of armor http://pastebin.com/FwxrBGMk Vanilla Spawn Disable - This listener is mean to cancel the spawning of all vanilla mobs and leave room only for my custom mobs/animals public class SpawnListener { @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { if (event.entity.dimension == DimensionIDs.LIGHTFORESTDIMENSION) { if(event.entity instanceof EntitySkeleton || event.entity instanceof EntityZombie || event.entity instanceof EntitySpider || event.entity instanceof EntitySheep || event.entity instanceof EntityChicken || event.entity instanceof EntitySquid || event.entity instanceof EntityCow || event.entity instanceof EntityPig || event.entity instanceof EntityEnderman) { event.setCanceled(true); } } } } They are registered in my main mod file here: @EventHandler public static void Load(FMLInitializationEvent event) { GameRegistry.registerFuelHandler(new FuelHandler()); GameRegistry.registerTileEntity(TileEntityCelestialFurnace.class, "Celestial Furnace"); NetworkRegistry.INSTANCE.registerGuiHandler(modInstance, new CCGuiHandler()); MinecraftForge.EVENT_BUS.register(new SpawnListener()); MinecraftForge.EVENT_BUS.register(new CelestialDimListener()); //#################ENTITY HANDELRS#########################\\ EntityHandler.registerMonster(EntityCyclops.class, "Cyclops"); EntityHandler.registerMonster(EntityLunarSpirit.class, "LunarSpirit"); EntityHandler.registerMonster(EntityCultist.class, "CC_Cultist"); EntityHandler.registerMonster(EntityFallenAngel.class, "FallenAngel"); EntityHandler.registerSummon(EntityAries.class, "Aries"); EntityHandler.registerItemEntity(EntityGrenade.class, "dimGrenade"); Any words of advise on how to change these or better yet get rid of them in favor of something more efficient and better? Thanks in advanced.
  11. If you need anymore segments of the code please feel free to ask. As I said, the Dimension works, you can enter it, explore it, get ore, and all that jaz. But I just can't get the multiple biomes to spawn. Thank you in advanced. And I know this is a large topic post and many people ask for help with it quite regularly. But I just want to note that I HAVE it working. I just can't get multiple Biomes. EDIT: Well holy crap.......I had conflicting IDs.....I had conflicting Biome IDs and that is what was driving me off a wall......HOWEVER I still do need some help. Anyone know how I can spread the biomes out a bit more so they are not spawning "on top" of each other. In other words. One direction is one biome and then a few blocks later could be another biome that stretches for a while, etc. etc.? Furthermore is there a way to have forge Auto-Assign the BiomeIDs so that conflicts are auto-resolved?
  12. Duly noted. Thank you for that heads-up. I was not aware of that and have fixed it.
  13. Woohoo, thank you truly to everyone who helped me with this. I learned a TON from it. I am happy to report that it works wonderfully. Including the cleanup method if the user disconnects. Hopefully it will perform the same on a server. Here is the finished class for those interested: http://pastebin.com/CWST7B4X My mod uses EXP as an energy source. Please let me know if you think I could optimize this code in anyway. As I said I am new to all of this and am learning as I go. So my code may not be the most efficient but that is part of my learning curve.
  14. Fantastic, now my probably one last final question is. If the owner of this entity disconnects or logs out I want this entity to despawn as it is not meant to be like a wolf and stay persistent. Now I know this probably has something to do with forge's events, but any guidance on how to take care of that? Or maybe I don't need the forge events at all and perhaps i can also take care of this in the onUpdate so that it checks in on the tick since I already have the owner referenced? I think once I can get that it will clean up this entity class nicely and I can finish it off. My thought is since I am not writing this entity to NBT (I took it out of the code) once the user logs off teh server that user/owner becomes null? In which case I can just call a check and if null then call this.worldObj.removeEntity(this); or is my thinking totally off?
  15. Correct I meant in this way: public int costCounter; public void onUpdate() { // executes each tick { costCounter += 1 if (costCounter = 80){ costCounter == 0; player.addExperienceLevel(-ariesSummonCost); if (player.experienceTotal < ariesSummonCost) { this.worldObj.removeEntity(this); } } } I wasn't talking about looping in the onUpdate no. Is this method better than checking the tickLife? NOTE: I might have some missing signs or incorrect signs in that sample as I typed the answer from my phone.
  16. Interesting way to do that. I didn't know you were able to measure how long the tick has existed for. However, inquiry, would it be more effective to write a loop into that method that increases an integer, and once the integer reaches a certain amount it reduces the player level and then the integer resets back to 0?
  17. Ultimately I'd like to try and have it be called every 4 seconds instead of every tick. So every 4 seconds or 80 ticks their, the player, EXP level drops by 1. However, if it is more effective and efficient to do it during the onUpdate than that is fine as I can just adjust to cost to compensate. Ultimately that would result in the player losing .25 EXP per tick which when calculated would be 1 EXP every 4 seconds. The only problem is that the XP functions only take intergers so I can't decrease them by decimals. And yes I know that the numbers we see are not the "actual" values. So like 3000XP might actually be level 43 but I am just speaking using these terms to make it clear. So I guess my question now becomes is their really no way to do this via a Tickhandler so that the cost is removed every 4 seconds? And if so then how can I set it up so that the player is losing XP at a much slower rate than every tick be it subtracting decimals or what have you.
  18. Outstanding! That seems to work exactly how I wanted. I had to change up the code because it seems that the EntityTameable class does not like the: float damage = (float) getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); So by simply defining float damage without the EntityAttribute it worked. Here is the updated FULL entity class: http://pastebin.com/6ra1ewWn Now the next question and this will probably finish up my entity inquiry. I want the entity to have a cost to stay summoned. Now I don't exactly want this to be subtracted every tick. May I want to have it subtracted every two seconds or so, and then once it reaches a certain threshold the entity despawns itself. If my guess is correct, I know the general makeup will be something along the lines of public void onUpdate() { super.onUpdate(); EntityLivingBase owner = this.getOwner(); this.iAmF = this.iAmE; if (owner instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) owner; player.addExperienceLevel(-ariesSummonCost); if (player.experienceTotal < ariesSummonCost) { this.worldObj.removeEntity(this); } } if (this.watchingYou()) { this.iAmE += (1.0F - this.iAmF) * 0.4F; } else { this.iAmF += (0.0F - this.iAmE) * 0.4F; } if (this.watchingYou()) { this.numTicksToChaseTarget = 10; } } But reading your statement above that probably isn't the most efficient way to go about it (althought that code does work and subtracts 1 EXP level every tick). So how could I make it so that this summon cost is only applied every two seconds or four seconds or so, or in minecraft terms every 40 or 80 ticks? In doing my searching I imagine this would have to do something relating to a tick handler? As I am still new to this I really am trying to find where to start. I did find this tutorial, actually by you coolAlias lol http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-forge-1-6-4-1-8-eventhandler-and But in summary, how would I go about doing that so that it only happens every 4 seconds while the entity is spawned? I do apologize but I am trying to learn. So any examples would be most beneficial, or even a code with comments so I can learn from it.
  19. Thank you. Yes it does seem to be working. I would rather not hard-code it to be quite honest as you stated. So this bring me to another point that perhaps I can get help with. I cannot seem to figure it out for the life of me. Rather than start a new thread I will just post it here as it is related to the same matter. There are 12 different types of these creatures that you summon and they are all extending the tamable class. Rather than hardcode the damage value I would like to try and use a formula that take the current experience points of the owner and perhaps divide it by something so that the creature actually gets stronger the stronger you are. Where exactly or how exactly would I go about doing that? I can't seem to figure out how to have the entity check via an onUpdate event what that entity's owner's experience points are. Then in that onUpdate event it would calculate what the current power of the entity is and return it in the attackEntityAsMob function. Thanks in advanced.
  20. I feel like an idiot bumping this. But right now I think I just need a confirmation. Does the function happen to control tameable mob damage be this. public boolean attackEntityAsMob(Entity entity) { int i = this.isTamed() ? 4 : 2; return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)12.0F); //i } entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)12.0F And in my case I set that to 12 to indicate 6 hearts of damage. I ask because originally it was set to i. Sorry for the bump and thanks in advanced.
  21. No such luck. I really feel like I am overlooking something so simple and it is just due to my ignorance.
  22. Alright, I have been posting some issues while coding my mod here and each and every time I have been able to solve it with the help of a post. And I thank you greatly to those of you that take the time to explain and correct my errors and nudge me in the right direction. I need assistance once more. My mod is coming along nicely. I have managed to do what I deem, in my noobyness, to be some quite complicated things. However now I am stuck with something probably so basic. I created a new companion entity that the player can summon via an item. It works great, the entity gets summoned and follows you around. I basically just took the Wolf entity and changed it around. However I cannot seem to figure out how to set the entity's Strength. Here is my entity class where everything is taken care of with the exception of setting the owner. (That is done in the item class used to summon this creature). Entity Code: http://pastebin.com/VBMUrjuz So that is the code. I have tried this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(12.0D); I imagine that happens because this is extending the Tameable class and not the Mob class which is fine. So then in doing some further search I cant seem to figure out where the attack damage for this entity is handled. Personally i thought it was somewhere in here: public boolean attackEntityFrom(DamageSource targeted, float power) { if (this.isEntityInvulnerable()) { return false; } else { Entity entity = targeted.getEntity(); this.aiSit.setSitting(false); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { power = (power + 12.0F) / 2.0F; } return super.attackEntityFrom(targeted, power); } } public boolean attackEntityAsMob(Entity entity) { int i = this.isTamed() ? 4 : 2; return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)i); } But that doesn't seem to be it. So can anyone give me a shove in the right direct as to where I handle the entity's strength, or any other attributes that are valuable to know?
  23. Outstanding help. I didn't think to use the breakpoint but it pointed out the issue almost immediately to me. I would have never thought an issue would be related to conflicting light levels. Now perhaps this is because I am a total noob to modding but what appears to be happening was that yes it was returning true as it should but then it went on to execute RenderBlocks.renderStandardBlockWithAmvientOcclusion here: http://pastebin.com/WMk0MdPV Now for whatever reason that does not like light levels coming off of blocks. Or perhaps the light levels of the portal were conflicting with the light levels of the block. So how did I fix it? //this.setLightLevel(0.6F); in the CelStone class. And it works just fine now. But I am curious. Any idea as to why that would happen or why they "fight" like that? I ask purely for knowledge sake. I mean a light level of .6 is hardly noticed next to my portal light level anyway but I am curious. Could it perhaps also be remedied by not allowing any light to pass through the celStone since the light itself seemed to cause the issue.
  24. Hello there. I have another question that I am sure is just from my noobness to the modding world. However I cannot seem to find the answer via searching. I have created a custom portal that will take the player to a custom dimension that I have created. Everything works wonderfully thus far. However there is one issue that I cannot seem to figure out, and i KNOW it most likely has something to do with either my portal block class or the block that is used to outline the portal. Here is my problem: Here is my stone block class (the block that outlines the portal that seems to be having the issue) - http://pastebin.com/7SUMba7w Here is my portal block class (I don't think the problem lies in here, because if I switch to a vanilla block like stone bricks or stone, that error doesn't occur) - http://pastebin.com/qe1C4tU3 Or perhaps I am totally wrong and it is the portal block class because I am rendering sides wrong or something like that. So once again any help is greatly appreciated. I promise I am not just "looking for answers" I really want to look for answers and learn. I have really grown to like modding and want to perfect it to the best of my ability. So thank you in advanced.
  25. Perfect, once again it was a dumb oversight on my part. I had this being registered via my RegisterMonster function as opposed to my RegisterItemEntity function (both are identical but one doesn't add the spawn) Thank you again for the help. The issue seems to have been corrected.
×
×
  • Create New...

Important Information

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