package net.newt.prehistoricascension.block.custom; import net.minecraft.core.BlockPos;…
- User
package net.newt.prehistoricascension.block.custom;
import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.item.BlockItem; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.newt.prehistoricascension.block.ModBlocks;
public class GinkgoKnuckles extends BlockItem {
public GinkgoKnuckles(Block block, Properties properties) { super(block, properties); } @Override public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); BlockPos pos = context.getPos().offset(context.getFace()); // Ensure it's placed on top of ginko_log BlockPos belowPos = context.getPos(); BlockState stateBelow = world.getBlockState(belowPos); if (stateBelow.getBlock() != ModBlocks.GINKO_LOG.get()) { return ActionResultType.FAIL; } // Place the block facing down (i.e., upside down) return super.onItemUse(new ItemUseContext(context.getPlayer(), context.getHand(), new BlockRayTraceResult( context.getHitVec(), Direction.DOWN, pos, false ))); }}
Method does not override method from its superclass Cannot resolve symbol 'ActionResultType' Cannot resolve symbol 'ItemUseContext' Cannot resolve symbol 'World' Cannot resolve method 'getWorld()' Cannot resolve method 'getPos()' Cannot resolve method 'getFace()' Cannot resolve method 'getPos()' Cannot resolve method 'getBlockState(BlockPos)' Cannot resolve symbol 'ActionResultType' Cannot resolve method 'onItemUse' in 'BlockItem' Cannot resolve symbol 'ItemUseContext' Cannot resolve method 'getPlayer()' Cannot resolve method 'getHand()' Cannot resolve symbol 'BlockRayTraceResult' Cannot resolve method 'getHitVec()'
Assistant
Ah, I see the issue. You're using newer Minecraft version syntax (1.18+) but some of the class names and methods have changed. Here's the corrected version with the proper imports and updated method names:
package net.newt.prehistoricascension.block.custom; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.newt.prehistoricascension.block.ModBlocks; public class GinkgoKnuckles extends BlockItem { public GinkgoKnuckles(Block block, Properties properties) { super(block, properties); } @Override public InteractionResult useOn(UseOnContext context) { Level level = context.getLevel(); BlockPos pos = context.getClickedPos().relative(context.getClickedFace()); // Ensure it's placed on top of ginko_log BlockPos belowPos = context.getClickedPos(); BlockState stateBelow = level.getBlockState(belowPos); if (stateBelow.getBlock() != ModBlocks.GINKO_LOG.get()) { return InteractionResult.FAIL; } // Place the block facing down (i.e., upside down) return super.useOn(new UseOnContext( context.getLevel(), context.getPlayer(), context.getHand(), context.getItemInHand(), new BlockHitResult( context.getClickLocation(), Direction.DOWN, pos, false ) )); } }Key changes made:
ActionResultType→InteractionResultItemUseContext→UseOnContextWorld→LevelonItemUse→useOngetWorld()→getLevel()getPos()→getClickedPos()getFace()→getClickedFace()BlockRayTraceResult→BlockHitResultgetHitVec()→getClickLocation()- Added missing parameters in the
UseOnContextconstructor
This version should work with modern Minecraft versions (1.18+). The functionality remains the same - it checks if the block is being placed on a Ginko Log and forces it to be placed facing downward.
You'll also need to make sure this block is properly registered in your
ModBlocksclass. Let me know if you need help with the registration part as well!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.