deerangle Posted April 17, 2020 Share Posted April 17, 2020 I have a log block in my mod, and I want to make it possible to strip when right-clicked with an axe. Currently, I am using this horrible method with reflection: private static void addStripping() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { Class clazz = Class.forName("net.minecraft.item.AxeItem"); Field map = clazz.getDeclaredField("BLOCK_STRIPPING_MAP"); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(map, map.getModifiers() & ~Modifier.FINAL); map.setAccessible(true); Map<Block, Block> strip_map = (Map<Block, Block>) map.get(null); HashMap<Block, Block> new_map = new HashMap<>(strip_map); new_map.put(Registry.BEECH_LOG_BLOCK, Registry.STRIPPED_BEECH_LOG_BLOCK); new_map.put(Registry.BEECH_WOOD_BLOCK, Registry.STRIPPED_BEECH_WOOD_BLOCK); map.set(null, new_map); } Is there any other way to do this? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted April 17, 2020 Share Posted April 17, 2020 5 minutes ago, deerangle said: Is there any other way to do this? Check out this post. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Recommended Posts
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.