Jessica04 Posted February 12, 2023 Posted February 12, 2023 Hello, I am spawning a command block into the world with the following: mc.world.setBlockState(blockPos, blockState); which works just fine. if (blockState.getBlock() == Blocks.COMMAND_BLOCK){ System.out.println("String thats passed in: " + commandLine); setCommandString(mc.world, blockPos, blockState, commandLine); } private static void setCommandString(World world, BlockPos pos, BlockState state, String command){ System.out.println("SetCommandString String: " + command); TileEntity tileentity = world.getTileEntity(pos); System.out.println("TileEntitySet: " + tileentity); if (tileentity instanceof CommandBlockTileEntity) { CommandBlockTileEntity commandblocktileentity = (CommandBlockTileEntity) tileentity; CommandBlockLogic commandblocklogic = commandblocktileentity.getCommandBlockLogic(); System.out.println("Here!!!!!!!!!!!!!!!!!"); commandblocklogic.setCommand(command); tileentity.markDirty(); world.notifyBlockUpdate(pos, state, state, 3); // CompoundNBT nbt = new CompoundNBT(); // nbt.putString("Command", command); // commandblocklogic.write(nbt); // commandblocktileentity.write(nbt); } } As you can see here, I am trying to "setCommand", however when I check the newly spawned command block, it has nothing written inside of it. Any thoughts on this?
ChampionAsh5357 Posted February 12, 2023 Posted February 12, 2023 The version you are using is no longer supported on this forum. Please update to a modern version of Minecraft to receive support. Currently supported versions are 1.19.3 (Latest), 1.19.2, and 1.18.2 (LTS).
Recommended Posts