Jump to content

RuthlessNail

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by RuthlessNail

  1. The first method work well with my current tag, I registered all my hammer items in the ModItems class using instance of custom HammerItem class so I probably would have to do it quite differently if I was using the second method (because I testing item -> item instanceof HammerItem prior to this post and it didn't work). Nonetheless, I will change the post topic to solved now. Greatly appreciate your help!
  2. Quite a trivial question I reckon, but my brain just can't figure it out. I want to create a "sharpness-esque" enchantment for my custom hammer tool, I tried using EnchantmentCategory.create, but I seems to be only able to pass in one item at a time. The enchantment currently only work on the wooden hammer I passed in. I hope to make it work on all ItemHammer instance. (I also have a tag for all hammer item set up, but I can't figure out how to pass it in using either method) static EnchantmentCategory HAMMER_TYPE = EnchantmentCategory.create("hammer", item -> item == ModItems.WOODEN_HAMMER.get()); protected HammerHurtEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { super(pRarity, HAMMER_TYPE, pApplicableSlots);
  3. Thanks mate, that makes total sense, I'll test it out right now and see if it works.
  4. So, when I implemented ore generation for my mod, everything's working as expected, except, that my tin ore is a lot rarer than I intended. Not big issue, I thought, then proceeded to bump up the value for vein per chunk. To my surprise, that didn't help, no matter how absurd I altered the value to. But in the end of the day, the ore still generated, so I called it a day and continued working on other stuff. Only today, when I was working on new ores, I discovered that the tin ores are generating in abundance down in y=-40. This made me slowly realise where the issue lie. public static final Holder<PlacedFeature> TIN_ORE_PLACED = PlacementUtils.register("tin_ore_placed", ModConfiguredFeatures.TIN_ORE, commonOrePlacement(32, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-16), VerticalAnchor.aboveBottom(94)))); public static final Holder<PlacedFeature> TIN_ORE_LARGE_PLACED = PlacementUtils.register("tin_ore_large_placed", ModConfiguredFeatures.TIN_ORE_LARGE, commonOrePlacement(16, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-16), VerticalAnchor.aboveBottom(94)))); Here in this section of my ModPlacedFeatured.java, I think I misunderstood the 'VerticalAnchor.aboveBottom' value, I thought it means my ore will only generate between y=-16 to y=94, and will be most commonly found in the y=39 region. However, it is evident that the tin ores are more commonly generated in y=-40 and below, despite the fact they shouldn't be there in the first place. In an attempt to un-mess up my mess up, I tried to look into what the VerticalAnchor value is for, and did a range of research online. I searched blindly for what I will not find. This is my final desperate cry for help. Edit: Changing the aboveBottom to absolute fixed it, huge thanks
  5. Thank you sir, you are a literal life-saver. This works flawlessly.
  6. I tried to implement a item that can be used multiple time in a crafting recipe, however, each usage will cause the item to lose 1 durability. In my particular example, I made a hammer that can be used with four coal to craft compacted coal, I attempted to implement this by overriding the getContainerItem method, where I basically applied one damage to the item, then returned the damaged item. To my knowledge this should make the damaged item as the container, and that will remain on the crafting grid after crafting is completed, however in practice this implementation doesn't work, and the hammer will still be consumed along with the other ingredients. This is my current code for the WoodenHammer class (excluding the imports): public class ItemWoodenHammer extends Item { public ItemWoodenHammer(Properties pProperties) { super(pProperties.durability(60)); } @Override public boolean isDamageable(ItemStack stack) { return true; } @Override public boolean hasContainerItem(ItemStack stack) { return true; } @Override public ItemStack getContainerItem(ItemStack itemStack) { itemStack.hurt(1, new Random(), null); System.out.println("hammer max durability:" + itemStack.getMaxDamage()); System.out.println("hammer's current state: " + itemStack); return itemStack; } } Here's the compactcoalfromwoodenhammer.json for the recipe: { "type": "minecraft:crafting_shapeless", "ingredients": [ { "item": "ornithophobia:wooden_hammer" }, { "item": "minecraft:coal" }, { "item": "minecraft:coal" }, { "item": "minecraft:coal" }, { "item": "minecraft:coal" } ], "result": { "item": "ornithophobia:compacted_coal" } } As you may see I tried to print out the hammer's max durability and the current state, since I initially suspect either I messed up assigning the durability to the hammer or I messed up with the item hurt method, but the print output suggest that hammer's max durability is 60, suggesting it's applied correctly, and that 1 damage was inflicted on the itemStack when crafting occurred. In addition, the print outputted at all suggest that the getContainerItem method is triggering when the crafting happened, yet still, nothing is left behind on the crafting grid, suggesting that the returning part was somehow broken, and yet I can't figure out how. I am just starting out modding with forge literally two days ago so my implementation of these functions are probably pretty dumb and I probably made some real silly mistake, but I have been trying to debug this for hours and it's seriously giving me a brain aneurysm. Any amount of help/insight is very much appreciated, huge thanks in advance.
×
×
  • Create New...

Important Information

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