Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

 

  • 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

  • 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

 

 

  • 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

  • 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);

}

  • Author

Thank you.  After changing definition from minecraft to world = event.entity.worldObj;  started to see events from the server.

 

Kind Regards 8)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.