@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());
}
}
This snippet of code seems like it should be the "hello world" of forge development. Trivial event, trivial effect.
However, when I type "test" in chat, I can see the correct log output, but the block doesn't change.
Testing in a single player game, my understanding is that any changes to the world have to happen through the server.
I have also 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());
}
}
and
@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());
}
}
All with the same results. What is the correct way to do this? IMO this should be a trivial operation or could easily be the first exercise of a forge tutorial.
Trying to do something as simple as:
This snippet of code seems like it should be the "hello world" of forge development. Trivial event, trivial effect.
However, when I type "test" in chat, I can see the correct log output, but the block doesn't change.
Testing in a single player game, my understanding is that any changes to the world have to happen through the server.
I have also tried:
and
All with the same results. What is the correct way to do this? IMO this should be a trivial operation or could easily be the first exercise of a forge tutorial.
Very strange issue, deleting and recreating the world fixed it.