mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-25 14:14:32 +01:00
Players with inverted gravity may now walk on the underside of clouds (wip)
This commit is contained in:
parent
b5aca42ba6
commit
92dd963b9b
2 changed files with 22 additions and 8 deletions
|
@ -318,7 +318,10 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(PlayerEntity player) {
|
public void onPlayerCollision(PlayerEntity player) {
|
||||||
if (player.getY() >= getY()) {
|
|
||||||
|
Pony pony = Pony.of(player);
|
||||||
|
|
||||||
|
if (pony.getPhysics().isGravityNegative() ? player.getY() <= getY() : player.getY() >= getY()) {
|
||||||
if (applyGravityCompensation(player)) {
|
if (applyGravityCompensation(player)) {
|
||||||
double difX = player.getX() - player.prevX;
|
double difX = player.getX() - player.prevX;
|
||||||
double difZ = player.getZ() - player.prevZ;
|
double difZ = player.getZ() - player.prevZ;
|
||||||
|
@ -327,7 +330,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
||||||
player.horizontalSpeed = (float)(player.horizontalSpeed + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
|
player.horizontalSpeed = (float)(player.horizontalSpeed + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
|
||||||
player.distanceTraveled = (float)(player.distanceTraveled + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
|
player.distanceTraveled = (float)(player.distanceTraveled + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
|
||||||
|
|
||||||
if (Pony.of(player).stepOnCloud()) {
|
if (pony.stepOnCloud()) {
|
||||||
BlockSoundGroup soundtype = BlockSoundGroup.WOOL;
|
BlockSoundGroup soundtype = BlockSoundGroup.WOOL;
|
||||||
player.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
|
player.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
|
||||||
}
|
}
|
||||||
|
@ -339,6 +342,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mobTick() {
|
protected void mobTick() {
|
||||||
|
|
||||||
if (!getStationary()) {
|
if (!getStationary()) {
|
||||||
if (!hasVehicle()) {
|
if (!hasVehicle()) {
|
||||||
double distance = targetAltitude - getY();
|
double distance = targetAltitude - getY();
|
||||||
|
@ -535,7 +539,6 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
||||||
|
|
||||||
double bounceModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10;
|
double bounceModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10;
|
||||||
|
|
||||||
|
|
||||||
entity.onGround = true;
|
entity.onGround = true;
|
||||||
|
|
||||||
Vec3d motion = entity.getVelocity();
|
Vec3d motion = entity.getVelocity();
|
||||||
|
@ -543,14 +546,24 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
||||||
double motionY = motion.y;
|
double motionY = motion.y;
|
||||||
double motionZ = motion.z;
|
double motionZ = motion.z;
|
||||||
|
|
||||||
if (motionY <= 0) {
|
Ponylike<?> p = Ponylike.of(entity);
|
||||||
motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - motionY + bounceModifier * 0.7) * 0.10000000149011612D;
|
boolean negativeGravity = p != null && p.getPhysics().isGravityNegative();
|
||||||
|
float gravityConstant = negativeGravity ? -1 : 1;
|
||||||
|
|
||||||
|
if (negativeGravity ? motionY >= 0 : motionY <= 0) {
|
||||||
|
motionY += gravityConstant * (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - motionY + bounceModifier * 0.7) * 0.10000000149011612D;
|
||||||
|
|
||||||
|
if (negativeGravity) {
|
||||||
|
if (motionY > 0) {
|
||||||
|
motionY = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
motionY = Math.min(0.1F, motionY);
|
motionY = Math.min(0.1F, motionY);
|
||||||
if (motionY < 0.002F) {
|
if (motionY < 0.002F) {
|
||||||
motionY = 0.001;
|
motionY = 0.001;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!getStationary()) {
|
if (!getStationary()) {
|
||||||
motionX += ((motionX - motionX) / getCloudSize()) - 0.002F;
|
motionX += ((motionX - motionX) / getCloudSize()) - 0.002F;
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class ConstructionCloudEntity extends CloudEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) {
|
public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) {
|
||||||
|
|
||||||
if (!(hasPassengers() || isConnectedThroughVehicle(player)) && hand == Hand.MAIN_HAND) {
|
if (!(hasPassengers() || isConnectedThroughVehicle(player)) && hand == Hand.MAIN_HAND) {
|
||||||
if (EquinePredicates.PLAYER_PEGASUS.test(player)) {
|
if (EquinePredicates.PLAYER_PEGASUS.test(player)) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue