-
Posts
424 -
Joined
-
Last visited
Everything posted by Daeruin
-
[SOLVED] [1.12.2] Player gets stuck in modified collision boxes
Daeruin replied to Daeruin's topic in Modder Support
Can you explain why you think this would help? I was guessing that maybe EntityPlayerSP#pushOutOfBlocks was trying to push the player out of the block, but then the player was falling back in, and was therefore getting stuck. So I tried cancelling PlayerSPPushOutOfBlocksEvent in the same conditions under which I'm modifying the collision boxes. No effect. -
Just edit the post and add [SOLVED] to the title.
-
I'm trying to do some fancy stuff to mimic the behavior of the mod Repose, where blocks whose collision box is normally a full cube will act as stairs when you're walking up a slope. This makes it so you don't have to jump so much. My code kinda works, but the player gets stuck inside the block. It's almost like the collision boxes are getting modified only some of the time, then changing back to a full cube and trapping the player. Sometimes I can get out for a second but then I get pulled back into the block. I initially suspected some kind of syncing problem, but it behaves the same when I run it on the server only and when I run it on both sides. It does nothing when run on the client only. Do I need to send some kind of packet to the client? Any idea what's going on?
-
Assuming Draco18s is right, you could do something like this: Subscribe to the PlayerInteractEvent.RightClickBlock event. Use RightClickBlock#getFace to get which side of the block was clicked. Use BlockPos#offset to get the position of the block that's adjacent to the one clicked. Use World#getBlockState to get the IBlockState at the position you obtained in the prior step. Use IBlockState#getBlock to get the Block at that position. Check if the block is a water block, and if so, use World#setBlockState to place your mud block.
-
One thing you might want to think about is what happens if someone breaks the torch and picks up the ItemBlock. Should the torch last forever in their inventory? What if they re-place the torch? Do you start the countdown over again? You might consider creating your own Block and/or ItemBlock. You could use a tile entity for the block and the damage field of the ItemBlock to keep track of their age.
-
You want the player to run all the time? Or just sometimes? When and where do you want the blocks to be placed? Player movement is controlled on the client side. You may want to subscribe to the PlayerTickEvent, check that you're on the client, and adjust the player's speed at that point.
-
[1.12.2] Make biomes spawn only in specific locations
Daeruin replied to Daeruin's topic in Modder Support
I think I have figured this out. First I want to make it clear I wasn't doing this for a custom biome. My intent was to control where vanilla biomes appear, based on latitude (how far in the Z direction you go). I wanted hot biomes only to appear near Z=0, and get progressively cooler the further you go in either Z direction. I established an arbitrary "north/south pole" beyond which everything is cold and icy no matter how far you go. I didn't try messing around with the BiomeProvider#getBiomesForGeneration or BiomeProvider#getBiomes since at that level we're working only with chunks. It seemed to difficult to me to change the biome for a given chunk and still ensure neighboring chunks also get updated with the correct biome, without doing some weird storing or searching of what biomes were assigned nearby. Perhaps I was wrong about that assumption, but in any case I felt the need to interrupt the regular biome choice much earlier in the process, during the GenLayer construction. I ended up doing a deep dive into world generation and learned a lot of stuff about how GenLayers work. To solve this, I ended up creating my own world type and overrode WorldType#getBiomeLayer to supply a custom GenLayerBiome class instead of the vanilla GenLayerBiome. In the GenLayerBiome class, during the GenLayerBiome#getInts method, it checks to see which biome categories have been chosen (DESERT, WARM, COOL, or ICY). I jacked into the process there and overrode that method, where I checked the current Z position and swapped the category as desired. The tricky part was that the position values at this point are not chunk coordinates or block coordinates—they have been adjusted relative to biome size during the GenLayer process. Default biome size is 4, but I'm using a biome size of 6 (aka Large Biomes). It took me some time to figure out how to translate the position values into actual block coordinates so I could figure out a rough location on the Z axis. I have only done a small amount of testing so far, but it's looking promising. I noticed a weird biome boundary at one point, where there was an unnatural cliff that hadn't been smoothed out. So I'm sure I will have tweaking to do. I may have to change something in the GenLayerEdge or GenLayerBiomeEdge classes. Not sure. -
[1.12.2] Stop rain splash particles from spawning
Daeruin replied to Daeruin's topic in Modder Support
I have technically solved this issue by replacing EntityRenderer with my own that duplicates basically everything except some customization in addRainParticles. It seems to be working fine, but it feels like I've used a sledgehammer when I'd rather be using a chisel. I would welcome any more insight into making your other suggestions work. Otherwise I'll mark this solved and move on. Hopefully Forge provides a hook into that method at some point. -
PlayerInteractEvent.RightClickEmpty
-
[1.12.2] Make biomes spawn only in specific locations
Daeruin replied to Daeruin's topic in Modder Support
I've read your tutorial. In fact, your site is often my first stopping point when doing research. That's what got me looking at BiomeProvider and GenLayerBiome. I'm pretty sure this is where the biomes are actually chosen, but most of the variables and numbers are totally cryptic to me at this point. I already have a custom dimension and chunk generator that mostly mimics ChunkGeneratorOverworld (the only change I've made so far is to remove some vanilla structures). It looks like setBlocksInChunk gets the biomes that are supposed to be generated for a new chunk. I think it gives a list with a biome assigned to each column in the chunk. I could edit the list right there, except it seems like I'd have a hard time making sure I stitch the biomes together correctly without creating a complete mess. I'd be guessing about which biome to use and still match neighboring chunks. It seems like I need to intercept the process earlier, before it decides which biome to use. So from there I have followed the trail to BiomeProvider#getBiomesForGeneration. But then I get lost. It seems to be getting a list of biomes from some GenLayer class that's supplied by GenLayer#initializeAllBiomeGenerators. That GenLayer class seems to be the first one in a list that initializeAllBiomeGenerators creates through some insane amount of other GenLayer calls. One of which is GenLayerBiome, which seems promising because it seems to be the only place that refers to Biome type (cool, warm, etc.). That's as far as I've gotten in several hours of research. -
I would like to control where biomes spawn. I'd like them only to spawn at certain Z values depending on their temperature. I think I'm poking around in the right set of classes (BiomeProvider and GenLayerBiome), but this world gen stuff is so convoluted, it's taking me forever to make tiny bits of progress. If someone can point me in the right direction and tell me which methods to look at and what bits to tweak, I'd much appreciate it.
-
You might be interested in some tutorials as well: Shadowfacts' tutorials—covers most of the basics Jabelar's tutorials—covers a lot of stuff in depth that's not covered anywhere else, also has a list of other tutorials Choonster's TestMod3—tons of great example code covering lots of things modders commonly want to do, although sometimes uses advanced Java concepts that are tough for beginners TheGreyGhost's MinecraftByExample—again, lots of great example code
-
OK, the method maybe isn't named something obvious. It's getHealAmount.
-
This is a question that's you should learn how to answer for yourself. Do you know how to use your IDE to see what methods are available? Have you tried looking at a vanilla food item? The methods you're looking for will only be available for items that extend ItemFood, so make sure you're checking that first.
-
{SOLVED} [1.8.9] How to right-click with specific Item drop ItemBlock
Daeruin replied to IlTosaerba's topic in Modder Support
If you're already using Shadowfacts and you need something more, I would recommend the following: Jabelar's tutorials—covers a lot of stuff in depth that's not covered anywhere else, also has a list of other tutorials Choonster's TestMod3—tons of great example code covering lots of things modders commonly want to do, although sometimes uses advanced Java concepts that are tough for beginners TheGreyGhost's MinecraftByExample—again, lots of great example code The best thing for you to do by far is to keep examining vanilla code and figuring out how it works. Think of something in vanilla that already does what you want, or something similar, and figure out how they do it. And keep digging deeper into Java. -
{SOLVED} [1.8.9] How to right-click with specific Item drop ItemBlock
Daeruin replied to IlTosaerba's topic in Modder Support
Depends a lot on what you want to do. I usually recommend Shadowfacts tutorials for the basics. -
[1.12.2] Stop rain splash particles from spawning
Daeruin replied to Daeruin's topic in Modder Support
I still don't understand when I would do this. Is there some Forge event that gives me access to the particle? -
[1.12.2] Stop rain splash particles from spawning
Daeruin replied to Daeruin's topic in Modder Support
I just read through your article on particles. I have the general idea of how to create a custom particle. However, I don't understand how I would make the vanilla particle invisible. How would I replace the vanilla texture with something transparent, while still using the vanilla texture for my custom particle? -
[1.12.2] Stop rain splash particles from spawning
Daeruin replied to Daeruin's topic in Modder Support
Well, I tried creating a new IWorldEventListener. I like the idea because it doesn't duplicate code like copying EntityRenderer. However, I must be doing it wrong. I keep getting errors—three different ones so far. A ConcurrentModificationException from RenderGlobal.updateClouds(RenderGlobal.java:1245), and then a ticking world exception and ticking block exception, both from PrimalWorldEventListener.notifyBlockUpdate. Here's my code. I suspect I'm mixing up sides or incorrectly referring to RenderGlobal, or something like that. I don't know enough about what I'm doing here. -
[1.12.2] Stop rain splash particles from spawning
Daeruin replied to Daeruin's topic in Modder Support
I kinda like this idea. It's not too invasive. It may not be compatible with texture packs if they're changing rain particles, but that's not horrible. Maybe I'll give this a try. -
[1.12.2] Stop rain splash particles from spawning
Daeruin replied to Daeruin's topic in Modder Support
Fair enough. It's no more drastic than copying the entire EntityRenderer. I want to understand the original idea better. This is the first time I've looked at IWorldEventListener. In that old post, you said to create a new IWorldAccess (now called IWorldEventListener, I guess) and farm out all the methods to RenderGlobal. Then use World#removeEventListener to remove RenderGlobal as a world event listener, and add my own. RenderGlobal does a lot more than just the stuff involved in being an IWorldEventListener. If I remove it as an event listener, I presume it still continues doing all that other stuff? -
[1.12.2] Stop rain splash particles from spawning
Daeruin replied to Daeruin's topic in Modder Support
I went ahead and did this. I created a class that extends EntityRenderer, hoping to just override the one method. Unfortunately, EntityRenderer#addRainParticles is private, so I couldn't override it. I had to override its calling class, EntityRenderer#updateRenderer. That method refers to tons of private variables that are also modified in other methods. I ended up just duplicating the entire class to make sure I'm covering all my bases. It seems to work, but it feels kinda yucky to me. I'm duplicating a ton of code that might get updated by Mojang or Forge in a future update. I'm not confident that I would remember to check and update my copied code. Plus this way of doing it prevents other mods from replacing the renderer. Can this be done dynamically? I don't want to remove the particles completely. I just want to control when they appear. Done. I hope they do it. -
Short version: Is there any way you can think of to prevent rain splash particles from appearing (short of canceling the weather entirely)? I've looked all through Forge's events and didn't see anything promising, but maybe I overlooked some event that lets me see what kind of particle is about to be spawned, or rendered, and cancel it. Long version: If you've seen my recent posts, you know I'm playing around with weather. I've managed to make it snow and rain based on things like season, altitude, etc. However, when I make it snow in a biome that's normally warm, I get rain splash particles and rain sound effects. These come from EntityRenderer#addRainParticles. There is no Forge hook in that method or anything that calls that method, until you work up to the generic ClientTickEvent. Which is unfortunate, because there's a handy Forge hook in EntityRenderer#renderRainSnow—but the snow and rain itself is only part of the story. Seems kind of half-baked to be able to change how rain renders, but not the rain splashes. I've already toyed around with changing the temperature of biomes via reflection, but it really doesn't work for me since I'm varying temperature, and therefore weather, based on latitude (Z position in the world). I'm planning to update world generation to prevent deserts spawning at extreme Z values. I found this nice idea from diesieben7, but I'm hoping for something a little less drastic: I'm afraid I may have to use ASM to change EntityRenderer#addRainParticles. That makes me sad because I thought I was going to be able to avoid ASM. (I haven't tried it yet, but I'm pretty sure I can cancel the rain sound using the SoundEvent.)
-
I somehow missed that you were adding this capability to vanilla blocks. You might consider creating a custom item that drops instead of the vanilla item when a vanilla block with your Capability is broken. You could write the NBT data to the custom item during the HarvestDropsEvent and remove the vanilla drop. If you wanted, you could even give the custom item the same texture and unlocalized name to make it appear like the vanilla version. Then have the custom item place the vanilla block when right clicked.
-
I did something like this with a container that keeps its contents when broken, but my memory is of it is a little fuzzy. I think you can write NBT data to the dropped ItemStack, but you have to override Block#removedByPlayer to return true if willHarvest is true, in order to prevent the tile entity from being deleted too early in the process. Then override harvestBlock, I think, to write the NBT data into an ItemStack and spawn it as an EntityItem.