Posted June 28, 201411 yr Hopefully somebody can help! Struggling with world.setBlock using forge 1.7.2 and gradle, I have the following code: World world = Minecraft.getMinecraft().theWorld; world.setBlock(xPos+x, yPos+1, zPos+z, Blocks.air,0,0); world.setBlock(xPos+x, yPos, zPos+z, Blocks.coal_block,20,20); I can set blocks within my mod, but the blocks reverts back to what they were before the .setBlock command (ie. if you try and use an item on them). when I exist a world, and return, my changes are gone. Rather than using custom blocks, I want to use standard inventory for the time being (unless I must create a custom block) ? If this something linked to client side changes to server side changes? It appears that I am making changes to a client side (cache) which is then being overidden by the server side cache? Any suggestions please ? Many thanks Lido666
June 28, 201411 yr Author I am calling this from my class which is triggered from the event_bus, eg @SubscribeEvent public void onPlayerUpdate(LivingUpdateEvent event) Where should I setup my event bus from to receive play events ? Many thanks in advance Lide o6666
June 28, 201411 yr Author Thanks for the quick response. Play events are exactly how you described them above. I create the hook on to the event bus using: @EventHandler public void init(FMLInitializationEvent event){ // We add the command below (and a new ItemPickupHandler class), all events now go in that class MinecraftForge.EVENT_BUS.register(new ItemPickupHandler()); It is from this class that I am calling the .setBlock
June 28, 201411 yr Author world.isRemote returns true. I have setup client and server side classes using: @SidedProxy(clientSide = "com.example.examplemod.proxy.ClientProxyClass", serverSide = "com.example.examplemod.proxy.ServerProxy") public static proxyCommon proxy; Do I need to register my event_bus handler from the class ServerProxy ? Many thanks in advance Lido666
June 28, 201411 yr Author Thank you. Even when using 'onLivingUpdateEvent', I only ever get events which are remote. Used the code below, and only received remote events, even when mining, jumping, crafting. Any suggestions please? @SubscribeEvent public void onLivingUpdateEvent(LivingUpdateEvent event) { world = Minecraft.getMinecraft().theWorld; if (world!=null) System.out.println("I am on server" + world.isRemote); }
June 28, 201411 yr Author Thank you. After changing definition from minecraft to world = event.entity.worldObj; started to see events from the server. Kind Regards Lido666
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.