
foul_owl
Members-
Posts
35 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
I am new!
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
foul_owl's Achievements

Tree Puncher (2/8)
1
Reputation
-
Thank you! I have poked around the vanilla code a bit but wasn't exactly sure what I was looking for in this case. I'll take a look at that class and then go from there.
-
Right now I am happily placing blocks with "setBlockState" but I ran into a small issue. I would like to be able to place a monster spawner. I have tried "Blocks.SPAWNER.getDefaultState()" but I don't have any control over what type of spawner. How exactly would I place a spawner of a specific type?
-
Thank you! Unfortunately the "runClient" task is the majority of the execution time. (about 95% or so) Perhaps there are some jvm args that could help here?
-
This might not be possible, but I figure it is at least worth asking. Right now a build + run takes about 2 minutes. Is there any easy way to speed up the build process? It makes it challenging to iterate quickly.
-
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
Ok, I figured out what the issue is here. The world I have been testing with was in a bugged state. It appears it is possible for the world to get into a bugged state where "getBlockState" shows the block as being one block type, where the player visually sees the block as a different block type. I even tried filling in the area with other blocks, and my "get" code still showed the block state as being diamond. Deleting the world and creating a new one resolved the issue. I didn't try this originally as a build takes ~2 minutes, and generating a world is an additional ~2 minutes. (Even 2 minutes is a long time to wait for a build for me, my C++ projects usually take seconds to build ?) I should have tried a new world sooner, but I simply did not expect a world to get into a state where: setBlockState has no effect. getBlockState does not match the block shown on screen. Replacing the block at the coordinates does not match the block type of "getBlockState". Very strange bug. (Yes, I confirmed my location each time both with "/teleport 50 50 100" and with F3.) In any case, happy to have this issue resolved. -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
Here is my code: @SubscribeEvent public void onChat(ServerChatEvent event){ final String message = event.getMessage(); World world = event.getPlayer().getServer().getWorld(DimensionType.OVERWORLD); if (message.equals("get")) { LOGGER.info("Running get code"); BlockState tmpstate; tmpstate = world.getBlockState(new BlockPos(50, 50, 100)); LOGGER.info("End of get code"); } else if (message.equals("set")) { LOGGER.info("Running test code"); world.setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } Breakpoint is set at the end of the "get" block. -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
I did getBlockState() and set a breakpoint to examine the contents. It's definitely a diamond block, but it appears, visually, to the player as a block of air. Is there some sort of refresh that has to happen after a setBlockState() is called? -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
Thank you! Which iteration of my code? The last attempt? -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
Thank you! Unfortunately, no effect. Same output as before. My code: @SubscribeEvent public void onChat(ServerChatEvent event){ final String message = event.getMessage(); if (message.equals("test")) { LOGGER.info("Running test code"); event.getPlayer().getEntityWorld().setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
I saw the "getServerWorld()" method from poking around and tried: @SubscribeEvent public void onChat(ServerChatEvent event){ final String message = event.getMessage(); if (message.equals("test")) { LOGGER.info("Running test code"); event.getPlayer().getServerWorld().setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } Again, same issue. I get the logger output but no effect. -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
Tried one more thing for the hell of it. Skipped the "world" variable entirely: @SubscribeEvent public void onChat(ServerChatEvent event){ final String message = event.getMessage(); if (message.equals("test")) { LOGGER.info("Running test code"); event.getPlayer().getServer().getWorld(DimensionType.OVERWORLD).setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } Same thing, I get the logger output but no effect. -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
Understood, thank you. I found this post: https://www.minecraftforge.net/forum/topic/82415-how-to-get-current-world-so-i-can-use-setblockstate-1152/ Which seems close to what I want to accomplish, so I tried: @SubscribeEvent public void onChat(ServerChatEvent event){ final String message = event.getMessage(); World world = DimensionManager.getWorld(event.getPlayer().getServer(), DimensionType.OVERWORLD, true, true); if (message.equals("test")) { LOGGER.info("Running test code"); world.setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } Same issue, no effect. So then I figured maybe I am complicating things with the dimension manager, so I also tried: @SubscribeEvent public void onChat(ServerChatEvent event){ final String message = event.getMessage(); World world = event.getPlayer().getServer().getWorld(DimensionType.OVERWORLD); if (message.equals("test")) { LOGGER.info("Running test code"); world.setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } Same issue. I see "Running test code" but the block does not change. I'm sorry, I really don't know what I'm doing wrong. Thank you so much for all the help. -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl replied to foul_owl's topic in Modder Support
Thank you! My code now looks like this: private MinecraftServer server; @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { // do something when the server starts LOGGER.info("HELLO from server starting"); server = event.getServer(); } @SubscribeEvent public void onChat(ServerChatEvent event){ final String message = event.getMessage(); if (message.equals("test")) { LOGGER.info("Running test code"); server.getWorld(DimensionType.OVERWORLD).setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } Unfortunately same issue here. I can see the logger output "Running test code" but the block does not change. Thank you so much for the help! -
[1.15.2] (Solved) How to setBlockState in ClientChatEvent?
foul_owl posted a topic in Modder Support
private MinecraftServer server; @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { // do something when the server starts LOGGER.info("HELLO from server starting"); server = event.getServer(); } @SubscribeEvent public void onChat(ClientChatEvent event){ final String message = event.getMessage(); if (message.equals("test")) { LOGGER.info("Running test code"); server.getWorld(DimensionType.OVERWORLD).setBlockState(new BlockPos(50, 50, 100), Blocks.DIAMOND_BLOCK.getDefaultState()); } } If the player says a certain phrase, I want a single block to change. Seems like a very simple task, but unfortunately this has no effect. I do see "Running test code" in the console, so I know it's getting to that point. -
[1.15.2] How to run code after a world has been created?
foul_owl replied to foul_owl's topic in Modder Support
Understood, thank you! Let me readjust my question in that case I would like to execute arbitrary code once the world gen has finished, ie "Hello world".