Jump to content

A Soulspark

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by A Soulspark

  1. 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
  2. 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?
  3. 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)
  4. 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:
  5. 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.
  6. 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.
  7. 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?
  8. huh, I wonder if this even is used in vanilla at all. thanks!
  9. 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?
  10. 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)
  11. 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!
  12. 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.
  13. 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!
  14. 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.
  15. That's true, but an empty kettle doesn't need a tile entity, whereas the other two do, and they have other states that are only necessary in each case. e.g. the boiling kettle has a fullness state, for how many uses it has left. this isn't necessary for empty or full kettles, as their "fullness" doesn't change: it's 0% or 100%. Plus, each version also has a different item/name/texture, and it was really troublesome to manage all that in a single item and block. If what I'm trying to do is extremely forbidden, then I could revert ofc. But this just sounds like it makes more sense :v
  16. After accepting the way I was doing things in my mod wasn't quite ideal, I decided I have to upgrade a certain block when users update into the newest version of my mod. This block currently has a Content blockstate (an enum with 3 values) and it should convert into a different block for each value. So, tea_kettle:kettle[content=empty] -> tea_kettle:empty_kettle tea_kettle:kettle[content=water] -> tea_kettle:water_kettle tea_kettle:kettle[content=hot_water] -> tea_kettle:boiling_kettle I just don't know how to do that! Maybe I'd need to keep the tea_kettle:kettle block and when it gets instantiated into the world, I immediately run the conversion. But How do I detect a block getting instantiated? Is there a better solution to this?
  17. Yep, this is what I was considering doing too, checking for the LIT state. I think even modded furnaces that don't extend AbstractFurnaceBlock usually still have that. Thanks!
  18. In my mod, you can place a tea kettle block on top of any burning furnace to make it boil. However, I'm only checking if it's an instanceof AbstractFurnaceBlock, which isn't the case for some modded furnaces. How exactly can I add compatibility with these other mods? I could check if the block is in a tag containing many modded furnaces, but how do I check if it's burning then? There must be a better alternative to this.
  19. Ok, that seems to make sense! Though I'm having a bit of trouble with the damaging part, since the getRemainingItems() function only gives you an Inventory. I believe the best way to damage the item is through attemptDamageItem(), but idk how to get a java.util.Random instance in this context. Here's the code for reference: @Override public NonNullList<ItemStack> getRemainingItems(CraftingInventory inv) { // get the default remaining items for a shapeless recipe NonNullList<ItemStack> remainingItems = super.getRemainingItems(inv); // loop through each slot in the crafting inventory for (int i = 0; i < remainingItems.size(); i++) { ItemStack stack = inv.getStackInSlot(i); // if the item in the slot are shears if (stack.getItem() instanceof ShearsItem) { // try to damage the item, but this is *ugly* // how do I get a Random instance here â–¬-â–¬ stack.attemptDamageItem(1, [insert java.util.Random instance], null); // (int amount, Random random, ServerPlayerEntity entity) remainingItems.set(i, stack); } } return remainingItems; }
  20. So, I want to add shapeless recipes where you use Shears + (some item) to craft another item, but the shears stay, albeit with -1 durability. After a bit of a search, it seems like you can use getContainerItem() and similar methods to achieve this, but that's out of scope here with a vanilla item. Then, how am I supposed to approach this? Maybe through a custom recipe type where one of the ingredients stay after crafting, but how do I even do that?
  21. Hmm, I swear I'd tried that before and it wouldn't work, but it did now! Thanks.
  22. It never crashed yet, the IDE that's complaining because it can be null. It's a warning, not an error, so everything compiles fine, but I'm not particularly happy with that code either and I'm wondering if there's a better way to do this.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.