Merge branch 'master' into processes

This commit is contained in:
Leijurv 2018-11-05 13:51:41 -08:00
commit fffd016008
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
7 changed files with 97 additions and 54 deletions

View File

@ -36,12 +36,11 @@ Building Baritone:
$ gradlew build $ 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 ## IntelliJ's Gradle UI
- Open the project in IntelliJ as a Gradle project - Open the project in IntelliJ as a Gradle project
- Run the Gradle task `setupDecompWorkspace` - Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns`
- Run the Gradle task `genIntellijRuns`
- Refresh the Gradle project (or, to be safe, just restart IntelliJ) - Refresh the Gradle project (or, to be safe, just restart IntelliJ)
- Select the "Minecraft Client" launch config - Select the "Minecraft Client" launch config
- In `Edit Configurations...` you may need to select `baritone_launch` for `Use classpath of module:`. - In `Edit Configurations...` you may need to select `baritone_launch` for `Use classpath of module:`.

View File

@ -58,7 +58,7 @@ sourceSets {
minecraft { minecraft {
version = '1.12.2' version = '1.12.2'
mappings = 'snapshot_20180731' mappings = 'stable_39'
tweakClass = 'baritone.launch.BaritoneTweaker' tweakClass = 'baritone.launch.BaritoneTweaker'
runDir = 'run' runDir = 'run'

View File

@ -17,7 +17,6 @@
package baritone.api.event.events; package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
import baritone.api.event.events.type.ManagedPlayerEvent; import baritone.api.event.events.type.ManagedPlayerEvent;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -35,21 +34,30 @@ public final class RotationMoveEvent extends ManagedPlayerEvent {
private final Type type; 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); super(player);
this.state = state;
this.type = type; this.type = type;
this.yaw = yaw;
} }
/** /**
* @return The state of the event * Set the yaw movement rotation
*
* @param yaw Yaw rotation
*/ */
public final EventState getState() { public final void setYaw(float yaw) {
return this.state; this.yaw = yaw;
}
/**
* @return The yaw rotation
*/
public final float getYaw() {
return this.yaw;
} }
/** /**

View File

@ -19,14 +19,17 @@ package baritone.launch.mixins;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.event.events.RotationMoveEvent; import baritone.api.event.events.RotationMoveEvent;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static org.spongepowered.asm.lib.Opcodes.GETFIELD;
/** /**
* @author Brady * @author Brady
* @since 8/21/2018 * @since 8/21/2018
@ -34,23 +37,37 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Entity.class) @Mixin(Entity.class)
public class MixinEntity { public class MixinEntity {
@Shadow public float rotationYaw;
/**
* Event called to override the movement direction when walking
*/
private RotationMoveEvent motionUpdateRotationEvent;
@Inject( @Inject(
method = "moveRelative", method = "moveRelative",
at = @At("HEAD") at = @At("HEAD")
) )
private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) { private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
Entity _this = (Entity) (Object) this; // noinspection ConstantConditions
if (EntityPlayerSP.class.isInstance(_this)) if (EntityPlayerSP.class.isInstance(this)) {
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.PRE, RotationMoveEvent.Type.MOTION_UPDATE)); this.motionUpdateRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent);
}
} }
@Inject( @Redirect(
method = "moveRelative", 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; private float overrideYaw(Entity entity) {
if (EntityPlayerSP.class.isInstance(_this)) if (entity instanceof EntityPlayerSP) {
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.POST, RotationMoveEvent.Type.MOTION_UPDATE)); return this.motionUpdateRotationEvent.getYaw();
}
return entity.rotationYaw;
} }
} }

View File

@ -19,41 +19,59 @@ package baritone.launch.mixins;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.event.events.RotationMoveEvent; import baritone.api.event.events.RotationMoveEvent;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static org.spongepowered.asm.lib.Opcodes.GETFIELD;
/** /**
* @author Brady * @author Brady
* @since 9/10/2018 * @since 9/10/2018
*/ */
@Mixin(EntityLivingBase.class) @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( @Inject(
method = "jump", method = "jump",
at = @At("HEAD") at = @At("HEAD")
) )
private void preJump(CallbackInfo ci) { private void preMoveRelative(CallbackInfo ci) {
EntityLivingBase _this = (EntityLivingBase) (Object) this; // noinspection ConstantConditions
// This uses Class.isInstance instead of instanceof since proguard optimizes out the instanceof (since MixinEntityLivingBase could never be instanceof EntityLivingBase in normal java) if (EntityPlayerSP.class.isInstance(this)) {
// but proguard isn't smart enough to optimize out this Class.isInstance =) this.jumpRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.JUMP, this.rotationYaw);
if (EntityPlayerSP.class.isInstance(_this)) Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.PRE, RotationMoveEvent.Type.JUMP)); }
} }
@Inject( @Redirect(
method = "jump", 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; private float overrideYaw(EntityLivingBase entity) {
// See above if (entity instanceof EntityPlayerSP) {
if (EntityPlayerSP.class.isInstance(_this)) return this.jumpRotationEvent.getYaw();
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent((EntityPlayerSP) _this, EventState.POST, RotationMoveEvent.Type.JUMP)); }
return entity.rotationYaw;
} }
} }

View File

@ -97,23 +97,14 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe
@Override @Override
public void onPlayerRotationMove(RotationMoveEvent event) { public void onPlayerRotationMove(RotationMoveEvent event) {
if (this.target != null && !this.force) { if (this.target != null && !this.force) {
switch (event.getState()) {
case PRE: event.setYaw(this.target.getYaw());
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() // 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 // 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) { if (!Baritone.settings().antiCheatCompatibility.get() && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE) {
this.target = null; this.target = null;
} }
break;
default:
break;
}
} }
} }

View File

@ -93,7 +93,17 @@ public class MovementParkour extends Movement {
if (!MovementHelper.fullyPassable(x, y + 2, z)) { if (!MovementHelper.fullyPassable(x, y + 2, z)) {
return; 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? // TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly?
for (int y2 = 0; y2 < 4; y2++) { for (int y2 = 0; y2 < 4; y2++) {
if (!MovementHelper.fullyPassable(x + xDiff * i, y + y2, z + zDiff * i)) { if (!MovementHelper.fullyPassable(x + xDiff * i, y + y2, z + zDiff * i)) {
@ -108,7 +118,7 @@ public class MovementParkour extends Movement {
return; return;
} }
} }
if (!context.canSprint()) { if (maxJump != 4) {
return; return;
} }
if (!Baritone.settings().allowParkourPlace.get()) { if (!Baritone.settings().allowParkourPlace.get()) {