Posted May 6, 20205 yr Henlo! I do not know how to place a block. This trouble seems really stupid. I tried to place a block using IWorld.setBlockState(BlockPos pos,BlockState state), but using of this method have caused a misunderstandings with ImmutableMap<K,V> (it needs for instantiating BlockState class) How to place a block?
May 6, 20205 yr IWorld is an interface, which you need to implement the methods yourself where are you trying to use this code? and isn't setBlockState() in IWorldWriter? Edited May 6, 20205 yr by poopoodice
May 6, 20205 yr Please post your code. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
May 6, 20205 yr Author I tried to use this code: @SubscribeEvent public void onBlockHarvested(BlockEvent.BreakEvent event) { IWorld world=event.getWorld(); world.setBlockState(event.getPos(),new BlockState(new Stump(),new ImmutableMap<String,String>())); } But I cannot instantiate the ImmutableMap class and I do not know how it uses
May 6, 20205 yr I assume Stump is a block, you should be able to just call getdefaultstate()... etc instead of create an instance of blockstate Edited May 6, 20205 yr by poopoodice
May 6, 20205 yr Author I asked how to place a block, not about a troubles with my code. Can you give me an example? PS: Problem solved, see previous post Edited May 6, 20205 yr by DeDxYk594
May 6, 20205 yr 7 minutes ago, DeDxYk594 said: Problem did not solved. Can someone give me an example of block placing? Show your updated code whenever you change something and need more help Also, be more descriptive with your errors, does the code compile? Run? Does it crash? Is there a log? The more detail you provide, the less time people will have to spend asking you questions My suggestion when you are trying to do something, is to look through vanilla code for something that does something similar to what you are trying to do, and use it as an example. Find something that sets blockstates and look to see how it does it. Part of the problem I can see, is that you are not using setBlockState correctly. Where did you get your parameters from? I've never seen setBlockState used like that. Look at the method signature to see what parameters it wants.
May 6, 20205 yr 1 hour ago, DeDxYk594 said: @SubscribeEvent public void onBlockHarvested(BlockEvent.BreakEvent event) { IWorld world=event.getWorld(); world.setBlockState(event.getPos(),new BlockState(new Stump(),new ImmutableMap<String,String>())); } You are also setting the block on both sides. Interactions like block placement should only happen on the server side. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
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.