Jump to content

jabelar

Members
  • Posts

    3266
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by jabelar

  1. You don't have to "convert" it to an item, just get the Item using the getItem() method for the purpose of the comparison. You only want to compare item stacks if you want to ensure the stack itself is equal -- meaning same number of items in the stack as well as it being same item. Note totally sure, but I think in your case the code could be: ((EntityItem) entity).getEntityItem().getItem().equals(itemStack.getItem())
  2. You have two options. You can use the AI task list system, or you can use the "old" method which just ran one method for all the AI. I have a tutorial on the AI task list system. Basically you create a list of AI methods that are checked in priority sequence for their start condition. Once they are running they will check condition to continue running, and also they will mask off other AI from running (so that you don't have entity start to wander away when it is in middle of attack for example). You can replace just one portion of the AI, or all of it, or re-order it, etc. I have tutorial on it: http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-custom-entity-ai.html
  3. Yep, I did mine the same way -- handle ServerCustomPacketEvent and ClientCustomPacketEvent. I haven't had problems.
  4. You know I never noticed that before but all the event hooks are in EntityLivingBase and so EntityItem (which extends Entity directly) doesn't get those events. That sucks actually since all Entities can get "hurt" and "die", so really they should have events too. I think one work-around would be to monitor things from a tick event. Basically you'd have to detect the death of one of the EntityItems (based on health<=0) and figure out whether it was an explosion that caused it. Are you controlling the explosion? It would still be bit of a guess, but if a tick handler saw that the EntityItem had died and if you know an explosion happened in its proximity, you could probably consider it a death by explosion. But yeah this is worth a enhancement or bug request to the Forge people. They should not limit the hurt and death events to living entities, or at least have an equivalent for general entities.
  5. If you're lucky it will just work. There have been some changes though, for example the bounding box pools changed so some of my methods became errors. In those cases it usually isn't too hard to figure out what the replacement should be. And if you do have specific problems you can ask here. But basically one of out my three main mods had errors, the rest just worked directly.
  6. You start simple. Just like in school textbook, do little exercises to cement your understanding. Here's some suggestions. 1) create a custom block that appears in creative tab and you can place. make it with custom texture. 2) create a custom entity that extends a vanilla entity but changes some general thing -- like make it move faster, or have more health. 3) create a custom entity that has custom model, with some animation when moving. Also make custom sounds for the entity. 4) handle an event, with simple effect to prove you're doing the right thing. For example, print "Boing" to chat whenever player jumps. 5) make a custom server command. 6) make a configuration options GUI. 7) make a block with tile entity (i.e. basically a block with extra logic, like something simple like it will kill all cows that come within certain range). make a new weapon, including recipe to craft it. For each such exercise, just make it really simple. It is honestly a big achievement to simply get a block registered, or to print "Boing" to the chat for each jump. These exercises will really get you confident in the basics. Things like how the sounds.json file works. Or how the event buses work. And so on. If you can do all these exercises, then you can suddenly find confidence to put them all together. Where you go with it depends on your interests. I personally like entities, so do a lot with them. Other people really like biomes, or armor, or enchantments, and so on.
  7. I didn't look too closely at your code, but for most directional blocks they use metadata to indicate the rotation. The trick is that (unfortunately) many of the values are different depending on the type of block. In other words, having a bed face North uses different value than steps. So it really depends on the type of block. For reference, you can see explanation of most/all blocks' metadata values here: http://minecraft.gamepedia.com/Data_values#Data So you should make sure your code puts the correct metadata for the particular block type. If it is custom block, then you need to make sure the icons and stuff are returned according to some metadata scheme.
  8. Not sure what the problem is. You're now properly spawning on server, so any disappearance is for different reason. I'm not sure it is even related to the spawn. Is there other code in your boss that would either make it jump positions, render invisibly, or die unexpectedly? I would put in a console statement in your boss entity that prints out the posX, posY, and posZ every tick. Then you'll see if it has moved somewhere, and also will notice if it dies (since nothing will print).
  9. Why not grab the world from the world parameter? Ha, ha. Yeah, skipped over that (I guess because name was obfuscated or something). Yes, that is more obvious.
  10. Interesting. I noted that LexManos made a remark in one of the changelogs for recent release that indicates he planning on re-writing the networking underpinnings. Maybe if he's reading this he can hint on what that is. I had yet another method of custom packets that used the FMLCustomPacket class. Like you said it seemed to work well for me, and seems like a legit method (heck, it's even called FML custom packet). I also don't think it would have had the memory leak problem, since I wasn't doing all that pipeline stuff, although I suppose I never really understood what the cause of the leak was. On the other hand I might not have stressed the system fully either. Anyway, definitely sucks that there isn't a trustworthy and comprehensive implementation yet.
  11. Speeding up is much harder than slowing down. The reason there is 20 ticks per second is because the game may need the time. I don't know about you but sometimes when I run it complains about ticks taking too long -- this means there is too much going on to complete in one tick. I think it is a bad idea and also unnecessary -- A traditional film movie runs at 24 frames per second and motion appears pretty smooth to human eye. In fast moving computer games, you can detect some differences between 30 and 60 fps, but it is really subtle. I doubt that spawning a couple per tick would look "bad".
  12. What exactly do you mean by warnings in Eclipse? I mean do any of your classes have a yellow warning or red error icon on them? Do any lines of code have such indicators to the left of the code? Is any of your code underlined in red?
  13. Generally, if you want to change vanilla behavior I look for the following possibilities (in this order). a) Look for public methods in the vanilla classes. For example, the AI of entities is in a public list that can be changed. For EntityChicken the time between eggs is a public field so you could change that, etc. Basically you can use your IDE (Eclipse) to suggest all available methods if you write the name of a class or class instance and then put the dot "." and wait a second -- a popup window will show all available methods. As a modder it is very useful to frequently browse through these -- they can even give you ideas for new mods. b) Look for Forge events that relate to what you want to do. The Forge programmers know the types of things that modders commonly want to do, and so they "fire" events at the points in the vanilla code that are likely useful. The events pass additional information to aid processing that particular event. For more on event handling you can check out my tutorial: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html. In this case, as diesieben07 suggests above there is an event that might be useful for your chicken mod need. c) Use Java reflection. This is easier than it sounds and allows inspection of fields and methods in other classes that were originally meant to have limited scope. In other words you can see private or protected stuff. This is a peculiarity of Java that allows this, and while it isn't really good programming practice generally it is a very important modding tool. d) Use ASM access transformers. I honestly haven't done a lot with this, but basically seems to be a framework to affect code that otherwise isn't within scope. I'm sure there are tutorials. Another approach that can be useful is to replace the vanilla items, blocks, or entities with your own custom ones that extend the original classes. There are events for most places where these are created, placed or spawned and in worst case you can use tick events to poll for existence of things you want to replace. This method can cause some side effects, if other vanilla code or other mods are expecting the vanilla classes and use something other than instanceof to test them or cast them. Anyway, just some ideas on techniques worth learning as a modder.
  14. Do all your Block instances have this problem? What about if you create a vanilla block instance? Since you said Eclipse isn't complaining, I assume your custom block is a proper extension of Block (or one of its sub-classes). but it would be interesting to see if your custom block behaves differently than vanilla.
  15. I don't know. I have a great fog effect for a "Jack and the Beanstalk" mod where as you climb up the beanstalk the fog gets thicker and thicker. It works without doing anything with GL11. Here is the code I used. You can try it and go into Creative Mode and just fly up to cloud level (I made the fog get thicker when you got into the clouds). @SideOnly(Side.CLIENT) @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(FogDensity event) { event.density = (float) Math.abs(Math.pow(((event.entity.posY-63)/(255-63)),4)); event.setCanceled(true); // must be canceled to affect the fog density }
  16. Hmmm. It seems it should be correct. Do you see any warnings or errors in Eclipse at all, other than the one about the unrecognized method? If you hover over "block" with your mouse in Eclipse, what does it say? Can you include the package and imports from your main class code?
  17. Where do you create the block instance? Can you post the code where you recreate it? (i.e. somewhere you must have something like MyCustomBlock block = new MyCustomBlock() kind of thing).
  18. You spelled it wrong: getUnloclaizedName should be getUnlocalizedName Spelling is VERY important in programming. For example, you even spelled the subject of this thread wrong -- it should be "recognizing". Anyway, to help you get spelling correct you should let Eclipse help you. If you type the "." after the instance or class and wait for a second, Eclipse should pop up with a list of all available fields or methods. You can keep typing a bit to filter the list down. If you select from that list then it will ensure that you've got a properly spelled method.
  19. You may want to see my tutorial on custom entity AI. http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-custom-entity-ai.html Overall, it is a bit complicated but there is a priority system and a masking system (mutexbits). With the masks you can make it so that certain AI can't be run while certain other AI is running. I try to explain this in my tutorial.
  20. You should first decide what you want other mods to be able to do, then figure out what API you need to support that. For example, do you want them to be able extend your entity class? In that case you could go as far as putting the the whole entity class into the API. Do you want them to just be able to control the custom functionality of your entity in some ways? Then make those special methods in your entity class an API (i.e. create another API class that calls the methods from your mod class). Do you want to have them create entities that you can interact with? then make a Java interface that you want them to implement. It all depends on what you want the interaction between the mods to be.
  21. diesieben07 has posted an example here: https://github.com/Questology/Questology/blob/master/src/main/java/demonmodders/questology/QuestologyWorldData.java
  22. To get the position of the block underneath properly, you need to take into account the Yoffset of the entity/player. So full code should be more like this: public Block findBlockUnderEntity(World parWorld, Entity parEntity) { return parWorld.getBlock(MathHelper.floor_double(parEntity.posX), MathHelper.floor_double(parEntity.posY - 0.20000000298023224D - (double)parEntity.yOffset), MathHelper.floor_double(parEntity.posZ)); } (The high precision double number was copied from elsewhere in Minecraft code, but of course you could probably get by with 0.2D).
  23. Is anything canceling the event? You may want to set the handler priority in your "2nd" mod to highest, and also maybe set receiveCanceled to true. Basically you augment the @SubscribeEvent like this: @SubscribeEvent(priority=EventPriority.HIGHEST, receiveCanceled=true) If it still doesn't get it, that seems weird. However, one thing I'm not sure about is how event buses get cleared. I assume it is a queue and the events stay there until handled, but there may be a subtlety where if mod 1 actually fires it after the mod 2 event handler is checked maybe the event somehow gets stuck -- like maybe it has to be handled in same tick that it is posted or it might be lost. Not sure, just a thought.
  24. I believe it is controlled by the hurtResistantTime field in the Entity class. The good news is that it is public so you should be able to control it even on vanilla mobs. It is normally controlled in the attackEntityFrom() method so you might want to check that out to understand how it normally works before messing with it. At very least on your custom mobs you can @Override that method to get rid of the hurt resistance.
  25. I think your sided stuff is slightly messed up. First of all, you're spawning the entity on the client side, not on the server side. The way you're getting the world is a client-side method and will crash when used on server. If it does spawn on client, it will disappear almost immediately or at least cause other trouble. So you need to grab the world from the entity parameter, and check !entity.worldObj.isRemote to ensure you are on server side before spawning. And you need to use that worldObj as well for the spawn to avoid crash. I'm actually not sure why it isn't already crashing for you (the Minecraft call should crash on server) so maybe that method is only being called on the client side. If you are detecting the spawn condition on the client side you then need to pass the information to the server with a custom packet, and the server should spawn the boss based on receiving that packet. You should also use @Override annotation as it is good practice to find any typographical or logical mistakes as it will warn you if the method declaration doesn't match the format of the method you think you're overriding.
×
×
  • Create New...

Important Information

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