Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.16.4 Stripping a Rotatable Block

Recommended Posts


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_) -> {
		return ActionResultType.PASS;


Link to post
Share on other sites

you need to get the rotation from the current block, and set the same rotation state to the new stripped block
you can do so by using BlockState#with, and set the orientation

and you can get a state with BlockState#get

  • Like 1
Link to post
Share on other sites

Thanks! But i think I use 'with' wrong, because I get this mistake: 


The method with(Property<T>, V) in the type StateHolder<Block,BlockState> is not applicable for the arguments (Block, BlockState)

My code:

world.setBlockState(blockpos, BlockInit.ROTATABLE_CUSTOM_BLOCK_STRIPPED.get().getDefaultState().with(blockstate.getBlock(), blockstate), 11);

What I wrote wrong?

Link to post
Share on other sites
13 minutes ago, urabaros said:

What I wrote wrong?

the  first parameter (Property<T>) is a BlockStateProperty and not a block, and the second is the value of the Property os like this:

Blocks.ACACIA_LOG.defaultBlockState().setValue(RotatedPillarBlock.AXIS, Direction.Axis.X);


  • Like 1
Link to post
Share on other sites




  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I'm creating a gui (container-less) and for the sake of visual simplicity, I'd like background screen components like the healthbar and hotbar to go away while this screen is open, like how pressing alt+f1 declutters the screen.  Anyone know how I can do this? 
    • Hi forum, I have a problem with forge 1.17.1  Every time i try to start version forge 1.17.1 it says: Game crasht Can Someone help me please Kind regards, Sven
    • I don't even have Optifine installed and the game doesn't start, it crashes right away
    • public enum ModArmorMaterial implements IArmorMaterial { ARGENTITE(Alcamod.ModID + ":argentite", 40, new int[] { 3, 6, 8, 3 }, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3.5F, 0.15F, () -> { return Ingredient.fromItems(ModItems.ARGENTITE_INGOT.get()); }), AZURITE(Alcamod.ModID + ":azurite", 45, new int[] { 3, 6, 8, 3 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3.7F, 0.16F, () -> { return Ingredient.fromItems(ModItems.AZURITE_INGOT.get()); }), EMATITE(Alcamod.ModID + ":ematite", 50, new int[] { 3, 6, 8, 3 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.0F, 0.17F, () -> { return Ingredient.fromItems(ModItems.EMATITE_INGOT.get()); }), BARITE(Alcamod.ModID + ":barite", 60, new int[] { 3, 6, 8, 3 }, 6, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.2F, 0.19F, () -> { return Ingredient.fromItems(ModItems.BARITE_INGOT.get()); }), UNPOWERED_NETHER_STAR(Alcamod.ModID + ":unpowered_nether_star", 70, new int[] { 3, 6, 8, 3 }, 6, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.0F, 0.21F, () -> { return Ingredient.fromItems(Items.NETHER_STAR.getItem()); }), NETHER_STAR(Alcamod.ModID + ":nether_star", 80, new int[] { 3, 6, 8, 3 }, 2, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 5.0F, 0.35F, () -> { return Ingredient.fromItems(ModItems.POWERED_NETHER_STAR.get()); }), INVERTED_NETHER_STAR(Alcamod.ModID + ":inverted_nether_star", 100, new int[] { 3, 6, 8, 3 }, 2, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 6.0F, 0.60F, () -> { return Ingredient.fromItems(ModItems.INVERTED_NETHER_STAR.get()); }); private static final int[] MAX_DAMAGE_ARRAY = new int[] { 11, 16, 15, 13 }; private final String name; private final int maxDamageFactor; private final int[] damageReductionAmountArray; private final int enchantability; private final SoundEvent soundEvent; private final float toughness; private final float knockBackResistance; private final Supplier<Ingredient> repairMaterial; ModArmorMaterial(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterial) { this.name = name; this.maxDamageFactor = maxDamageFactor; this.damageReductionAmountArray = damageReductionAmountArray; this.enchantability = enchantability; this.soundEvent = soundEvent; this.toughness = toughness; this.repairMaterial = repairMaterial; this.knockBackResistance = knockbackResistance; } @Override public int getDurability(EquipmentSlotType slotIn) { return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; } @Override public int getDamageReductionAmount(EquipmentSlotType slotIn) { return this.damageReductionAmountArray[slotIn.getIndex()]; } @Override public int getEnchantability() { return this.enchantability; } @Override public SoundEvent getSoundEvent() { return this.soundEvent; } @Override public Ingredient getRepairMaterial() { return this.repairMaterial.get(); } @Override public String getName() { return this.name; } @OnlyIn( Dist.CLIENT ) @Override public float getToughness() { return this.toughness; } public float getKnockbackResistance() { return this.knockBackResistance; } }  
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.