Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

foul_owl

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by foul_owl

  1. 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.
  2. 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?
  3. 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?
  4. 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.
  5. 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.
  6. 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.
  7. 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?
  8. Thank you! Which iteration of my code? The last attempt?
  9. 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()); } }
  10. 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.
  11. 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.
  12. 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.
  13. 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!
  14. 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.
  15. 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".
  16. Is it possible for a user, in a single player game, to type in "/foo" and have it execute arbitrary code?
  17. My apologies, I thought that the client ran the world gen code for single player games. The client actually runs a local instance of the server?
  18. Assume a player creates a new world. After the world has done its initial generation, either right before the player joins the world or right after, I want to execute my arbitrary code. Let's say print "Hello World" once to the console. How would I go about doing this? Client side only, don't care about server.
  19. Thank you! I am interested in this as well. One small issue: where/how do you register a command on the client side? (Assuming I want a command that only exists on the client) I assumed that something like "serverLoad" would have a companion "clientLoad" but sadly this is not the case.
  20. Thank you! Using IntelliJ. I was now able to successfully locate "SwampHutPiece.java"!
  21. I've been trying to migrate my 1.12 worldgen code over to 1.15. All the advice I have seen on similar topics is "look at how the vanilla source does it". (Swamp huts seem like a good example for my case) Where exactly can I locate the vanilla source? I seem to recall for 1.12 there was a gradle task to decompile, but doesn't seem to be one for 1.15.
  22. Thank you! I am going to start reviewing that information.
  23. As 1.12 is an old version, it's time for me to migrate my mod over to 1.15. This has been going pretty well so far, fixed all the block changes, etc, except for one issue. I don't know how to register my world generator now. 1.12 code: package com.example.examplemod; import net.minecraft.init.Blocks; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Logger; import net.minecraftforge.fml.common.registry.GameRegistry; @Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION) public class ExampleMod { public static final String MODID = "TEST"; public static final String NAME = "TEST"; public static final String VERSION = "0.0.2"; private static Logger logger; @EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); } @EventHandler public void init(FMLInitializationEvent event) { GameRegistry.registerWorldGenerator(new TestWorldGenerator(), 0); } } All I need to do is register my world generator. I know a lot was changed after 1.12, but I can't find any migration documentation. Thank you!
  24. I found a tutorial that basically has exactly what I was looking for: http://www.minecraftforge.net/wiki/Adding_World_Generation Thanks folks!
  25. Understood. But it might be a good way for me to learn how to execute an arbitrary function via keypress. In the meantime, for the sake of avoiding scope creep, I'm back to my original question, ie, changing blocks at the end of stage 4. Thanks!
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.