-
[1.16] Making a vanilla block replaceable
hah, that works, but lacks sound effects, hooks and the checks that ensure you are allowed to place the block. I'll try using a block item to emulate the behavior of placing, or just replicate all those extra tidbits
-
[1.16] Making a vanilla block replaceable
huh, that's clever, wonder why I went with such a difficult path for the detection xd I still need to figure out the placement logic. do I really have to copy all the code that vanilla uses for normal block placement?
-
[1.16] Making a vanilla block replaceable
My tea mod adds kettles, and now these should be placeable on top of campfires. Obviously campfires can't do that on their own, so I created a new block that looks like a campfire with one on top. My problem is with "placing" the block. I'm currently doing it by detecting the RightClickBlock event when you right click a campfire, then changing the block, but this seems to be unnecessarily difficult, as I have to account for all the block placement rules again. Is there a simpler way to do this? I saw there is an replaceBlock() method I could override, except I can't, I'd have to override from vanilla T-T Here's my code. I gave up on this path once I realized you could place it even when the kettle was "inside" you (eg. you were standing on the campfire)
-
Block with multiple parts (1.16)
well, I think I understand what the mod is doing. it makes a second raycast everytime the block is interacted with to determine what part is being interacted with. except the way it does that raycast is through a function in BlockState called collisionRayTrace, which doesn't exist in 1.16. still, I'll try out another method that sounds like it should work (VoxelShape.rayTrace). we'll see! EDIT: it does! hooray, that made my day ^^ Here's the code for reference:
-
[1.16.5] A few questions about various stuff
I believe the problem is because in your code you assign ESSENSE_BLOCK_DARKNESS to a new Block(), which does not have directionality, and so none of the variants in your blockstates definition will ever apply. In order to fix this, you probably want to create a class for your blocks that extends HorizontalBlock (take a look at the GlazedTerracottaBlock class as an example), and in the register method, use that class instead of Block.
-
Block with multiple parts (1.16)
Yeah, that sounds close to what I had in mind! But how should I go about detecting what part of the block was interacted with? For example, in the onBlockActivated method, what information could I use to determine if you right-clicked the kettle or the campfire? you should be able to pick up the kettle by right-clicking it, but not the campfire. Same problem for the dropping: how do I check if you broke the kettle or the campfire? if you only broke the kettle, it should only remove the kettle, not both parts.
-
Block with multiple parts (1.16)
someone suggested me to add the ability to place my mods' kettles on campfires to boil the water in them. these would be a block with two parts: the kettle and campfire, which can be interacted with and broken separately. while I could think of ways to implement the rendering, I'm not quite sure how to detect when the player broke or interacted with each part of the block. I considered the Forge Multipart lib, but that's outdated right? is there another way to do this?
-
Optional Loot Tables (only load if a mod is present)
huh, I wonder if this even is used in vanilla at all. thanks!
-
Optional Loot Tables (only load if a mod is present)
wait, you can use tags for an entry result? interesting so if I have multiple items in that tag, it'll drop one at random?
-
Optional Loot Tables (only load if a mod is present)
In my mod there are some compatibility blocks to better work with other mods. The problem is, these mods aren't always loaded of course, they're not dependencies! So, I have to make sure to check if they're loaded before the loot tables loaded, otherwise it throws annoying errors at the console. I asked this question earlier in the Discord, and Unbekannt suggested to load a datapack conditionally, with all the loot tables inside it. Not quite sure how I do that tho, and if there are any better alternatives? 🤔 (I tried using the LootTableLoadEvent to disable loading certain loot tables if the mod wasn't there, but it seems to only call for vanilla recipes)
-
[1.16] Soft dependency for a mod (running code if a mod is loaded)
Amazing, thanks for the help!
-
[1.16] Soft dependency for a mod (running code if a mod is loaded)
Huh, I didn't know that! So an import is just a thing to help code readability? Oh, I saw a post of yours from a few years ago describing this process, but I wasn't sure if it still applied today. I'll do that then, thanks!
-
[1.16] Soft dependency for a mod (running code if a mod is loaded)
I'm once again asking about mod compatibility :v This time, it's more of a curiosity than a necessity, as I've already come up with a solution to my problem, but I was wondering: How do you run some code in 1.16 only if a mod is present? I know there is ModList.get().isLoaded(<modid>) but if I import a class that isn't loaded it will still break.
-
[1.16] Converting a legacy block after update
alright, I think this turned out well. I had already done this "multiple items per block" thing before, but this time I managed to solve the duplicate items in Creative by adding a fillItemGroup() override to my items. I still had to split the blocks into Empty and Water Kettles because I'll later add Milk Kettles too. Still, it indeed would've been a lot messier if I'd done it with 3 blocks and 2 tile entities lmao. thanks for the guidance!
-
[1.16] Converting a legacy block after update
ok, I'll try that. but is it possible to have multiple block items for the same block, just with different states? last time I tried this, the Creative inventory got messed up and it just added one of the items multiple times. p.s.: I do need multiple items because there are recipes where only hot kettles can be used.
IPS spam blocked by CleanTalk.