Don't dispatch RenderEvent if bot isn't in same dimension

This commit is contained in:
Brady 2020-03-13 16:17:54 -05:00
parent 5b1340e362
commit 9e225949ea
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 8 additions and 9 deletions

View File

@ -21,6 +21,7 @@ import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -38,7 +39,13 @@ public class MixinEntityRenderer {
)
)
private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
int renderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().provider.getDimensionType().getId();
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
World world = ibaritone.getPlayerContext().world();
if (world == null || world.provider.getDimensionType().getId() != renderViewDimension) {
continue;
}
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
}
}

View File

@ -58,18 +58,10 @@ public final class PathRenderer implements IRenderer {
return;
}
if (Helper.mc.currentScreen instanceof GuiClick) {
if (Helper.mc.currentScreen instanceof GuiClick && behavior.baritone == BaritoneAPI.getProvider().getPrimaryBaritone()) {
((GuiClick) Helper.mc.currentScreen).onRender();
}
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().provider.getDimensionType().getId();
int currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().provider.getDimensionType().getId();
if (thisPlayerDimension != currentRenderViewDimension) {
// this is a path for a bot in a different dimension, don't render it
return;
}
Entity renderView = Helper.mc.getRenderViewEntity();
if (renderView.world != BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world()) {