Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jonaskohl

Members
  • Joined

  • Last visited

Everything posted by jonaskohl

  1. I realized that I'm still on 1.16.4 with MCP mappings, so I probably can't expect any support... (I tried upgrading the mod to 1.18.2, but that went, uhm, let's say horrible, as so much has changed between 1.16.4 and 1.18.2 and I couldn't find a migration guide, so the mod would require a major rewrite, but that's an entierly different topic...)
  2. I'm sorry if this is a stupid question, but how would I do that? Because right now, the PlayerEntity is never an instance of ServerPlayerEntity (my check never returns true)
  3. I am trying to implement a right-click interaction between a vanilla tool and a vanilla block (so I can't use onBlockActivated or onItemUse). Everything is working fine except my call to ItemStack#attemptDamageItem, because the PlayerEntity I get from PlayerInteractEvent.RightClickBlock#getPlayer() is an instance of ClientPlayerEntity, not a ServerPlayerEntity. However, ItemStack#attemptDamageItem expects a ServerPlayerEntity only. I tried passing in null as the damager parameter, and this almost works, but the item doesn't break when reaching 0 durability. This may be, because the ITEM_DURABILITY_CHANGED trigger never fires when damager is null. Now my question: How can I get access to a ServerPlayerEntity instance, or alternatively, how can I make sure the item breaks when reaching 0 durability? My code looks as follows:
  4. I'm trying to add a custom tree to my mod. I'm using the following method to register the tree: //// == ElderTree.java == //// public class ElderTree extends Tree { @Nullable @Override protected ConfiguredFeature<BaseTreeFeatureConfig, ?> getTreeFeature(Random randomIn, boolean largeHive) { return (ConfiguredFeature<BaseTreeFeatureConfig, ?>) ModFeatures.ELDER_TREE.get(); } } //// == ModFeatures.java == //// // [...] public static final Lazy<ConfiguredFeature<? extends IFeatureConfig, ?>> ELDER_TREE = register("elder_tree", () -> Feature.TREE.withConfiguration(Configs.ELDER_TREE_CONFIG) .withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT) .withPlacement(Placements.ELDER_TREE_PLACEMENT) ); // [...] public static final class Configs { public static final BaseTreeFeatureConfig ELDER_TREE_CONFIG; // [...] static { ELDER_TREE_CONFIG = new BaseTreeFeatureConfig.Builder( new SimpleBlockStateProvider(ModBlocks.ELDER_LOG.get().getDefaultState()), new SimpleBlockStateProvider(ModBlocks.ELDER_LEAVES.get().getDefaultState()), // Radius | Offset | Height new BlobFoliagePlacer(FeatureSpread.create(2), FeatureSpread.create(0), 3), // Base height | Height Rand A | Height Rand B new StraightTrunkPlacer(4, 2, 0), new TwoLayerFeature(1, 0, 1) ) .setIgnoreVines() .build(); } // [...] } But whenever I try to grow a sapling or generate a new world, Minecraft crashes with the following exception: [13:25:21] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server java.lang.ClassCastException: net.minecraft.world.gen.feature.DecoratedFeatureConfig cannot be cast to net.minecraft.world.gen.feature.BaseTreeFeatureConfig at net.minecraft.block.trees.Tree.attemptGrowTree(Tree.java:28) ~[forge:?] {re:classloading} at team.mixxit.allotment.blocks.ModSapling.placeTree(ModSapling.java:50) ~[?:?] {re:classloading} at team.mixxit.allotment.blocks.ModSapling.grow(ModSapling.java:71) ~[?:?] {re:classloading} at net.minecraft.item.BoneMealItem.applyBonemeal(BoneMealItem.java:73) ~[forge:?] {re:classloading} at net.minecraft.item.BoneMealItem.onItemUse(BoneMealItem.java:36) ~[forge:?] {re:classloading} at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:613) ~[forge:?] {re:classloading} at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:191) ~[forge:?] {re:classloading} at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:359) ~[forge:?] {re:classloading} at net.minecraft.network.play.ServerPlayNetHandler.processTryUseItemOnBlock(ServerPlayNetHandler.java:986) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:45) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:12) ~[forge:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:758) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:159) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:741) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:735) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:122) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:721) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:667) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) ~[forge:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {} It seems that ConfiguredFeature#withPlacement(ConfiguredPlacement<?>) is the culprit, as it adds a DecoratedFeatureConfig to the feature. What is the proper way to add a placement rule to a tree?
  5. I want to add a recipe to my mod that has a block (let's say wooden planks) and a vanilla tool (let's say an axe) and I want the axe to loose durability when used in crafting. This is what I got so far (inside of ModRecipeProvider#registerRecipes): Ingredient axeIngredients = Ingredient.fromItems( () -> Items.WOODEN_AXE, () -> Items.STONE_AXE, () -> Items.GOLDEN_AXE, () -> Items.IRON_AXE, () -> Items.DIAMOND_AXE, () -> Items.NETHERITE_AXE ); ShapelessRecipeBuilder.shapelessRecipe(ModBlocks.CHIPPED_OAK_PLANK.get()) .addIngredient(Blocks.OAK_PLANKS) .addIngredient(axeIngredients) .addCriterion("has_plank", hasItem(Blocks.OAK_PLANKS)) .build(consumer); However, this will consume the axe completely when crafted. How can I make the axe stay inside of the crafting grid and lose one point of durability? (Forge 1.16)
  6. I am using the following snippet inside of an onBlockClicked event listener to strip a custom log. Everything works as expected, except the axe doesn't "swing" as it does with vanilla blocks. It just does nothing. I tried using playerentity.swingArm(event.getHand()); but that does absolutely nothing. How can I achieve a swinging tool?
  7. That did the trick! Thank you so much!
  8. In my mod I have several custom flower types (instances of FlowerBlock), which I register using the DeferredRegister. Now I want to add them to the composter's registry of compostable items. I know I need to add them to ComposterBlock.CHANCES, but I don't know when exactly I need to do this. When I call ComposterBlock.CHANCES.put() in my mod's main class's constructor, I get a NullPointerException with the message 'Registry Object not present: my_mod:my_flower', even though I created the flower objects before I tried to register them. I suspect I need to call this at a later time, but I couldn't find any information about this anywhere.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.