Remove Baritone casts

This commit is contained in:
Brady 2018-11-14 16:29:15 -06:00
parent f6dee1ecb7
commit 237f1846d3
No known key found for this signature in database
GPG Key ID: 73A788379A197567
13 changed files with 68 additions and 48 deletions

View File

@ -21,7 +21,7 @@ import baritone.api.behavior.ILookBehavior;
import baritone.api.behavior.IMemoryBehavior; import baritone.api.behavior.IMemoryBehavior;
import baritone.api.behavior.IPathingBehavior; import baritone.api.behavior.IPathingBehavior;
import baritone.api.cache.IWorldProvider; import baritone.api.cache.IWorldProvider;
import baritone.api.event.listener.IGameEventListener; import baritone.api.event.listener.IEventBus;
import baritone.api.process.ICustomGoalProcess; import baritone.api.process.ICustomGoalProcess;
import baritone.api.process.IFollowProcess; import baritone.api.process.IFollowProcess;
import baritone.api.process.IGetToBlockProcess; import baritone.api.process.IGetToBlockProcess;
@ -79,10 +79,5 @@ public interface IBaritone {
IPlayerContext getPlayerContext(); IPlayerContext getPlayerContext();
/** IEventBus getGameEventHandler();
* Registers a {@link IGameEventListener} with Baritone's "event bus".
*
* @param listener The listener
*/
void registerEventListener(IGameEventListener listener);
} }

View File

@ -0,0 +1,36 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.event.listener;
/**
* A type of {@link IGameEventListener} that can have additional listeners
* registered so that they receive the events that are dispatched to this
* listener.
*
* @author Brady
* @since 11/14/2018
*/
public interface IEventBus extends IGameEventListener {
/**
* Registers the specified {@link IGameEventListener} to this event bus
*
* @param listener The listener
*/
void registerEventListener(IGameEventListener listener);
}

View File

@ -17,7 +17,6 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.event.events.RotationMoveEvent; import baritone.api.event.events.RotationMoveEvent;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
@ -54,7 +53,7 @@ public class MixinEntity {
// noinspection ConstantConditions // noinspection ConstantConditions
if (EntityPlayerSP.class.isInstance(this)) { if (EntityPlayerSP.class.isInstance(this)) {
this.motionUpdateRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); this.motionUpdateRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
((Baritone) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this)).getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent);
} }
} }

View File

@ -17,7 +17,6 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.event.events.RotationMoveEvent; import baritone.api.event.events.RotationMoveEvent;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
@ -57,7 +56,7 @@ public abstract class MixinEntityLivingBase extends Entity {
// noinspection ConstantConditions // noinspection ConstantConditions
if (EntityPlayerSP.class.isInstance(this)) { if (EntityPlayerSP.class.isInstance(this)) {
this.jumpRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.JUMP, this.rotationYaw); this.jumpRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.JUMP, this.rotationYaw);
((Baritone) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this)).getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
} }
} }

View File

@ -17,7 +17,6 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.behavior.IPathingBehavior; import baritone.api.behavior.IPathingBehavior;
import baritone.api.event.events.ChatEvent; import baritone.api.event.events.ChatEvent;
@ -45,7 +44,7 @@ public class MixinEntityPlayerSP {
) )
private void sendChatMessage(String msg, CallbackInfo ci) { private void sendChatMessage(String msg, CallbackInfo ci) {
ChatEvent event = new ChatEvent((EntityPlayerSP) (Object) this, msg); ChatEvent event = new ChatEvent((EntityPlayerSP) (Object) this, msg);
((Baritone) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this)).getGameEventHandler().onSendChatMessage(event); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onSendChatMessage(event);
if (event.isCancelled()) { if (event.isCancelled()) {
ci.cancel(); ci.cancel();
} }
@ -61,7 +60,7 @@ public class MixinEntityPlayerSP {
) )
) )
private void onPreUpdate(CallbackInfo ci) { private void onPreUpdate(CallbackInfo ci) {
((Baritone) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this)).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.PRE)); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.PRE));
} }
@Inject( @Inject(
@ -74,7 +73,7 @@ public class MixinEntityPlayerSP {
) )
) )
private void onPostUpdate(CallbackInfo ci) { private void onPostUpdate(CallbackInfo ci) {
((Baritone) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this)).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.POST)); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.POST));
} }
@Redirect( @Redirect(

View File

@ -17,7 +17,6 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent; import baritone.api.event.events.RenderEvent;
@ -40,7 +39,7 @@ public class MixinEntityRenderer {
) )
private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) { private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
((Baritone) ibaritone).getGameEventHandler().onRenderPass(new RenderEvent(partialTicks)); ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
} }
} }
} }

View File

@ -91,7 +91,7 @@ public class MixinMinecraft {
? TickEvent.Type.IN ? TickEvent.Type.IN
: TickEvent.Type.OUT; : TickEvent.Type.OUT;
((Baritone) ibaritone).getGameEventHandler().onTick(new TickEvent(EventState.PRE, type)); ibaritone.getGameEventHandler().onTick(new TickEvent(EventState.PRE, type));
} }
} }
@ -102,7 +102,7 @@ public class MixinMinecraft {
) )
private void runTickKeyboard(CallbackInfo ci) { private void runTickKeyboard(CallbackInfo ci) {
// keyboard input is only the primary baritone // keyboard input is only the primary baritone
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).getGameEventHandler().onProcessKeyBinds(); BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onProcessKeyBinds();
} }
@Inject( @Inject(
@ -117,7 +117,7 @@ public class MixinMinecraft {
// mc.world changing is only the primary baritone // mc.world changing is only the primary baritone
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).getGameEventHandler().onWorldEvent( BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onWorldEvent(
new WorldEvent( new WorldEvent(
world, world,
EventState.PRE EventState.PRE
@ -133,8 +133,7 @@ public class MixinMinecraft {
// still fire event for both null, as that means we've just finished exiting a world // still fire event for both null, as that means we've just finished exiting a world
// mc.world changing is only the primary baritone // mc.world changing is only the primary baritone
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onWorldEvent(
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).getGameEventHandler().onWorldEvent(
new WorldEvent( new WorldEvent(
world, world,
EventState.POST EventState.POST
@ -165,7 +164,7 @@ public class MixinMinecraft {
) )
private void onBlockBreak(CallbackInfo ci, BlockPos pos) { private void onBlockBreak(CallbackInfo ci, BlockPos pos) {
// clickMouse is only for the main player // clickMouse is only for the main player
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK)); BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK));
} }
@Inject( @Inject(
@ -178,6 +177,6 @@ public class MixinMinecraft {
) )
private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) { private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) {
// rightClickMouse is only for the main player // rightClickMouse is only for the main player
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE)); BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE));
} }
} }

View File

@ -17,7 +17,6 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.event.events.ChunkEvent; import baritone.api.event.events.ChunkEvent;
@ -47,7 +46,7 @@ public class MixinNetHandlerPlayClient {
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) { private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onChunkEvent( ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent( new ChunkEvent(
EventState.PRE, EventState.PRE,
ChunkEvent.Type.POPULATE, ChunkEvent.Type.POPULATE,
@ -66,7 +65,7 @@ public class MixinNetHandlerPlayClient {
private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) { private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onChunkEvent( ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent( new ChunkEvent(
EventState.POST, EventState.POST,
ChunkEvent.Type.POPULATE, ChunkEvent.Type.POPULATE,
@ -88,7 +87,7 @@ public class MixinNetHandlerPlayClient {
private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) { private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onPlayerDeath(); ibaritone.getGameEventHandler().onPlayerDeath();
} }
} }
} }

View File

@ -17,7 +17,6 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PacketEvent;
@ -61,7 +60,7 @@ public class MixinNetworkManager {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, inPacket)); ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, inPacket));
} }
} }
} }
@ -77,7 +76,7 @@ public class MixinNetworkManager {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, inPacket)); ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, inPacket));
} }
} }
} }
@ -95,7 +94,7 @@ public class MixinNetworkManager {
} }
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, packet)); ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, packet));
} }
} }
} }
@ -110,7 +109,7 @@ public class MixinNetworkManager {
} }
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, packet)); ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, packet));
} }
} }
} }

View File

@ -17,7 +17,6 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.event.events.ChunkEvent; import baritone.api.event.events.ChunkEvent;
@ -42,7 +41,7 @@ public class MixinWorldClient {
private void preDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) { private void preDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) { if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onChunkEvent( ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent( new ChunkEvent(
EventState.PRE, EventState.PRE,
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD, loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
@ -62,7 +61,7 @@ public class MixinWorldClient {
private void postDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) { private void postDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) { if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
((Baritone) ibaritone).getGameEventHandler().onChunkEvent( ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent( new ChunkEvent(
EventState.POST, EventState.POST,
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD, loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,

View File

@ -20,7 +20,7 @@ package baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.event.listener.IGameEventListener; import baritone.api.event.listener.IEventBus;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.behavior.Behavior; import baritone.behavior.Behavior;
import baritone.behavior.LookBehavior; import baritone.behavior.LookBehavior;
@ -125,7 +125,7 @@ public class Baritone implements IBaritone {
this.worldProvider = new WorldProvider(); this.worldProvider = new WorldProvider();
if (BaritoneAutoTest.ENABLE_AUTO_TEST) { if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
registerEventListener(BaritoneAutoTest.INSTANCE); this.gameEventHandler.registerEventListener(BaritoneAutoTest.INSTANCE);
} }
this.initialized = true; this.initialized = true;
@ -135,17 +135,13 @@ public class Baritone implements IBaritone {
return this.pathingControlManager; return this.pathingControlManager;
} }
public IGameEventListener getGameEventHandler() {
return this.gameEventHandler;
}
public List<Behavior> getBehaviors() { public List<Behavior> getBehaviors() {
return this.behaviors; return this.behaviors;
} }
public void registerBehavior(Behavior behavior) { public void registerBehavior(Behavior behavior) {
this.behaviors.add(behavior); this.behaviors.add(behavior);
this.registerEventListener(behavior); this.gameEventHandler.registerEventListener(behavior);
} }
@Override @Override
@ -199,8 +195,8 @@ public class Baritone implements IBaritone {
} }
@Override @Override
public void registerEventListener(IGameEventListener listener) { public IEventBus getGameEventHandler() {
this.gameEventHandler.registerEventListener(listener); return this.gameEventHandler;
} }
public static Settings settings() { public static Settings settings() {

View File

@ -20,6 +20,7 @@ package baritone.event;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.event.events.*; import baritone.api.event.events.*;
import baritone.api.event.events.type.EventState; import baritone.api.event.events.type.EventState;
import baritone.api.event.listener.IEventBus;
import baritone.api.event.listener.IGameEventListener; import baritone.api.event.listener.IGameEventListener;
import baritone.cache.WorldProvider; import baritone.cache.WorldProvider;
import baritone.utils.Helper; import baritone.utils.Helper;
@ -33,7 +34,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
* @author Brady * @author Brady
* @since 7/31/2018 * @since 7/31/2018
*/ */
public final class GameEventHandler implements IGameEventListener, Helper { public final class GameEventHandler implements IEventBus, Helper {
private final Baritone baritone; private final Baritone baritone;
@ -140,8 +141,8 @@ public final class GameEventHandler implements IGameEventListener, Helper {
listeners.forEach(l -> l.onPathEvent(event)); listeners.forEach(l -> l.onPathEvent(event));
} }
@Override
public final void registerEventListener(IGameEventListener listener) { public final void registerEventListener(IGameEventListener listener) {
this.listeners.add(listener); this.listeners.add(listener);
} }
} }

View File

@ -43,7 +43,7 @@ public class PathingControlManager {
public PathingControlManager(Baritone baritone) { public PathingControlManager(Baritone baritone) {
this.baritone = baritone; this.baritone = baritone;
this.processes = new HashSet<>(); this.processes = new HashSet<>();
baritone.registerEventListener(new AbstractGameEventListener() { // needs to be after all behavior ticks baritone.getGameEventHandler().registerEventListener(new AbstractGameEventListener() { // needs to be after all behavior ticks
@Override @Override
public void onTick(TickEvent event) { public void onTick(TickEvent event) {
if (event.getType() == TickEvent.Type.OUT) { if (event.getType() == TickEvent.Type.OUT) {