lGuestll666l Posted February 2, 2022 Share Posted February 2, 2022 Im trying to use setBlockAndUpdate with my inputs of BlockEvent.EntityPlaceEvent, want to make spawning mobs with structures, like Iron golem. After im checking if its pumpkin and if under it Diamond Block, im using setBlockAndUpdate. It replace Block to air and return it to previous blockState. How i can fix it? Link to comment Share on other sites More sharing options...
Draco18s Posted February 2, 2022 Share Posted February 2, 2022 Show your code. 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 comment Share on other sites More sharing options...
lGuestll666l Posted February 2, 2022 Author Share Posted February 2, 2022 I cant copy it right now but its look like that: @SubscribedEvent public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) { ExampleMod.LOGGER.info("block placed") if (event.getPlacedBlock().getBlockState() == Block.CARWED_PUMPKIN.getdefaultBlockState()) { ExampleMod.LOGGER.info("block is pumpkin") if(Minecraft.getInstance().player.level.getBlockState(New BlockPos(event.getPos().getX(),event.getPos().getY()-1,event.getPos().getZ())) == Blocks.DIAMOND_BLOCK.getdefaultBlockState()){ Level level = Minecraft.getInstance().player.level; level.setBlockAndUpdate(event.getPos(),Blocks.AIR.getdefaultBlockState()); ExampleMod.LOGGER.info("block on Diamond Block"); } } } its works fine but Block dont want to be placed, it turn in air for milisecond and turn to pumpkin back. Link to comment Share on other sites More sharing options...
Draco18s Posted February 2, 2022 Share Posted February 2, 2022 (edited) 5 minutes ago, lGuestll666l said: if(Minecraft.getInstance() You can't do this. You want the blockstate of a block in the world, use the world given to you in the event. You want the player? Use the player given to you in the event. This code will crash dedicated servers. Quote its works fine but Block dont want to be placed, it turn in air for milisecond and turn to pumpkin back. Yeah, because the server says "the fuck you doing client, that position is a pumpkin." Edited February 2, 2022 by Draco18s 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 comment Share on other sites More sharing options...
lGuestll666l Posted February 2, 2022 Author Share Posted February 2, 2022 Ok, i will try this later when i have free time. Thank you in advance. Link to comment Share on other sites More sharing options...
Recommended Posts