From c814874cb6290d70f864888e56dd377b6a2a6c09 Mon Sep 17 00:00:00 2001 From: 0x22 <0x22@futureclient.net> Date: Sun, 4 Nov 2018 18:09:40 -0500 Subject: [PATCH 1/6] Updated mappings to stable_39 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index abb75959..e0b556a2 100755 --- a/build.gradle +++ b/build.gradle @@ -58,7 +58,7 @@ sourceSets { minecraft { version = '1.12.2' - mappings = 'snapshot_20180731' + mappings = 'stable_39' tweakClass = 'baritone.launch.BaritoneTweaker' runDir = 'run' From 6812d2ba7d744ff00aaceba6ec99a44cbceff7ad Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 4 Nov 2018 22:22:04 -0800 Subject: [PATCH 2/6] simplify readme --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index dd7a87cf..78202aa6 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,7 @@ For example, to replace out Impact 4.4's Baritone build with a customized one, b ## IntelliJ's Gradle UI - Open the project in IntelliJ as a Gradle project -- Run the Gradle task `setupDecompWorkspace` -- Run the Gradle task `genIntellijRuns` +- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns` - Refresh the Gradle project (or, to be safe, just restart IntelliJ) - Select the "Minecraft Client" launch config - In `Edit Configurations...` you may need to select `baritone_launch` for `Use classpath of module:`. From 1c4f029bf4510e43d3c813e2b0c49791e3fe6ec4 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 5 Nov 2018 12:47:17 -0600 Subject: [PATCH 3/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78202aa6..4defe19f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Building Baritone: $ gradlew build ``` -For example, to replace out Impact 4.4's Baritone build with a customized one, build Baritone as above then copy `dist/baritone-api-$VERSION.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). +For example, to replace out Impact 4.4's Baritone build with a customized one, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/$VERSION$/baritone-api-$VERSION$.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:$VERSION$"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). ## IntelliJ's Gradle UI - Open the project in IntelliJ as a Gradle project From ffb044ffc6248c7022a04955f30faf6502900d28 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 5 Nov 2018 13:47:55 -0600 Subject: [PATCH 4/6] Replace RotationMoveEvent Inject with Redirect --- .../api/event/events/RotationMoveEvent.java | 15 +++--- .../baritone/launch/mixins/MixinEntity.java | 37 ++++++++++---- .../launch/mixins/MixinEntityLivingBase.java | 48 +++++++++++++------ 3 files changed, 67 insertions(+), 33 deletions(-) diff --git a/src/api/java/baritone/api/event/events/RotationMoveEvent.java b/src/api/java/baritone/api/event/events/RotationMoveEvent.java index 7a7514db..7f98947d 100644 --- a/src/api/java/baritone/api/event/events/RotationMoveEvent.java +++ b/src/api/java/baritone/api/event/events/RotationMoveEvent.java @@ -17,7 +17,6 @@ package baritone.api.event.events; -import baritone.api.event.events.type.EventState; import baritone.api.event.events.type.ManagedPlayerEvent; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; @@ -35,21 +34,21 @@ public final class RotationMoveEvent extends ManagedPlayerEvent { private final Type type; /** - * The state of the event + * The yaw rotation */ - private final EventState state; + private float yaw; - public RotationMoveEvent(EntityPlayerSP player, EventState state, Type type) { + public RotationMoveEvent(EntityPlayerSP player, Type type, float yaw) { super(player); - this.state = state; this.type = type; + this.yaw = yaw; } /** - * @return The state of the event + * @return The yaw rotation */ - public final EventState getState() { - return this.state; + public final float getYaw() { + return this.yaw; } /** diff --git a/src/launch/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java index fe019bb7..db8b513f 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntity.java @@ -19,14 +19,17 @@ package baritone.launch.mixins; import baritone.Baritone; import baritone.api.event.events.RotationMoveEvent; -import baritone.api.event.events.type.EventState; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import static org.spongepowered.asm.lib.Opcodes.GETFIELD; + /** * @author Brady * @since 8/21/2018 @@ -34,23 +37,37 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Entity.class) public class MixinEntity { + @Shadow public float rotationYaw; + + /** + * Event called to override the movement direction when walking + */ + private RotationMoveEvent motionUpdateRotationEvent; + @Inject( method = "moveRelative", at = @At("HEAD") ) private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) { - Entity _this = (Entity) (Object) this; - if (EntityPlayerSP.class.isInstance(_this)) - Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.PRE, RotationMoveEvent.Type.MOTION_UPDATE)); + // noinspection ConstantConditions + if (EntityPlayerSP.class.isInstance(this)) { + this.motionUpdateRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); + Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent); + } } - @Inject( + @Redirect( method = "moveRelative", - at = @At("RETURN") + at = @At( + value = "FIELD", + opcode = GETFIELD, + target = "net/minecraft/entity/Entity.rotationYaw:F" + ) ) - private void postMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) { - Entity _this = (Entity) (Object) this; - if (EntityPlayerSP.class.isInstance(_this)) - Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.POST, RotationMoveEvent.Type.MOTION_UPDATE)); + private float overrideYaw(Entity entity) { + if (entity instanceof EntityPlayerSP) { + return this.motionUpdateRotationEvent.getYaw(); + } + return entity.rotationYaw; } } diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java index 6313b3a1..42aa9bf0 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java @@ -19,41 +19,59 @@ package baritone.launch.mixins; import baritone.Baritone; import baritone.api.event.events.RotationMoveEvent; -import baritone.api.event.events.type.EventState; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +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; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import static org.spongepowered.asm.lib.Opcodes.GETFIELD; + /** * @author Brady * @since 9/10/2018 */ @Mixin(EntityLivingBase.class) -public class MixinEntityLivingBase { +public abstract class MixinEntityLivingBase extends Entity { + + /** + * Event called to override the movement direction when jumping + */ + private RotationMoveEvent jumpRotationEvent; + + public MixinEntityLivingBase(World worldIn, RotationMoveEvent jumpRotationEvent) { + super(worldIn); + this.jumpRotationEvent = jumpRotationEvent; + } @Inject( method = "jump", at = @At("HEAD") ) - private void preJump(CallbackInfo ci) { - EntityLivingBase _this = (EntityLivingBase) (Object) this; - // This uses Class.isInstance instead of instanceof since proguard optimizes out the instanceof (since MixinEntityLivingBase could never be instanceof EntityLivingBase in normal java) - // but proguard isn't smart enough to optimize out this Class.isInstance =) - if (EntityPlayerSP.class.isInstance(_this)) - Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.PRE, RotationMoveEvent.Type.JUMP)); + private void preMoveRelative(CallbackInfo ci) { + // noinspection ConstantConditions + if (EntityPlayerSP.class.isInstance(this)) { + this.jumpRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.JUMP, this.rotationYaw); + Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent); + } } - @Inject( + @Redirect( method = "jump", - at = @At("RETURN") + at = @At( + value = "FIELD", + opcode = GETFIELD, + target = "net/minecraft/entity/EntityLivingBase.rotationYaw:F" + ) ) - private void postJump(CallbackInfo ci) { - EntityLivingBase _this = (EntityLivingBase) (Object) this; - // See above - if (EntityPlayerSP.class.isInstance(_this)) - Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.POST, RotationMoveEvent.Type.JUMP)); + private float overrideYaw(EntityLivingBase entity) { + if (entity instanceof EntityPlayerSP) { + return this.jumpRotationEvent.getYaw(); + } + return entity.rotationYaw; } } From c0e0f8dc2a3537f2cd463ba03cfe9c1d3cfdd5ff Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 5 Nov 2018 13:53:26 -0600 Subject: [PATCH 5/6] Fix last commit lol --- .../api/event/events/RotationMoveEvent.java | 9 ++++++++ .../java/baritone/behavior/LookBehavior.java | 21 ++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/api/java/baritone/api/event/events/RotationMoveEvent.java b/src/api/java/baritone/api/event/events/RotationMoveEvent.java index 7f98947d..790318e0 100644 --- a/src/api/java/baritone/api/event/events/RotationMoveEvent.java +++ b/src/api/java/baritone/api/event/events/RotationMoveEvent.java @@ -44,6 +44,15 @@ public final class RotationMoveEvent extends ManagedPlayerEvent { this.yaw = yaw; } + /** + * Set the yaw movement rotation + * + * @param yaw Yaw rotation + */ + public final void setYaw(float yaw) { + this.yaw = yaw; + } + /** * @return The yaw rotation */ diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index ac3a4698..bcaf487e 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -97,22 +97,13 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe @Override public void onPlayerRotationMove(RotationMoveEvent event) { if (this.target != null && !this.force) { - switch (event.getState()) { - case PRE: - this.lastYaw = player().rotationYaw; - player().rotationYaw = this.target.getYaw(); - break; - case POST: - player().rotationYaw = this.lastYaw; - // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() - // Also the type has to be MOTION_UPDATE because that is called after JUMP - if (!Baritone.settings().antiCheatCompatibility.get() && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE) { - this.target = null; - } - break; - default: - break; + event.setYaw(this.target.getYaw()); + + // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() + // Also the type has to be MOTION_UPDATE because that is called after JUMP + if (!Baritone.settings().antiCheatCompatibility.get() && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE) { + this.target = null; } } } From f286c400a3d8904657104b098ab3d713c01d66f8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 5 Nov 2018 13:47:00 -0800 Subject: [PATCH 6/6] when parkouring from soul sand, the maximum gap should be 1, fixes #247 --- .../movement/movements/MovementParkour.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index dbcf3a59..68bddae0 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -93,7 +93,17 @@ public class MovementParkour extends Movement { if (!MovementHelper.fullyPassable(x, y + 2, z)) { return; } - for (int i = 2; i <= (context.canSprint() ? 4 : 3); i++) { + int maxJump; + if (standingOn.getBlock() == Blocks.SOUL_SAND) { + maxJump = 2; // 1 block gap + } else { + if (context.canSprint()) { + maxJump = 4; + } else { + maxJump = 3; + } + } + for (int i = 2; i <= maxJump; i++) { // TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly? for (int y2 = 0; y2 < 4; y2++) { if (!MovementHelper.fullyPassable(x + xDiff * i, y + y2, z + zDiff * i)) { @@ -108,7 +118,7 @@ public class MovementParkour extends Movement { return; } } - if (!context.canSprint()) { + if (maxJump != 4) { return; } if (!Baritone.settings().allowParkourPlace.get()) {