Compare commits
6 Commits
aac8e65b61
...
ade9328b88
Author | SHA1 | Date |
---|---|---|
|
ade9328b88 | |
|
d79c08678e | |
|
27fd3bfbc5 | |
|
c3a4b322b8 | |
|
ac154973fc | |
|
da55a64c4b |
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Describe the feature you want
|
|
@ -3,6 +3,7 @@ package fhannenheim.autopilot.flight;
|
|||
import com.sun.javafx.geom.Vec2d;
|
||||
import fhannenheim.autopilot.Autopilot;
|
||||
import fhannenheim.autopilot.util.Config;
|
||||
import fhannenheim.autopilot.util.ElytraConfig;
|
||||
import fhannenheim.autopilot.util.InventoryUtils;
|
||||
import fhannenheim.autopilot.util.SpecialActions;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -10,6 +11,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.network.play.client.CPlayerTryUseItemPacket;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
public class FlightExecutor {
|
||||
public FlightHandler flightHandler;
|
||||
|
@ -17,6 +19,12 @@ public class FlightExecutor {
|
|||
private FlightPhase flightPhase;
|
||||
public boolean preventRocket;
|
||||
|
||||
public boolean isDescending;
|
||||
public boolean pullDown;
|
||||
public boolean pullUp;
|
||||
public double currentVelocity;
|
||||
public ElytraConfig config = new ElytraConfig();
|
||||
|
||||
public FlightExecutor(FlightHandler flightHandler) {
|
||||
this.flightHandler = flightHandler;
|
||||
}
|
||||
|
@ -53,33 +61,41 @@ public class FlightExecutor {
|
|||
|
||||
// values from https://www.reddit.com/r/Minecraft/comments/5ic9la/using_a_genetic_algorithm_to_power_infinite/
|
||||
public void fourtyfourtyFlight(PlayerEntity playerEntity) {
|
||||
// Place new rockets in hand if needed
|
||||
InventoryUtils.refillRockets(playerEntity);
|
||||
this.currentVelocity = getVelocity(playerEntity);
|
||||
|
||||
// apparently switch statements can't handle null-objects
|
||||
flightPhase = flightPhase == null ? FlightPhase.DESCEND : flightPhase;
|
||||
|
||||
switch (flightPhase) {
|
||||
case ASCEND:
|
||||
playerEntity.rotationPitch = -49.44969f;
|
||||
break;
|
||||
case DESCEND:
|
||||
playerEntity.rotationPitch = 37.7458839f;
|
||||
break;
|
||||
default:
|
||||
flightPhase = FlightPhase.DESCEND;
|
||||
break;
|
||||
if (this.isDescending) {
|
||||
this.pullUp = false;
|
||||
this.pullDown = true;
|
||||
if (this.currentVelocity >= this.config.pullDownMaxVelocity) {
|
||||
this.isDescending = false;
|
||||
this.pullDown = false;
|
||||
this.pullUp = true;
|
||||
}
|
||||
} else {
|
||||
this.pullUp = true;
|
||||
this.pullDown = false;
|
||||
if (this.currentVelocity <= this.config.pullUpMinVelocity) {
|
||||
this.isDescending = true;
|
||||
this.pullDown = true;
|
||||
this.pullUp = false;
|
||||
}
|
||||
}
|
||||
|
||||
double velocity = getVelocity(playerEntity);
|
||||
if (flightPhase == FlightPhase.DESCEND && velocity > 2.08719635f)
|
||||
flightPhase = FlightPhase.ASCEND;
|
||||
else if (flightPhase == FlightPhase.ASCEND && velocity < 0.224041611f)
|
||||
flightPhase = FlightPhase.DESCEND;
|
||||
if (flightPhase == FlightPhase.ASCEND && playerEntity.getPosY() < Config.flight_level.get() && velocity < 0.75f) {
|
||||
useRocket();
|
||||
ticksSinceRocket = 0;
|
||||
|
||||
if (this.pullUp) {
|
||||
playerEntity.rotationPitch = (float)((double)playerEntity.rotationPitch - this.config.pullUpSpeed);
|
||||
if ((double)playerEntity.rotationPitch <= this.config.pullUpAngle) {
|
||||
playerEntity.rotationPitch = (float)this.config.pullUpAngle;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pullDown) {
|
||||
playerEntity.rotationPitch = (float)((double)playerEntity.rotationPitch + this.config.pullDownSpeed);
|
||||
if ((double)playerEntity.rotationPitch >= this.config.pullDownAngle) {
|
||||
playerEntity.rotationPitch = (float)this.config.pullDownAngle;
|
||||
}
|
||||
}
|
||||
|
||||
if (flightHandler.destination != null && Vec2d.distance(flightHandler.destination.x, flightHandler.destination.z, playerEntity.getPosX(), playerEntity.getPosZ()) < 3) {
|
||||
if (Config.on_arrive.get() == SpecialActions.Disconnect) {
|
||||
flightHandler.shallDisconnect = true;
|
||||
|
|
|
@ -48,12 +48,14 @@ public class FlightHandler {
|
|||
if (playerEntity != null && (rockets || angle4040)) {
|
||||
destination = null;
|
||||
if (!isAutoFlying && !playerEntity.onGround) {
|
||||
if (!playerEntity.isElytraFlying()) {
|
||||
playerEntity.startFallFlying();
|
||||
}
|
||||
startFlying(playerEntity);
|
||||
if (rockets) flightType = FlightType.ROCKETS;
|
||||
else flightType = FlightType.ANGLE4040;
|
||||
isAutoFlying = true;
|
||||
|
||||
if (isAutoFlying && flightType == FlightType.ANGLE4040) {
|
||||
flightExecutor.isDescending = true;
|
||||
}
|
||||
} else {
|
||||
isAutoFlying = false;
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ public class FlightHandler {
|
|||
destination = null;
|
||||
return;
|
||||
}
|
||||
if (playerEntity.onGround) {
|
||||
if (playerEntity.onGround && playerEntity.isElytraFlying()) {
|
||||
playerEntity.stopFallFlying();
|
||||
isAutoFlying = false;
|
||||
destination = null;
|
||||
|
@ -106,7 +108,7 @@ public class FlightHandler {
|
|||
InventoryUtils.replaceElytra(playerEntity);
|
||||
|
||||
// Start flying again
|
||||
Minecraft.getInstance().getConnection().sendPacket(new CEntityActionPacket(playerEntity, CEntityActionPacket.Action.START_FALL_FLYING));
|
||||
startFlying(playerEntity);
|
||||
}
|
||||
if (destination != null) {
|
||||
playerEntity.lookAt(EntityAnchorArgument.Type.EYES, destination);
|
||||
|
@ -131,6 +133,12 @@ public class FlightHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void startFlying(PlayerEntity playerEntity) {
|
||||
if (playerEntity.tryToStartFallFlying()) {
|
||||
Minecraft.getInstance().getConnection().sendPacket(new CEntityActionPacket(playerEntity, CEntityActionPacket.Action.START_FALL_FLYING));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void disconnect(TickEvent.RenderTickEvent event) {
|
||||
if (shallDisconnect) {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package fhannenheim.autopilot.util;
|
||||
|
||||
public class ElytraConfig {
|
||||
public int guiX = 5;
|
||||
public int guiY = 5;
|
||||
public int guiWidth = 150;
|
||||
public int guiHeight = 50;
|
||||
public int guiGraphRealWidth = 2000;
|
||||
public boolean showGraph = true;
|
||||
public double pullUpAngle = -46.633514D;
|
||||
public double pullDownAngle = 37.19872D;
|
||||
public double pullUpMinVelocity = 1.9102669D;
|
||||
public double pullDownMaxVelocity = 2.3250866D;
|
||||
public double pullUpSpeed = 6.4815372D;
|
||||
public double pullDownSpeed = 0.61635801D;
|
||||
|
||||
public ElytraConfig() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue