Posted April 16, 20214 yr Can't seem to find much about how to make this work and trying to use code from open source mods doesn't help, Tried using AxeItem.Strippables but that doesn't work either. I'm wondering if there's an easy vanilla way to do this. Googling it doesn't seem to help me either.
April 16, 20214 yr 1 hour ago, immortalcatz said: How would I add that into the class file and which one would that be in? the class for the block you want to make stripabble
April 17, 20214 yr Author Ya but I'm not sure how I would actually add/implement it into the class correctly, and then registering the block correctly in my register class.
April 17, 20214 yr ? Registering the block and overriding a function inside the class are two completely different things Edited April 17, 20214 yr by Turtledove
April 17, 20214 yr Author Okay, I got it working correctly now, but I'm not sure how to make it work with multiple blocks. My Block Code: package expanded.blocks; import javax.annotation.Nullable; import expanded.VanillaBuildingBlocks; import net.minecraft.block.BlockState; import net.minecraft.block.RotatedPillarBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; public class CustomLog extends RotatedPillarBlock { public CustomLog(Properties properties) { super(properties); } @Override @Nullable public BlockState getToolModifiedState(BlockState state, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType) { return toolType == ToolType.AXE ? VanillaBuildingBlocks.acacia_log.defaultBlockState() : null; } } Edited April 17, 20214 yr by immortalcatz
April 17, 20214 yr Author whenever i add more then one log type and i right click it turns into the acacia log, not it's own stripped version.... I'm using vanilla blocks to test it with so I know it's working. *edit: like if I make a spruce and right click with an axe, the spruce log turns into the acacia log, not the stripped version, but the acacia log turns into stripped acacia. Edited April 17, 20214 yr by immortalcatz
April 17, 20214 yr 4 minutes ago, immortalcatz said: whenever i add more then one log type and i right click it turns into the acacia log, not it's own stripped version.... I'm using vanilla blocks to test it with so I know it's working. *edit: like if I make a spruce and right click with an axe, the spruce log turns into the acacia log, not the stripped version, but the acacia log turns into stripped acacia. of course, because you're registering the same class, and in the class you harcoded it to return acacia what you can do is to write one class per log block or make a StrippableLog class, which takes a supplier of the block you want to return in the constructor Edited April 17, 20214 yr by kiou.23
April 17, 20214 yr 2 minutes ago, immortalcatz said: how would I do that with the Strippable Log class? the first way I thought of is to take a supplier of the stripped block in the constructor, and then return that in the proper method
April 17, 20214 yr Author Not sure how I would do that, should I just make the stripped block extend Block or use something else like RotatdPillarBlock?
April 17, 20214 yr Just now, immortalcatz said: Not sure how I would do that, should I just make the stripped block extend Block or use something else like RotatdPillarBlock? yes? you already have the class you called CustomLog, it's the same thing isn't it?
April 17, 20214 yr Author Found a version of what I was trying to do on github, had to tweak it a bit to make it updated to 1.16.5 tho.... package expanded.blocks; import javax.annotation.Nullable; import expanded.VanillaBuildingBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.RotatedPillarBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; public class CustomLog extends RotatedPillarBlock { public CustomLog(Properties properties) { super(properties); } @Override @Nullable public BlockState getToolModifiedState(BlockState state, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType) { Block block = state.getBlock(); if (block == VanillaBuildingBlocks.acacia_log) { return VanillaBuildingBlocks.stripped_acacia_log.defaultBlockState(); } else if (block == VanillaBuildingBlocks.spruce_log) { return VanillaBuildingBlocks.stripped_spruce_log.defaultBlockState(); } else { return super.getToolModifiedState(state, world, pos, player, stack, toolType); } } } in case anyone else needs it.... This is solved now, thanks for all the help. ^^
April 17, 20214 yr 6 minutes ago, immortalcatz said: Found a version of what I was trying to do on github, had to tweak it a bit to make it updated to 1.16.5 tho.... package expanded.blocks; import javax.annotation.Nullable; import expanded.VanillaBuildingBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.RotatedPillarBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; public class CustomLog extends RotatedPillarBlock { public CustomLog(Properties properties) { super(properties); } @Override @Nullable public BlockState getToolModifiedState(BlockState state, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType) { Block block = state.getBlock(); if (block == VanillaBuildingBlocks.acacia_log) { return VanillaBuildingBlocks.stripped_acacia_log.defaultBlockState(); } else if (block == VanillaBuildingBlocks.spruce_log) { return VanillaBuildingBlocks.stripped_spruce_log.defaultBlockState(); } else { return super.getToolModifiedState(state, world, pos, player, stack, toolType); } } } in case anyone else needs it.... This is solved now, thanks for all the help. ^^ that works... but makes the code really hard to mantain and expand upon, imagine you add 50 logs, you'd have 50 else-if statements? the best solution I already told you 2 times, and now the 3rd: simply pass the stripped block to the constructor, and return it in the getToolModifiedState also, you're not checking if the tool is an axe, so any tool would be able to strip the log block EDIT: also, if you need to look up something this basic on github, maybe you should take some time to learn programming beforehand, that'll really make your life modding easier Edited April 17, 20214 yr by kiou.23
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.