
Tuhljin
Forge Modder-
Posts
28 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Tuhljin's Achievements

Tree Puncher (2/8)
2
Reputation
-
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.