
Tuhljin
Forge Modder-
Posts
28 -
Joined
-
Last visited
Everything posted by Tuhljin
-
I've tried world.spawnEntity(entity); both before and after attaching the leash. It didn't make a difference.
-
One of my village buildings - upon its creation - spawns an animal and puts it on a leash, attached to a fence. This works fine. The problem, however, is that the leash does not render until the player exits the world and then loads it back up. I think that the problem has to do with the packet which informs about the leash state not being sent to the player due to the player not being considered to be "watching" the entity at the time entity.SetLeashedToEntity (which sends the packet) is called. Like I said, the animal is spawned fine and it is properly attached to the fence by a lead, but the lead doesn't render. How can I make it render without needing the player to exit and rejoin the world? I tried sending the packet myself at the end of spawnLeashedAnimal, but of course that doesn't work (presumably for the same reason that the packet doesn't work when it's sent by entity.setLeashedToEntity). If I could reliably send the packet a little later, I think that would work, though. I know that if you send the packet later on, the leash starts rendering, since I created a test item which, on right-click, looks at entities in the area and sends those packet(s) out. Is there maybe some way to delay sending the packet to a moment after the world generation bit is done and presumably the player is now "watching" the entity? Or if there a better way to fix the rendering problem, what would that be?
-
So, I've done a lot of research on this and I haven't found a practical solution. I could replace the village generation with my own (extending the vanilla one), but that would make my mod incompatible with many other mods that change villages. Does no one know of a good way to do this? The vanilla code relies on so many static methods in key places, there isn't a nice way to do what I want by reflection. Perhaps we need a new Event in Forge. I don't know where the best place for that would be, though I can offer some suggestions. At net.minecraft.world.gen.structure.StructureVillagePieces.getStructureVillageWeightedPieceList(Random random, int size), there's already a call to Forge's "addExtraVillageComponents". Maybe there could be something there to remove components, as well. Then, I could remove the vanilla structure and add my own. But while removing structures could be nice for some mods, and it'd work fine on its own for me, it isn't the ideal when it comes to intermod compatibility since all I want to do is make some minor adjustments -- adjustments that could, presumably, happen in conjunction with other mods' adjustments to the same structure. Perhaps the ideal for me is an Event that fires within net.minecraft.world.gen.structure.StructureStart.generateStructure(World, Random, StructureBoundingBox) just after structurecomponent.addComponentParts is called (if that call was a success), something that is passed all the arguments addComponentParts is to be passed and also structurecomponent itself (so the event tells us which component this was). So, the event would act as a pseudo-post-hook for the addComponentParts call.
-
Edit: Ignore the following post. I'm still looking for help with the OP, but I figured out what went wrong with the below. (The issue was that Forge doesn't handle villages on superflat worlds the way it does for regular worlds, meaning there is no InitMapGenEvent for them. I think that Forge probably should do so since testing this stuff out is much more difficult as is, but that isn't what this thread is about.)
-
I'm trying to slightly modify the world generation of a structure created within villages. Specifically, I want to add a chest with loot (and maybe a few more blocks down the road) to the church. What is the best way to go about this? I've poked around rather extensively in the code and there doesn't seem to be a way to be notified that that specific building was generated and where so I can simply plug my block(s) in. There is an event that informs about a village being generated but I didn't see anything more specific than that. Would I need to replace the church with my own church building? If so, what's the best way to go about that? Wouldn't that mess with cleric villager spawning and possibly other things?
-
Here's the relevant bit: Edit: Somehow this was posted while I was still editing it. I wanted to put it in a spoiler but that doesn't seem to be working, and some of it's in italics for some reason (and I can't turn that off). Getting JavaScript errors when I try to do much editing. Something's wrong with the forums, it seems.
-
I've got a custom GUI element that acts as a pseudo-item-slot, rendering an item icon and showing the item's tooltip when the cursor is over it. I use the renderToolTip in GuiScreen to do this as that seems to be how vanilla does it. It shows the tooltip as I'd expect for the most part, including whatever the item adds through the addInformation method. The problem is that mods like NEI and Waila are supposed to add to the tooltip (such as one showing the mod the item comes from) but this is not added to my tooltips. I've done extensive searches in NEI to see where addInformation is called and so on to see if there's some other method for me to call instead of renderToolTip, but I don't see anything relevant. I'm quite sure I've got the right method, and yet it doesn't do for my custom GUI element what it does for vanilla Slots.
-
curious about the newest forge version v1.7.10
Tuhljin replied to classlessrook32's topic in Modder Support
Just to double check this -- so, barring the use of certain functions removed in 1.7.10 (as mentioned here), any 1.7.2 mod should work with 1.7.10 and vice versa? No need to maintain two development environments and two version of the mod? -
[1.7.2]Packet Handler Illegal State Exception
Tuhljin replied to Democretes's topic in Modder Support
I had a similar crash when I didn't put in a constructor that took no parameters. It was required, even if it seemingly didn't do anything. PacketMatrix.Handler doesn't have one. Try something like this: public Handler() { } -
Giving players potion effects when hit by a projectile
Tuhljin replied to Sear_Heat's topic in Modder Support
Not sure what type of projectile you've got going there, but if it extends EntityThrowable then you can override the onImpact method. You can see how vanilla's EntityEnderPearl deals damage to what it hits there. If it's more like an arrow, then perhaps you can override onCollideWithPlayer. Not sure how that will work out, though. EntityArrow does it but only for letting players pick up their arrows again, not to deal damage. You'd probably instead have to override onUpdate and handle the flying through the air and all that yourself (you could mostly copy EntityArrow so it shouldn't be too bad) or use a method like that suggested above. -
So, a while back I was looking at this tutorial on the wiki and I noticed that the code there declares two private methods: adjustLightFixture and adjustRotatePivotViaMeta. However, I don't see anything that calls either of them. I thought that was odd but soon moved on to rendering a different way so forgot about them. Now, some time later, I happened to find people using the adjustLightFixture in their code posted on forums, github, etc. -- and most of them weren't calling it, either! I get the feeling they simply took it from the tutorial without knowing any better. Is there some reason those methods need to be there as they are? Unless I'm missing something, I think it's just confusing people. I would just edit the wiki myself but I don't want to do alter anything without running it by some more experienced Minecraft modders. Also, I don't know if it'd be better to delete them outright or to put those methods in a separate "extra options" section for those who might benefit from them. Adjusting rotation based on metadata certainly makes sense in many instances... however I'm not entirely sure that the adjustLightFixture is actually necessary at all since the lighting looked okay without it (though I haven't carefully scrutinized the lighting differences between them).
-
Item in Slot 0 of GUI Inventory instantly disappears
Tuhljin replied to Tuhljin's topic in Modder Support
So, I fixed it with a sanity check in my readCustomNBT method: ... byte slot = tagList.getByte("Slot"); if (slot >= 0 && slot < numSlots) { if (inventorySlots[slot] == null) // Prevent inexplicable overwrite of slot 0 inventorySlots[slot] = ItemStack.loadItemStackFromNBT(tagList); } ... But I still don't see why this was necessary. The tutorials and other code from open source projects doesn't have to take these precautions. Now, of course the most important thing is it's working, but I'd still like to get any insight on why that change was necessary in my case and not in others, or more to the point, what I did/didn't do that caused the problem in the first place. -
Item in Slot 0 of GUI Inventory instantly disappears
Tuhljin replied to Tuhljin's topic in Modder Support
Edit: Never mind this second post. I misread something. The problem in the OP still persists, though. -
I have a block with an associated tile entity with an inventory and right-clicking on the block opens a GUI showing the inventory. When you put items in most of the slots, they stay there - including between sessions. However, if you put them in the first slot (slot zero), then the item disappears almost immediately. The slot becomes empty right away visually, but you can still click on it and take the item you put in back out. If you restart the game, then the item is gone permanently. However, if all the other slots are filled, then for some reason, the item in the first slot doesn't disappear, persisting even after a reload. I don't understand how this is happening. I followed video tutorials I found and everything worked fine for them. I made some changes but I see nothing that explains this. I'm not doing any special logic on slot 0 -- it should behave exactly the same as all the other slots as far as I can tell. What am I missing? ContainerVisReader.java TileEntityVisReader.java ModTileEntityWithInventory.java
-
This should help: The relevant portion starts around 7:10 into it.
-
[1.7.2] Mods in Eclipse possible ?(specific Damage Indicator)
Tuhljin replied to Heltrato's topic in Modder Support
If you download the mod CodeChickenCore for 1.7.2 and put it in the eclipse\mods folder, it should let you put other mods in the same folder. -
Recreating tile entity with every metadata update causes problems
Tuhljin replied to Tuhljin's topic in Modder Support
Thanks again! -
[1.7.2][Solved]Need help on learning howto render 2D projectile entities
Tuhljin replied to Taji34's topic in Modder Support
This might help: http://www.minecraftforum.net/topic/1892995-custom-projectile-and-rendering/ -
Recreating tile entity with every metadata update causes problems
Tuhljin replied to Tuhljin's topic in Modder Support
Alright, I'm using this: @Override public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { return oldBlock != newBlock || oldBlock != ModBlocks.redcrystal; } ... where ModBlocks.redcrystal is a static reference to the instance of the block class I'm using. It seems to be working fine. You don't see any problems with this implementation, right? (I'm just being extra cautious since I don't want to leave stranded tile entities around, taking up space or whatever they might do.) -
Recreating tile entity with every metadata update causes problems
Tuhljin replied to Tuhljin's topic in Modder Support
Thank you, I'll try that. But what kind of issues are we talking about and how can I prevent them? It will still destroy the TE when the block is removed and all that normal stuff, right? What kind of gotchas are we talking about? Can I just check the instanceof of the oldBlock vs the newBlock, making sure both are still my custom block (and neither is null) and be okay if I return true in that case? -
Is there supposed to be a new tile entity being created every time the BlockContainer block's metadata is updated? This is causing some annoying graphical issues with my custom-rendered block, which references the tile entity in order to know how it is supposed to be rendered. For a split second whenever the metadata is updated, the way it is rendered will revert to the default as if the saved variables aren't there. This is jarring, as the object can be rotated completely the wrong way. Is there some way to prevent this behavior or is there some other solution anyone knows of? I will note that the graphical issue only seems to be noticeable if the player is close to the block and only if they are looking at it from certain angles (looking downward seems to make it happen most easily).
-
Thanks. Now I assume I still have to have the API code in place so I can reference those classes etc. and have the thing compile, so was I right in placing the API files where I did? (Just in their own folder alongside my mod's in src/main/java .) Are they going to be built into the release and could that be a problem or become one in the future since the API is also included by the main mod and other addons (and later on, possibly different versions of it)?