Jump to content

urabaros

Members
  • Posts

    59
  • Joined

  • Last visited

Everything posted by urabaros

  1. Ok, but how can I get these parameters from blockstate T.T Sorry, I don't understand.
  2. Thanks! But i think I use 'with' wrong, because I get this mistake: My code: world.setBlockState(blockpos, BlockInit.ROTATABLE_CUSTOM_BLOCK_STRIPPED.get().getDefaultState().with(blockstate.getBlock(), blockstate), 11); What I wrote wrong?
  3. Hello! I'm very new to modding and I'm trying to strip a rotatable custom block. I don't know how to strip it and set a right BlockState, if you know, please help me. What should I write into setBlockState function? public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); BlockPos blockpos = context.getPos(); BlockState blockstate = world.getBlockState(blockpos); blockpos.add(0, 0, 1); if (blockstate.getBlock() == BlockInit.ROTATABLE_CUSTOM_BLOCK.get()) { PlayerEntity playerentity = context.getPlayer(); world.playSound(playerentity, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isRemote) { world.setBlockState(blockpos, BlockInit.ROTATABLE_CUSTOM_BLOCK_STRIPPED.get().getStateAtViewpoint(blockstate, world, blockpos, context.getHitVec()), 11); if (playerentity != null) { context.getItem().damageItem(1, playerentity, (p_220040_1_) -> { p_220040_1_.sendBreakAnimation(context.getHand()); }); } } } return ActionResultType.PASS; }
  4. Thank youuuuuuu that helped!!!!!!!
  5. No, that's strange, but it has only one state. Moreover, even if I wanted to compare block (not blockstate), i don't know how to do it, because this function require BlockState
  6. Hi! I made a stick that would strip special blocks like an axe. These blocks can be stripped ONLY using this stick. It's currently working, but only when block was placed on the ground. If it is placed on the side of another block, it is not working. I think maybe it is something about getDefaultState, because I'm checking block simply through If @Override public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); BlockPos blockpos = context.getPos(); BlockState blockstate = world.getBlockState(blockpos); if (blockstate == BlockInit.CUSTOM_BLOCK.get().getDefaultState()) { PlayerEntity playerentity = context.getPlayer(); world.playSound(playerentity, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isRemote) { world.setBlockState(blockpos, BlockInit.CUSTOM_BLOCK_STRIPPED.get().getDefaultState(), 11); if (playerentity != null) { context.getItem().damageItem(1, playerentity, (p_220040_1_) -> { p_220040_1_.sendBreakAnimation(context.getHand()); }); } } } p.s. Sorry sorry sorry i know my code is kinda bad, I'm only learning.
  7. Thank you! Sorry, I really know java poorly, but I'm definitely going to learn it! Thank you once more!
  8. Hi! I'm trying to make a custom Stick that would strip special custom blocks. I know how to add blocks to BLOCK_STRIPPING_MAP, but my goal is to strip my custom blocks only with my custom Stick, but not with vanilla Axes. I've tried to create StickItem extends ToolItem and copy everything from AxeItem, then change BLOCK_STRIPPING_MAP, but it doesn't help. Moreover, it seems that this stripping depends on ToolType in onItemUse function... so I don't know what to do. Do anyone have any ideas?
×
×
  • Create New...

Important Information

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