jabelar
Members-
Posts
3266 -
Joined
-
Last visited
-
Days Won
39
Everything posted by jabelar
-
[1.8][SOLVED] Placed block using wrong model json
jabelar replied to Tyron's topic in Modder Support
I personally had difficulty getting an enum property to work as well. I just switched to an integer property and it seemed to work better. Sometime I need to go back and figure out the enum properties properly, but although enum is more elegant an int works well too. I'd try to convert the property to an integer and see if you have any different result. -
To spread out the loop over multiple ticks, just use a counter variable that you increment and test if it has reached the max. I've only used other threads in one situation, where I was getting a response from a web site to create a version check. But for most in-game stuff you definitely want to stick within the threads already implemented. This does mean you need to be aware of how long your code is taking to execute. For example, I have a tile entity that generates a structure but it was a big, slow loop which could take up to 20 seconds -- I had to break that down over multiple ticks.
-
A vector is a mathematical representation of a direction and distance. A 3-dimensional vector is represented by a Vec3 class in Minecraft. A Vec3 is practically just an x, y, z and the concept of direction and distance is relative to 0, 0, 0. The Vec3 class has methods for adding, multiplying, etc. including more esoteric mathematical operations like dot product and cross product. There are various methods that return Vec3. One is called the "look vector" which represents the direction the player is looking. I think there is also a method called getEyePosition() or similar which gives a vector (basically the position) of the player's eyes. The look vector is normalized (meaning it has length of 1.0) so if you want to go farther in the direction you need to multiply it by the distance you want to go. So putting this all together, you want to get the eye position and add the look vector multiplied by distance you want. Then spawn the projectile at the x, y, z from that resulting vector.
-
Adding more damage to a sword if a player is sprinting
jabelar replied to Asweez's topic in Modder Support
If you look at the call hierarchy for the hitEntity() method, it seems that the attacker is the last parameter (ItemStack calls it with the EntityPlayer), so I think that is correct. I think the question is whether the method is being called at all. I would put another console statement at the beginning of the method. -
Guys, it is a really common misconception but the rayTrace() methods only find blocks, not entities. The confusion is that these methods return a MovingObjectPosition which contains fields for entities hit but those will always be null. There is a method called getMouseOver() which ray traces both blocks and entities, but only within the reach distance of the player -- it is used to figure out whether you hit an entity. So I've made my own custom mouse over method which uses the same technique as the built-in mouse over but extends the distance as far as you want. I was able to use the method to create a weapon with "infinite" reach -- basically picking off anything I could see. I'm writing a tutorial on ray tracing, but for now check out my tutorial on the extended reach weapon. It will give you what you need: http://jabelarminecraft.blogspot.com/p/minecraft-modding-extending-reach-of.html
-
[1.8][SOLVED] Placed block using wrong model json
jabelar replied to Tyron's topic in Modder Support
To clarify, the metadata is only 4 bits, not 4 bytes. So 16 possible values. In your getMetaFromState() function you need to figure out a mapping that fits the properties you've got into those 4 bits. If you need more than that you may need to consider creating other blocks that get swapped in, or using a tile entity (which can store NBT) if you don't intend to place a lot of the blocks. In the code for your anvil block, you don't seem to be storing your property. You are only converting the facing property, not the metal property. You have to do proper getMetaFromState() and getStateFromMeta() that handle all the properties. But also you have the issue that you have too many variants, unless you use a tile entity to manage your property values. To explain further -- each Block class is only instantiated once (it is a "singleton" class). So to store information that makes some of the blocks appear or act differently when placed in the world, there is 4 bits of meta data stored per block position. The reason it is only 4 bits is because there are so many blocks in the world that you'd have issue with memory, disk space, or networking with much more data. -
Adding more damage to a sword if a player is sprinting
jabelar replied to Asweez's topic in Modder Support
To be clear, the 1.0F in the attackEntityFrom() method should be changed to the amount of damage you want to do. You probably want to make it a multiplier of the base damage -- i.e. if sprinting doubles the damage, then multiply the base damage by 2.0F. And the causePlayerDamage() method doesn't actually do any damage, it just makes sure the DamageSource has the player field properly filled in. -
[1.7.10] [UNSOLVED] Ticking memory exception/NullPointerException...
jabelar replied to Ms_Raven's topic in Modder Support
This took me a while to get as well. The Container is intended to take care of the synchronization between client and server, plus help aggregate multiple IInventory. But it isn't needed for all GUIs. I explain "do you need a container" a bit here: http://jabelarminecraft.blogspot.com/p/minecraft-modding-blocks-with-guis.html -
The other thread already answers the question. Just create the two entities at the same time, but make one a bit farther out (ideally it would be at a distance that project moves in half a tick).
-
and here is 1.8 version of the code for those who might want to use it:
-
Okay -- I created my own version of set block that doesn't do the lighting updates. Basically just copied the World#setBlock() code along with the Chunk function it calls and commented out the things that recalculated lighting. The time to generate went down from 22 seconds to 74 milliseconds!!! Pretty much instantaneous. If you're interested, here is the code (1.7.10 version) as I currently have it. I renamed a few parameters to make it more readable, and will probably go through and rename some more, but it seems to work and you can see what I commented out: Note it does have some lighting artifacts -- some areas are darker than they should be, but they fill in over time or as you move around, and it doesn't look that bad and frankly Minecraft has a lot of such visual/loading artifacts. I will still look at how i can get the lighting update after the blocks are placed...
-
Thanks for the suggestion. I actually read the file into an array in advance during the mod loading, so I'm not reading from the file during the generation.
-
Okay, yeah I did that and it definitely seems that the server is held up while the client is continuing. Here's the log starting a few ticks before the generation starts: You can see that at the beginning on average it is doing same number client and server ticks. Then you can see the generation starts and then there are only client ticks. I then stopped the game and then a whole bunch of server messages came through. So yep, just like I thought, I'm hanging the server. I had previously broken up the structure to just do a few blocks per tick, so I'll try to go back to that. Ultimately, I've really got to figure out a way to create an alternative setBlock() that doesn't regenerate lighting after every placement. I almost got it working by trying to edit the chunk storage directly and it was literally 100 times faster...
-
I have a structure generator that is invoked when a tile entity reaches a certain state. This structure generator simply reads a text file and places blocks accordingly. But as mentioned in another thread on the topic, I'm generating this very high up (in the clouds) and it turns out that the lighting updated during the setBlock make a high structure much slower to generate than a lower structure. Anyway, the point is that it takes about 20 seconds to generate the structure. The thing that puzzles me though is that it doesn't create any lag in the actual game. The structure takes 20 seconds to appear, but there is no lag (other gameplay is smooth) while it is generating. But this seems odd because I'm doing the structure generation from the update method of a tile entity, and the structure gen is just a big nested loop, so I would think that whatever thread called the tile entity update method would get held up until it completed the generation. So I'm wondering whether the server is actually hung up during the generation and the client is continuing to make the game play seem to work, or is the server sufficiently threaded that the call to the tile entity is isolated from the other code the server is executing? Basically it just seems odd to me that putting code that takes 20 seconds to loop through isn't causing the server to have trouble doing the rest of what it needs to do.
-
Difference between EntityConstructing/EntityJoinWorld
jabelar replied to Mistram's topic in Modder Support
Also note that it seems that EntityConstructing is called at the *beginning* of the constructor. So if you set fields in the constructor, I've found that they are not available at the time the event is called. For example you won't have a position for the entity. -
If you press F3 while in game it will show you how much memory is being used. With 4G JVM arguments I'm normally using less than 30%, so you probably don't need more. But you can check with F3.
-
[Forge 1.8] Help Understanding Minecraft's Noise Generation
jabelar replied to MCZaphelon's topic in Modder Support
Yeah, that was my thread and I wasn't really able to solve the problem. I had a structure that when placed at ground level took about 4 seconds, but when placed at cloud level took 40 seconds, and any height in between was in between. I tried to solve this by actually trying to bypass some of the setblock code, and tried directly writing to the chunk storage, in both cases trying to bypass the lighting stuff but couldn't quite get it to work. Without lighting calculations the structure placement only took about 40 milliseconds but would crash afterwards. I'm sure someone could figure it out there, it felt like I was close to a solution. -
Furthermore Minecraft is just Java so you can do regular Java file access stuff. There is a class called ByteBufUtils which has methods to easily write NBT to a buffer that you can then put into or out of a file stream.
-
Actually I wouldn't call that a "derp". It is annoying that they've been changing the format for the version on several of the most recent builds. And a couple weren't listed properly on the file downloads site. But yeah, you need to check exactly what it should be.
-
One possible approach is in a tick event handler to try to detect the same conditions for the natural healing and then counteract it by reducing health by amount it would be healing.
-
There are certain questions that when the person asks it, it shows that they may not be strong enough in programming generally to do modding. When you're a programmer you'll already know that anything Java can do is possible. So if someone asks "how do I access a file location", or "how do I create a timer", that is really just a Java question and if you don't already know the answer (or can't quickly figure it out) then you should probably study more Java. A more legitimate question is one asked about the details of the Minecraft, FML or Forge implementation. Like most new modders have to figure out that an Item is a singleton but ItemStack is instantiated. That is specific to Minecraft modding. So, back to the original question -- if he doesn't know how to set or test a boolean then he needs to study more programming. If what he really meant was something like "how do I ensure that all players know when a player has clicked on a button in an overlay GUI", that is much more reasonable to ask here. Hopefully he can clarify whether he really doesn't know how to do the boolean part, or if it is more about the mechanics of the drawing and syncing of the button activity.
-
A mob that acts as a collective consciousness?
jabelar replied to The Great Duck's topic in Modder Support
I think the way mobs like wolves and pets attack is pretty much the same as what you want to do. Basically, if one of the entities gets a target, then all of them in the nearby region also get the same attack target. I know you might say that is "communication", but really that is the same thing -- all of them collectively getting same target. If you want to be literal about it and actually combine what they can all see, I think there is a canEntityBeSeen() method in the EntityLivingBase class. You could iterate through all your entities and check any of them can see the player. -
[1.7.10] onCreated method for Item called twice for server?
jabelar replied to HappyKiller1O1's topic in Modder Support
You probably have two instances of the class. Is this an item? Did you register two with that class? Did you extend the class and instantiate a subclass? -
[1.7.10] Changing light value of shadow of block to be displayed....
jabelar replied to Elix_x's topic in Modder Support
What are you returning for the isOpaqueCube() function in your block?