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

[1.7.10][Forge-10.13.2.1291] possible bug with ClientTickEvent


N247S
 Share

Recommended Posts

Hey,

 

I was strugling with some clientside updates, and I noticed that there is a possible bug.

What I did was making a simple Tick Handler, and registered it with this:

		FMLCommonHandler.instance().bus().register(new TickEventHandler());

 

this is the EventHandler class

@SideOnly(Side.CLIENT)
public class TickEventHandler
{
@SubscribeEvent
public void onTickEvent(TickEvent.ClientTickEvent event)
{
	if(event.phase == event.phase.START)
	{
		//some code wich get executed every tick
	}
}
}

 

I added a debug line to this code to see when its called, and I noticed it got called in the following situations:

1. When a world is running (SP)

2. When a world is paused(SP)

3. When a world is closed after it was startup once!!

 

You can imagine that this went pretty crazy with my mod.(and my head!)

I solved the problem for me already, but I was curious if this is something normal, or a bug with this forge version?

 

The solution is as follows:

//if(event.phase == event.phase.START) -  replace this with the following:
if(event.phase == event.phase.START  && !Minecraft.getMinecraft().isGamePaused() && Minecraft.getMinecraft().thePlayer != null)

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

That does seem a bit weird.

 

If you follow the call hierarchy for ClientTickEvent with START phase, it is only called in the onPreClientTick() method, and that is called in the Minecraft classes runTick() and it isn't really qualified in any way (no if-then that might prevent it).

 

So I assume it is being posted as long as a Minecraft is doing a runTick(). So I guess that class is still instantiated and calling runTick().

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

This is not really a bug, just for the record - it was like that since forever, it is ClientTick, not world, nor anything else, also I am myself using this event also since forever and I do same if statement that you are doing in order to make world decrement some integer within server (WorldTick is only (unless something changes lateely) called from Server thread on server worlds, I needed to tick also on client world).

 

Just sharing experience.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

@jabelar

 

I'm not English so I have a hard time understanding what you're trying to point out. But basicly what you're saying is: It shouldn't call the methode, but cause its phase START, its still calling runTick()?

 

No matter how I look at it, it is wierd. I can imagine it will ignore a paused game somehow. but it makes zero sence to me why it is called in the gamemenu(after the world is closed). cause there shouldn't be any tick events possible.

 

Luckly there is a work-around, but I'm sure there are some getting a headache of this.

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

@jabelar

 

I'm not English so I have a hard time understanding what you're trying to point out. But basicly what you're saying is: It shouldn't call the methode, but cause its phase START, its still calling runTick()?

 

No, I'm saying that is the other way around. Minecraft#runTick() always calls the onPreClientTick() which posts the ClientTickEvent.START. So you should see the event as long as there is a Minecraft instance executing runTick(0.

 

Anyway, as Ernio says "client" doesn't strictly mean "world". It just means user interface is running.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

It's not a bug, but just a feature which the client tick event has.

Since client means everything related with gui/rendering, the feature should be reasonable one (at least to me).

 

What I think is strange is that the client tick event is not called when the client main screen shows up.

 

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Here is my configuration: % java -version java version "18.0.2" 2022-07-19 Java(TM) SE Runtime Environment (build 18.0.2+9-61) Java HotSpot(TM) 64-Bit Server VM (build 18.0.2+9-61, mixed mode, sharing) forge-1.19-41.1.0-mdk on macOS Monterey 12.5 I ran the command: ./gradlew genEclipseRuns and was hoping it will generate the Eclipse project files for me. The run log is at https://gist.github.com/arun-gupta/06b983a6976b4c0a0f510d0dc225ddd3 and the generated directory structure is at https://gist.github.com/arun-gupta/3f5bfc70ec5d3d903b0f97d42840abda. In previous versions (1.12-ish), it used to generate an eclipse directory but 1.19 does not seem to have it. I tried opening the top-level forge directory but Eclipse does not recognize it as a project as well. How do I open this project in Eclipse now?  
    • I didn't put in credentials, I used it only for testing installing forge. But still the problem mentioned above.
    • I am trying to use Forge 1.18.2, I have checked my firewall, redownloaded Forge, deleted the fml.toml file (which keeps reappearing) and looked at countless help pages. I am just trying to download and use forge so that I can play with my friends and it will not download. It tells me there may be an issue with the Java runtime config and that the exit code is one, and I have copied the exit code.   
    • Okay, i think i understand but im getting issues, i create another packet to sync entity to another players like this package com.naim.belloto.networking.packet; import com.naim.belloto.networking.handler.ClientSyncHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.network.NetworkEvent; import java.util.Objects; import java.util.function.Supplier; public class ClientSyncPacket { public ClientSyncPacket() { } public ClientSyncPacket(FriendlyByteBuf buf) { } public void toBytes(FriendlyByteBuf buf) { } public boolean handle(Supplier<NetworkEvent.Context> ctx) { NetworkEvent.Context context = ctx.get(); context.enqueueWork(() -> { assert Minecraft.getInstance().player != null; int idplayer = Minecraft.getInstance().player.getId(); DistExecutor.unsafeCallWhenOn(Dist.CLIENT,() -> () -> ClientSyncHandler.handlePacket(ctx, idplayer)); }); return true; } } And in the handler: public class ClientSyncHandler { public static boolean handlePacket(Supplier<NetworkEvent.Context> ctx, int idPlayer) { Minecraft.getInstance().level.getEntity(idPlayer); return true; } } But is not working :// 
  • Topics

×
×
  • Create New...

Important Information

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