jabelar
Members-
Posts
3266 -
Joined
-
Last visited
-
Days Won
39
Everything posted by jabelar
-
As mentioned above, creating a custom even and posting it to a bus is pretty easy. I would also suggest you look at how the built-in events work and are used. For example, usually the vent takes in other parameters that are useful in the event handling. Also, you may not need cancellation for your event but if you do there are sort of two approaches for "cancellation" of an event which you may want to consider -- there is the boolean return value which can be used to interrupt your code in the case the event is cancelled, and there is the event results which can be things like DENY. Anyway, look at built-in events to get a sense of how this is implemented and used. Lastly, it goes without saying that you still have to handle the event normally. So you need an event handler class registered to the bus, and that class needs to have a method that subscribes and has the event parameter of your event.
-
It shouldn't be choppy with 20 points in each swinging direction. What is the rest of your code for actually using the array? In terms of what the angles are when the entity stops, that is up to you. When you detect it stopping you can set the angles back to 0 or whatever you want.
-
[1.7.10] How to get the block the player is looking at?
jabelar replied to HappyKiller1O1's topic in Modder Support
On the client side I think you can use: Minecraft.getMinecraft().objectMouseOver, which is the current MovingObjectPosition as determined by the EntityRenderer. -
[SOLVED][1.8] Having trouble with texture on a custom block model
jabelar replied to jabelar's topic in Modder Support
I was able to fix it by following your example of defining the textures at the top and using the #base, #pole references. So it works. I still hate how this JSON stuff fails silently -- no long really a warning that it can't find the texture. Oh, well thanks again! -
Maybe you don't understand what the events are. There are events being fired off all the time by Forge and FML. Some events like the tick and update events are fired every tick. Other events are fired when certain things happen -- like an entity death event, or a block harvest event. So if you make a handler that handles a tick event, and it is registered properly, and you put console statements in the handling method, you should see the console statements come out continuously. If you make a handler that handles a block harvest event, then you'd only see console statement when you harvest something in the game. An "event" isn't necessarily something special in the game, rather it is just an indicator about which part of the vanilla code is running and gives you an opportunity to react at that time and possibly modify how the game continues to execute. What event are you trying to handle?
-
Your animations can be as smooth as trig functions. You just need to put the values in that trig would give you over a cycle, and you need to put in enough steps in the cycle so the full cycle takes the amount of time you want. For example, there are 20 ticks per second so if you want a full swing to take 2 seconds when walking you'll need 40 rows. To make it smooth, this is where you now need to act like a real animator -- you need to envision or draw out (seriously paper drawings help a lot for this) and just think through it. You can pick your ending angles -- maybe -45 and +45 and you know the middle of the cycle will be in the middle (0). The angle will change the most between steps at the middle of the swing, and will almost not move at all near the ends of the swing. So I'd start with something like this: -45 -32 -27 -22 -18 -15 -12 -9 -6 -3 0 3 6 9 12 15 18 22 27 32 45 32 27 22 18 15 12 9 6 3 0 -3 -6 -9 -12 -15 -18 -22 -27 -32 -45
-
I've successfully created several blocks in 1.8 that are full blocks, with orientable parent and working textures. Now I'm trying a more complicated shape -- in this case it is a tanning rack that has two posts and a plane between them. I want the posts to have a wood texture and the plane will have a leather hide texture. Anyway, the cuboid shapes work fine but I'm trying to map a texture and it is just using the pink and black checkered default. To keep it simple, I started by avoiding the uv mapping and just trying to map a hardened clay texture onto all faces of all three elements. However, it doesn't seem to put the textures on. Here is my JSON: { "elements":[ { "__comment":"The skin on the tanning rack", "from":[ 4, 3, 7.5 ], "to":[ 12, 15, 7.5 ], "faces":{ "north":{ "texture":"blocks/hardened_clay_stained_brown" }, "south":{ "texture":"blocks/hardened_clay_stained_brown" } } }, { "__comment":"The right post of the tanning rack", "from":[ 13, 0, 7 ], "to":[ 15, 16, 8 ], "faces":{ "down":{ "texture":"blocks/hardened_clay_stained_brown" }, "up":{ "texture":"blocks/hardened_clay_stained_brown" }, "north":{ "texture":"blocks/hardened_clay_stained_brown" }, "south":{ "texture":"blocks/hardened_clay_stained_brown" }, "west":{ "texture":"blocks/hardened_clay_stained_brown" }, "east":{ "texture":"blocks/hardened_clay_stained_brown" } } }, { "__comment":"The left post of the tanning rack", "from":[ 1, 0, 7 ], "to":[ 3, 16, 8 ], "faces":{ "down":{ "texture":"blocks/hardened_clay_stained_brown" }, "up":{ "texture":"blocks/hardened_clay_stained_brown" }, "north":{ "texture":"blocks/hardened_clay_stained_brown" }, "south":{ "texture":"blocks/hardened_clay_stained_brown" }, "west":{ "texture":"blocks/hardened_clay_stained_brown" }, "east":{ "texture":"blocks/hardened_clay_stained_brown" } } } ] } Any ideas? I understand the concept, but I must have a typo or am missing something simple. Do I need to specify a parent? (I tried using some of the common parents but it makes the model into a full block instead).
-
From the way you describe it, I think you may be thinking about events wrong. Normally you don't fire the events (although you can in certain circumstances). Instead the built-in events are firing whenever things happen in the game and you can intercept them. So you need to basically register an entity handling method for the event you're interested in, and the event parameter that gets passed into that event will have information (like the drops) and allow you to change some things, and even cancel other vanilla processing from continuing. I have a tutorial on events here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html Events are very powerful because they've made events for most of the common things that modders like to change. So you can intercept how things render, or how they update, or how they spawn, or how they die, or what they drop, or what they get hurt by, etc. It is one of the main ways of changing vanilla behavior in cases where a public field or method isn't available from the vanilla class.
-
Note you can make the array however makes sense for your animation. The point is that you can get the values for the rotations (and positions if necessary) for each part of your model but simply stepping through the rows of the array. But if you have more or less model parts than I do, then your array will have different number of columns and if your animation has more or less steps to it you'll have a different number of rows. Anyway, the whole point is forget hurting your brain over sin and cos trigonometry, it is faster and ultimately more controllable to simple set the rotations as you wish, and an array makes it easy to step through those values.
-
Are the entities you're capturing custom entities too, or vanilla entities? In either case, I think you need to create your own ID system. If you're only capturing custom entities you could have a field in the entity for your custom ID, but if you're capturing vanilla entities then you will need to create some sort of map in your main mod class that maps your custom id with the latest actual entity ID. I don't think you should use UUID at all -- I don't think those are the same between client and server. Instead use the getEntityID() method for the entity -- that will be the same on both side. That gives you the ID for an entity, and to look up the entity from the ID I usually use a method like this. public static Entity getEntityByID(int entityID, World world) { for(Object o: world.getLoadedEntityList()) { if(((Entity)o).getEntityId() == entityID) { // DEBUG // System.out.println("Found the entity"); return ((Entity)o); } } return null; }
-
Yes, that is an animation array, suitable for my animation. You can have as many arrays as you want and then just switch them based on a field in your entity. So yes you can have sprinting, or whatever. For example, my elephant only rears up when I set an isRearing boolean in my entity AI code. The only trick is that the model is processed on the client, but the entity state usually comes from the server. So you need to make sure you're syncing the value on client with the server using a packet. For sprinting you could also just cycle through the same walking animation but do it faster -- just increment the counter faster. But again, to know if you're sprinting or walking needs a field synced to server.
-
That wouldn't be very useful in Minecraft (unlike games like Runescape). According to the poster, the bot is supposed to plant things and then harvest them. I assume he'd want more than one plant going. So it would have to be aware of where it can plant, know how to check back for harvesting, etc. Also, when someone asks a question like this you know their next question will be: now how do I make a bot that can fight zombies, etc. But yes, if it were just button mashing he could do that simply with separate program.
-
No, you wouldn't want a separate bot program for this because it would need too much "vision processing" to figure what to do. Separate bots work well for games like Runescape where there is a fixed map (everything is in a known location), resources regenerate in the exact same place and the colors are set (they don't change with lighting and such) so you can look for particular pixel colors and assume what is there. To try to prevent bots in Runescape the game developers actively disrupt repetitive tasks with random mini games, although they too can be accomplished with a bot. In Minecraft you would need the bot to be in-game so it could find the block to be mined or whatever.
-
While the built-in mobs tend to use a lot of trigonometry for their animations, it can hurt your head trying to do the same with your own custom animations, and really things like the sin and cos functions only work for "swinging" type animations. Instead I've come up with an approach that is more like what real animators (like in a movie or video game will do) -- basically you figure out the set of angles (and positions if needed, like if you have orbs flying around) you might need in advance and then step through them as the animation progresses. I have a tutorial on this here: http://jabelarminecraft.blogspot.com/p/introduction-first-of-all-to-understand.html Once you understand this technique, you can just draw your animation on a piece of paper, estimate the angles and put them in the array. You also need a field that triggers the animation. But it is pretty simple. I've achieved things like an elephant rearing up, an eagle flapping its wings, a python with a snake-like movement, all using this. No trigonometry required (except guessing angles).
-
I already gave you some hints about the topics you need to learn. AI, pathfinding, and input interception.
-
What events are you trying to handle? For testing I use a lot of console statements using System.out.println() then you can check to see if the code is following the path you expect. It is also interesting to learn how the events fire -- some only fire on Server, some on both Client and Server, etc. So print out a lot of console statements and watch and learn. Otherwise, for any given event hopefully you have an idea when it should fire. If you're handling a block harvest event, then go into your game and start harvesting blocks. And so forth.
-
Use playerIn.openGui() method not the FMLNetworkHandler.
-
Like Asweez points out, that is basically a type of hacking (assuming you create a bot that is better than a human). It also would be a tough programming exercise. Are you an experienced modder and Java programmer. I think you'd have to create an AI and pathfinding system and then you'd have to intercept all the user input or at least generate user input that achieves what you want.
-
I agree with Ernio. I think you need a way to make your entity "act dead" rather than actually set dead. You can just create a boolean field in your custom entity called actDead. Then in your attack entity from method you should override it and change the code so setDead() is not called when health goes below 0 but rather your actDead field should be set to true. Then, like Ernio says you can use that actDead field to control it. For example, in the onUpdate() method you can check it and change what happens. So you can prevent movement for example, and if you want it to stay visible you can continue to render it (probably rotated so it is fallen on the ground). That's probably how I'd try to do it.
-
[1.7.10] how to create a spawn egg for custom mob
jabelar replied to Glistre's topic in Modder Support
In object-oriented programming, such as Java, a class can either be static or instantiated (whenever you use the "new" keyword in Java). And if it is instantiated it can either only have one instance (they call this a "singleton") or multiple. Because of the client server nature of games like Minecraft, static classes can be a problem if they have fields that can be modified -- then the modification might happen twice (e.g. if you had a counter decrementing, it would decrement twice every tick because both client and server will call the same static class and each decrement) So most classes with modifiable fields should be instantiated. These may be "singleton" on each side, but technically there may be two instances running in parallel (both client and server). Classes that are supposed to be instantiated will usually have an explicit constructor, while static classes don't need them. When a class has been instantiated, you have to access it's methods through the instance not just the class name. For example: MyClass1.myMethod(); // this is example of a static method call MyClass2 myClass2 = new MyClass2(); myClass2.myMethod(); // this is example of an instance method call A key point is that you need to "remember" the instance in order to access its methods. For example, each item type has an instance which are instantiated in the Items class. For classes that are singletons, they often provide an public instance field, or a public instance() method to help you find the instance when you need it. Some examples in Minecraft modding: - You can create new ItemStack all over the place. Each of those is an instance. - But the Items class is never instantiated. It just has a bunch of static final (meaning can't be modified) fields representing all the possible items (which in turn are singleton instances) - FMLCommonHandler is a singleton, so to call it's methods you need to use FMLCommonHandler .instance() Hope that makes sense. More experienced programmers may correct some of the info I stated above, but I think it should be mostly correct way to look at it. -
[1.7.10] how to create a spawn egg for custom mob
jabelar replied to Glistre's topic in Modder Support
You're still using the old way of registering the entity, instead of EntityRegistry.registerGlobalEntityID(EntityGlistreWolf.class, "Glistre_Wolf", EntityGlistreWolfID); you should use: int modEntityID = 0; EntityRegistry.registerModEntity(EntityGlistreWolf.class, "Glistre_Wolf", ++modEntityID, <name of your mod's main class>.instance, 80, 3, false); All that other spawn stuff is related to natural spawning and not the spawn egg. Other than that, to debug you should put some console statements with System.out.println() at judicious places in the code and confirm that it is executing as expected. -
The only problem with tile entities is that there is a reason that all blocks don't have them -- performance and memory. So it really depends on how many of these blocks might exist in a game. Since you described it as being for pixel art, I suspect there could be quite a few of these if someone decided to do a large scale piece of art. So I think you're on the right track -- create blocks that each have a 16-color palette.
-
[1.7.10] how to create a spawn egg for custom mob
jabelar replied to Glistre's topic in Modder Support
When using registerModEntity I think you also need to create a custom "monster placer" (what a spawn egg is called in the code). I have a tutorial for that here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-creating-custom.html -
how to add a drop to a vanilla mob [1.7.10]
jabelar replied to 2FastAssassin's topic in Modder Support
Did you really not see my post above where I link you to a tutorial specifically about how to change drops for vanilla entities? -
Yes I agree that I think you have to put modid prefix. In one of my mods with lots of custom entities I got tired of either forgetting to put my modid or tired of typing it when I remembered. So I created my own command called /conjure. I have a tutorial on this if you're interested: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172.html