-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from VazkiiMods/event-bus-wip-stuff
Event bus wip stuff
- Loading branch information
Showing
83 changed files
with
2,495 additions
and
2,203 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 38 additions & 36 deletions
74
src/main/java/org/violetmoon/zeta/client/ClientTicker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,46 @@ | ||
package org.violetmoon.zeta.client; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.violetmoon.zeta.client.event.play.ZClientTick; | ||
import org.violetmoon.zeta.client.event.play.ZRenderGuiOverlay; | ||
import org.violetmoon.zeta.client.event.play.ZRenderTick; | ||
import org.violetmoon.zeta.event.bus.PlayEvent; | ||
import org.violetmoon.zeta.event.bus.ZPhase; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.screens.Screen; | ||
|
||
//TODO: 1.21. replace with minecraft own ticker. Tbh this is legacy already and should be replaced with Minecraft.getPartialTicks() | ||
@Deprecated | ||
public final class ClientTicker { | ||
public int ticksInGame = 0; | ||
public float partialTicks = 0; | ||
public float delta = 0; | ||
public float total = 0; | ||
|
||
@PlayEvent | ||
public void onRenderTick(ZRenderTick event) { | ||
if(event.isStartPhase()) | ||
partialTicks = event.getRenderTickTime(); | ||
else | ||
endRenderTick(); | ||
} | ||
|
||
@PlayEvent | ||
public void onEndClientTick(ZClientTick event) { | ||
if(event.getPhase() != ZPhase.END) | ||
return; | ||
|
||
Screen gui = Minecraft.getInstance().screen; | ||
if(gui == null || !gui.isPauseScreen()) { | ||
ticksInGame++; | ||
partialTicks = 0; | ||
} | ||
|
||
endRenderTick(); | ||
} | ||
|
||
public void endRenderTick() { | ||
float oldTotal = total; | ||
total = ticksInGame + partialTicks; | ||
delta = total - oldTotal; | ||
} | ||
|
||
//no need to have more than 1 instance of this class. Ticks are always the same | ||
public static final ClientTicker INSTANCE = new ClientTicker(); | ||
|
||
private ClientTicker() { | ||
} | ||
|
||
public float partialTicks = 0; | ||
public float delta = 0; | ||
public float total = 0; | ||
|
||
public int ticksInGame = 0; | ||
|
||
@ApiStatus.Internal | ||
@PlayEvent | ||
public void onRenderTick(ZRenderTick.Start event) { | ||
partialTicks = Minecraft.getInstance().getPartialTick(); | ||
delta = Minecraft.getInstance().getDeltaFrameTime(); | ||
total = ticksInGame + partialTicks; | ||
} | ||
|
||
@ApiStatus.Internal | ||
@PlayEvent | ||
public void onEndClientTick(ZClientTick.End event) { | ||
if (!Minecraft.getInstance().isPaused()) { | ||
ticksInGame++; | ||
} | ||
} | ||
|
||
@PlayEvent | ||
public void pre(ZRenderGuiOverlay.ChatPanel.Pre event) { | ||
int aa = 1; | ||
} | ||
} |
76 changes: 0 additions & 76 deletions
76
src/main/java/org/violetmoon/zeta/client/TopLayerTooltipHandler.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/org/violetmoon/zeta/client/event/load/ZRegisterClientReloadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.violetmoon.zeta.client.event.load; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.violetmoon.zeta.event.bus.IZetaLoadEvent; | ||
|
||
import net.minecraft.server.packs.resources.PreparableReloadListener; | ||
|
||
public interface ZRegisterClientReloadListener extends IZetaLoadEvent, Consumer<PreparableReloadListener> { | ||
@Override | ||
void accept(PreparableReloadListener bleh); | ||
} |
14 changes: 0 additions & 14 deletions
14
src/main/java/org/violetmoon/zeta/client/event/load/ZRegisterReloadListeners.java
This file was deleted.
Oops, something went wrong.
8 changes: 6 additions & 2 deletions
8
src/main/java/org/violetmoon/zeta/client/event/play/ZClientTick.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package org.violetmoon.zeta.client.event.play; | ||
|
||
import org.violetmoon.zeta.event.bus.IZetaPlayEvent; | ||
import org.violetmoon.zeta.event.bus.ZPhase; | ||
|
||
public interface ZClientTick extends IZetaPlayEvent { | ||
ZPhase getPhase(); | ||
|
||
interface Start extends ZClientTick { | ||
} | ||
|
||
interface End extends ZClientTick { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.