Move gravity direction system to Anthology
Gravity API, mixins, projectile compat, inverted effect, gravity sync and /gravity now live in the Anthology library. Antarchy registers the Underside region, antiwater, stale-inversion cleanup and portal gun camera roll through GravityHooks, and depends on the local Anthology jar in anthology_jars/.
This commit is contained in:
1 parent
0cad456efd
commit
bba2a56671
140 files changed
+570
-4947
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.craisinlord.antarchy;
|
||||
|
||||
import com.craisinlord.antarchy.content.computer.AntarchyArchiveLocators;
|
||||
import com.craisinlord.antarchy.content.movement.AntarchyGravityHooks;
|
||||
import com.craisinlord.antarchy.content.util.AttributeRangeInit;
|
||||
import com.craisinlord.antarchy.content.worldgen.VillagePoolAdditions;
|
||||
import com.craisinlord.integrated_api.events.lifecycle.ServerGoingToStartEvent;
|
||||
@@ -17,6 +18,7 @@ public class Antarchy {
|
||||
public static void init() {
|
||||
AttributeRangeInit.apply();
|
||||
AntarchyArchiveLocators.register();
|
||||
AntarchyGravityHooks.register();
|
||||
ServerGoingToStartEvent.EVENT.addListener(Antarchy::serverAboutToStart);
|
||||
}
|
||||
private static void serverAboutToStart(final ServerGoingToStartEvent event) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.block;
|
||||
|
||||
import com.craisinlord.antarchy.content.entity.UpwardFallingBlockEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -66,7 +66,7 @@ public class AntimetalScaffoldingBlock extends ScaffoldingBlock {
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
BlockPos pos = context.getClickedPos();
|
||||
Level level = context.getLevel();
|
||||
boolean inverted = context.getPlayer() != null && AntarchyGravityApi.isGravityInverted(context.getPlayer());
|
||||
boolean inverted = context.getPlayer() != null && GravityApi.isGravityInverted(context.getPlayer());
|
||||
int distance = getDistance(level, pos, inverted);
|
||||
if (inverted && distance >= 7) {
|
||||
return null;
|
||||
|
||||
+6
-6
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.block.PotentNyxiteBlock;
|
||||
import com.craisinlord.antarchy.content.block.state.PotentNyxiteState;
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.client.particle.InvertedGeyserParticleOptions;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
@@ -333,9 +333,9 @@ public class PotentNyxiteBlockEntity extends BlockEntity {
|
||||
continue;
|
||||
}
|
||||
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(entity);
|
||||
GravityDirection gravityDirection = GravityApi.getGravityDirection(entity);
|
||||
Vec3 currentWorldVelocity = gravityDirection.isInverted()
|
||||
? AntarchyGravityRotationUtil.vecPlayerToWorld(entity.getDeltaMovement(), gravityDirection)
|
||||
? GravityRotationUtil.vecPlayerToWorld(entity.getDeltaMovement(), gravityDirection)
|
||||
: entity.getDeltaMovement();
|
||||
|
||||
double axisVelocity = currentWorldVelocity.y * eruptionDirection.getStepY();
|
||||
@@ -343,7 +343,7 @@ public class PotentNyxiteBlockEntity extends BlockEntity {
|
||||
Vec3 nextWorldVelocity = currentWorldVelocity.add(worldPush);
|
||||
entity.setDeltaMovement(
|
||||
gravityDirection.isInverted()
|
||||
? AntarchyGravityRotationUtil.vecWorldToPlayer(nextWorldVelocity, gravityDirection)
|
||||
? GravityRotationUtil.vecWorldToPlayer(nextWorldVelocity, gravityDirection)
|
||||
: nextWorldVelocity
|
||||
);
|
||||
entity.hurtMarked = true;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.content.network.PortalGunTransitPayload;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransformUtil;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransitMath;
|
||||
@@ -34,7 +34,7 @@ public final class PortalGunClientTransit {
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
Vec3 crossingVelocity = AntarchyGravityApi.isGravityInverted(player)
|
||||
Vec3 crossingVelocity = GravityApi.isGravityInverted(player)
|
||||
? PortalGunTransitMath.entityVelocityToWorld(player, velocity)
|
||||
: velocity;
|
||||
for (PortalGunPortalEntity portal : PortalGunPortalEntity.findPortalsNearBounds(player.level(), startBox.minmax(currentBox).expandTowards(crossingVelocity).inflate(1.0D))) {
|
||||
@@ -49,7 +49,7 @@ public final class PortalGunClientTransit {
|
||||
connection.send(new ServerboundCustomPayloadPacket(new PortalGunTransitPayload(
|
||||
portal.getId(), PortalGunTransitMath.entityPosition(startBox, player), player.position(), velocity)));
|
||||
PortalGunPortalEntity.PortalTransit transit = portal.computeTransit(player, linked, currentBox, velocity, look);
|
||||
Vec3 rollLook = AntarchyGravityApi.isGravityInverted(player)
|
||||
Vec3 rollLook = GravityApi.isGravityInverted(player)
|
||||
? PortalGunTransitMath.entityVelocityToWorld(player, look)
|
||||
: look;
|
||||
PortalGunRollClientState.onTransit(portal, linked, rollLook);
|
||||
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.command;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public final class GravityCommand {
|
||||
private static final AntarchyGravityTransition COMMAND_TRANSITION = new AntarchyGravityTransition(12);
|
||||
|
||||
private GravityCommand() {
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
dispatcher.register(
|
||||
Commands.literal("gravity")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.then(Commands.literal("get")
|
||||
.then(Commands.argument("targets", EntityArgument.entities())
|
||||
.executes(context -> getGravity(context, EntityArgument.getEntities(context, "targets")))))
|
||||
.then(Commands.literal("set")
|
||||
.then(Commands.argument("targets", EntityArgument.entities())
|
||||
.then(Commands.literal("down")
|
||||
.executes(context -> setGravity(context, EntityArgument.getEntities(context, "targets"), AntarchyGravityDirection.DOWN)))
|
||||
.then(Commands.literal("up")
|
||||
.executes(context -> setGravity(context, EntityArgument.getEntities(context, "targets"), AntarchyGravityDirection.UP)))))
|
||||
.then(Commands.literal("clear")
|
||||
.then(Commands.argument("targets", EntityArgument.entities())
|
||||
.executes(context -> clearGravity(context, EntityArgument.getEntities(context, "targets")))))
|
||||
);
|
||||
}
|
||||
|
||||
private static int getGravity(CommandContext<CommandSourceStack> context, Collection<? extends Entity> targets) {
|
||||
for (Entity target : targets) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(target);
|
||||
context.getSource().sendSuccess(
|
||||
() -> Component.literal(target.getName().getString() + ": " + direction.getSerializedName()),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
return targets.size();
|
||||
}
|
||||
|
||||
private static int setGravity(CommandContext<CommandSourceStack> context, Collection<? extends Entity> targets, AntarchyGravityDirection direction) {
|
||||
for (Entity target : targets) {
|
||||
AntarchyGravityApi.setGravityDirection(target, direction, COMMAND_TRANSITION);
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(
|
||||
() -> Component.literal("Set gravity " + direction.getSerializedName() + " for " + targets.size() + " target(s)"),
|
||||
true
|
||||
);
|
||||
return targets.size();
|
||||
}
|
||||
|
||||
private static int clearGravity(CommandContext<CommandSourceStack> context, Collection<? extends Entity> targets) {
|
||||
for (Entity target : targets) {
|
||||
AntarchyGravityApi.setGravityDirection(target, AntarchyGravityDirection.DOWN, COMMAND_TRANSITION);
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(
|
||||
() -> Component.literal("Reset gravity for " + targets.size() + " target(s)"),
|
||||
true
|
||||
);
|
||||
return targets.size();
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.effect;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
public final class InvertedMobEffect extends MobEffect {
|
||||
private static final AntarchyGravityTransition EFFECT_TRANSITION = new AntarchyGravityTransition(12);
|
||||
|
||||
public InvertedMobEffect() {
|
||||
super(MobEffectCategory.HARMFUL, 0x8B0000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
||||
// Vex flight steering is authored around vanilla gravity and ground contact. Rotating its
|
||||
// gravity frame makes the native flight controller drive it into terrain.
|
||||
if (entity.getType() == EntityType.VEX) {
|
||||
if (!entity.level().isClientSide()) {
|
||||
AntarchyGravityApi.clearForcedGravity(entity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!entity.level().isClientSide()) {
|
||||
if (AntarchyGravityApi.getGravityDirection(entity) != AntarchyGravityDirection.UP || !AntarchyGravityApi.isGravityForced(entity)) {
|
||||
AntarchyGravityApi.setForcedGravityDirection(entity, AntarchyGravityDirection.UP, EFFECT_TRANSITION);
|
||||
}
|
||||
} else {
|
||||
// Mob effects are synced by vanilla, so this fires on the client too.
|
||||
// If the gravity state hasn't been applied yet , apply it directly without position adjustment.
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
AntarchyGravityApi.applySyncedState(entity, AntarchyGravityDirection.UP, AntarchyGravityDirection.UP, true, 0, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+7
-7
@@ -4,9 +4,9 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -477,15 +477,15 @@ public class AlphaMantisEntity extends MantisEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -334,16 +334,16 @@ public abstract class AppleCowEntity extends Cow implements GeoEntity, Shearable
|
||||
this.setDeltaMovement(this.toWorld(0.0D, motion.y < 0.0D ? motion.y : 0.0D, 0.0D));
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private int randomNapCooldown() {
|
||||
|
||||
+6
-6
@@ -5,9 +5,9 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.block.BedBugEggBlock;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -394,15 +394,15 @@ public class BedBugEntity extends Animal implements GeoEntity {
|
||||
}
|
||||
|
||||
private void commitLunge(LivingEntity target, double horizontalSpeed, double verticalSpeed) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
Vec3 horizontal = new Vec3(localLunge.x, 0.0D, localLunge.z);
|
||||
if (horizontal.lengthSqr() < 1.0E-4D) {
|
||||
return;
|
||||
}
|
||||
horizontal = horizontal.normalize().scale(horizontalSpeed);
|
||||
Vec3 localImpulse = new Vec3(horizontal.x, verticalSpeed, horizontal.z);
|
||||
Vec3 worldImpulse = AntarchyGravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
Vec3 worldImpulse = GravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(worldImpulse.x, worldImpulse.y, worldImpulse.z));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
+7
-7
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
@@ -352,16 +352,16 @@ public class BomberEntity extends Monster implements GeoEntity {
|
||||
return this.toLocal(this.getDeltaMovement()).horizontalDistanceSqr() > 1.0E-4D || this.getNavigation().isInProgress();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+4
-4
@@ -5,8 +5,8 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
@@ -184,7 +184,7 @@ public class ButterflyEntity extends Animal implements FlyingAnimal, GeoEntity {
|
||||
FlyingPathNavigation navigation = new FlyingPathNavigation(this, level) {
|
||||
@Override
|
||||
public boolean isStableDestination(BlockPos pos) {
|
||||
BlockPos support = AntarchyGravityApi.isGravityInverted(ButterflyEntity.this) ? pos.above() : pos.below();
|
||||
BlockPos support = GravityApi.isGravityInverted(ButterflyEntity.this) ? pos.above() : pos.below();
|
||||
return !this.level.getBlockState(support).isAir();
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ public class ButterflyEntity extends Animal implements FlyingAnimal, GeoEntity {
|
||||
|
||||
@Override
|
||||
protected void jumpInLiquid(net.minecraft.tags.TagKey<Fluid> fluidTag) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 0.01D, 0.0D, AntarchyGravityApi.getGravityDirection(this))));
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(GravityRotationUtil.vecPlayerToWorld(0.0D, 0.01D, 0.0D, GravityApi.getGravityDirection(this))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-7
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.RandomSource;
|
||||
@@ -228,16 +228,16 @@ public class CrawlingBlightEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -768,20 +768,20 @@ public class DorrieEntity extends Animal implements GeoEntity {
|
||||
|| this.getNavigation().isInProgress();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+23
-23
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -428,9 +428,9 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
case ACTIVE -> {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 motion = AntarchyGravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 motion = GravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
if (--this.hardenDurationTicks <= 0) {
|
||||
this.beginHardeningEnd();
|
||||
return;
|
||||
@@ -441,9 +441,9 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
case END -> {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 motion = AntarchyGravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 motion = GravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
if (--this.hardenStateTicks <= 0) {
|
||||
this.setHardenPhase(HardenPhase.NONE);
|
||||
this.hardenCooldownTicks = Math.max(1, AntarchySettings.emperorScorpionHardenCooldownTicks());
|
||||
@@ -504,10 +504,10 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
Vec3 anchor = this.getTarget() != null ? this.getTarget().position() : this.position();
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localRing = Vec3.directionFromRotation(0.0F, this.random.nextFloat() * 360.0F)
|
||||
.scale(2.75D + this.random.nextDouble() * 1.75D);
|
||||
Vec3 worldRing = AntarchyGravityRotationUtil.vecPlayerToWorld(localRing, direction);
|
||||
Vec3 worldRing = GravityRotationUtil.vecPlayerToWorld(localRing, direction);
|
||||
BlockPos spawnPos = this.findSummonSpawnPos(anchor.add(worldRing));
|
||||
Vec3 spawnCenter = Vec3.atCenterOf(spawnPos);
|
||||
scorpion.moveTo(spawnCenter.x, spawnCenter.y, spawnCenter.z, this.random.nextFloat() * 360.0F, 0.0F);
|
||||
@@ -522,22 +522,22 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void commitLunge(LivingEntity target, double horizontalSpeed, double verticalSpeed) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
Vec3 horizontal = new Vec3(localLunge.x, 0.0D, localLunge.z);
|
||||
if (horizontal.lengthSqr() < 1.0E-4D) {
|
||||
return;
|
||||
}
|
||||
horizontal = horizontal.normalize().scale(horizontalSpeed);
|
||||
Vec3 localImpulse = new Vec3(horizontal.x, verticalSpeed, horizontal.z);
|
||||
Vec3 worldImpulse = AntarchyGravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
Vec3 worldImpulse = GravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(worldImpulse.x, worldImpulse.y, worldImpulse.z));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
private BlockPos findSummonSpawnPos(Vec3 center) {
|
||||
BlockPos base = BlockPos.containing(center);
|
||||
Direction gravityDown = AntarchyGravityRotationUtil.getGravityDownDirection(this);
|
||||
Direction gravityDown = GravityRotationUtil.getGravityDownDirection(this);
|
||||
Direction gravityUp = gravityDown.getOpposite();
|
||||
BlockPos fallback = base;
|
||||
for (int step = -2; step <= 2; step++) {
|
||||
@@ -1001,10 +1001,10 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
|
||||
if (EmperorScorpionEntity.this.isWithinMeleeAttackRange(target) && EmperorScorpionEntity.this.hasLineOfSight(target)) {
|
||||
EmperorScorpionEntity.this.getNavigation().stop();
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localMotion = AntarchyGravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localMotion = GravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
Vec3 localStopped = new Vec3(0.0D, localMotion.y, 0.0D);
|
||||
Vec3 worldStopped = AntarchyGravityRotationUtil.vecPlayerToWorld(localStopped, direction);
|
||||
Vec3 worldStopped = GravityRotationUtil.vecPlayerToWorld(localStopped, direction);
|
||||
EmperorScorpionEntity.this.setDeltaMovement(worldStopped);
|
||||
AttackType attackType = EmperorScorpionEntity.this.selectAttack(target);
|
||||
if (attackType != AttackType.NONE) {
|
||||
@@ -1024,8 +1024,8 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void approachDirectly(LivingEntity target) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localDelta = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(EmperorScorpionEntity.this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localDelta = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(EmperorScorpionEntity.this.position()), direction);
|
||||
double dx = localDelta.x;
|
||||
double dz = localDelta.z;
|
||||
if (dx * dx + dz * dz < 1.0E-4D) {
|
||||
@@ -1039,15 +1039,15 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
EmperorScorpionEntity.this.yBodyRot = newYaw;
|
||||
EmperorScorpionEntity.this.yBodyRotO = newYaw;
|
||||
|
||||
Vec3 currentMotion = AntarchyGravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
Vec3 currentMotion = GravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
float headingError = Math.abs(Mth.wrapDegrees(targetYaw - currentYaw));
|
||||
if (headingError <= DIRECT_APPROACH_ALIGN_THRESHOLD) {
|
||||
double speed = EmperorScorpionEntity.this.getAttributeValue(Attributes.MOVEMENT_SPEED) * CHASE_SPEED;
|
||||
Vec3 forward = Vec3.directionFromRotation(0.0F, newYaw).scale(speed);
|
||||
Vec3 worldForward = AntarchyGravityRotationUtil.vecPlayerToWorld(forward.x, currentMotion.y, forward.z, direction);
|
||||
Vec3 worldForward = GravityRotationUtil.vecPlayerToWorld(forward.x, currentMotion.y, forward.z, direction);
|
||||
EmperorScorpionEntity.this.setDeltaMovement(worldForward);
|
||||
} else {
|
||||
EmperorScorpionEntity.this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, currentMotion.y, 0.0D, direction));
|
||||
EmperorScorpionEntity.this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(0.0D, currentMotion.y, 0.0D, direction));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchyGameRules;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.item.BigBerthaItem;
|
||||
import com.craisinlord.antarchy.content.network.HerculesBeetleImpactShakeSync;
|
||||
import java.util.EnumSet;
|
||||
@@ -1341,20 +1341,20 @@ public class HerculesBeetleEntity extends TamableAnimal implements GeoEntity, Fl
|
||||
.toList();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+8
-8
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.mixins.LivingEntityJumpingAccessor;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -70,7 +70,7 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effectInstance) {
|
||||
return effectInstance.getEffect().value() instanceof com.craisinlord.antarchy.content.effect.InvertedMobEffect;
|
||||
return effectInstance.getEffect().value() instanceof com.craisinlord.anthology.effect.InvertedMobEffect;
|
||||
}
|
||||
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
@@ -172,11 +172,11 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
if (!this.hasPassenger(passenger)) {
|
||||
return;
|
||||
}
|
||||
Vec3 riderOffset = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 riderOffset = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
RIDER_Y_OFFSET,
|
||||
0.0D,
|
||||
AntarchyGravityApi.getGravityDirection(this)
|
||||
GravityApi.getGravityDirection(this)
|
||||
);
|
||||
moveFunction.accept(passenger, this.getX() + riderOffset.x, this.getY() + riderOffset.y, this.getZ() + riderOffset.z);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
}
|
||||
|
||||
private double resolveVerticalMotion(boolean holdingJump) {
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravityDirection = GravityApi.getGravityDirection(this);
|
||||
double supportHeight = this.findSupportHeight(gravityDirection);
|
||||
double height = gravityDirection.isInverted() ? supportHeight - this.getY() : this.getY() - supportHeight;
|
||||
if (holdingJump) {
|
||||
@@ -236,7 +236,7 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
return -SETTLE_DESCEND_SPEED;
|
||||
}
|
||||
|
||||
private double findSupportHeight(AntarchyGravityDirection gravityDirection) {
|
||||
private double findSupportHeight(GravityDirection gravityDirection) {
|
||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ()));
|
||||
if (!gravityDirection.isInverted()) {
|
||||
int minY = this.level().getMinBuildHeight();
|
||||
|
||||
+7
-7
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.horde.CavarynHordeManager;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -308,16 +308,16 @@ public class JerryEntity extends Monster implements GeoEntity {
|
||||
: super.doHurtTarget(target);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.entity.royal.QueenEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -385,7 +385,7 @@ public class ManticoreEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private static Vec3 oppositeGravity(Entity entity) {
|
||||
return AntarchyGravityApi.isGravityInverted(entity) ? new Vec3(0.0D, -1.0D, 0.0D) : new Vec3(0.0D, 1.0D, 0.0D);
|
||||
return GravityApi.isGravityInverted(entity) ? new Vec3(0.0D, -1.0D, 0.0D) : new Vec3(0.0D, 1.0D, 0.0D);
|
||||
}
|
||||
|
||||
private void tickQueenSummonInversionRule() {
|
||||
@@ -395,8 +395,8 @@ public class ManticoreEntity extends Monster implements GeoEntity {
|
||||
if (this.hasEffect(AntarchyObjects.INVERTED_EFFECT.get())) {
|
||||
this.removeEffect(AntarchyObjects.INVERTED_EFFECT.get());
|
||||
}
|
||||
if (AntarchyGravityApi.isGravityInverted(this) && AntarchyGravityApi.isGravityForced(this)) {
|
||||
AntarchyGravityApi.setGravityDirection(this, AntarchyGravityDirection.DOWN, false);
|
||||
if (GravityApi.isGravityInverted(this) && GravityApi.isGravityForced(this)) {
|
||||
GravityApi.setGravityDirection(this, GravityDirection.DOWN, false);
|
||||
}
|
||||
this.setNoGravity(false);
|
||||
}
|
||||
|
||||
+11
-11
@@ -3,10 +3,10 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.entity.kraken.KrakenEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityTransition;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -413,8 +413,8 @@ public class MissileSquidEntity extends Monster implements GeoEntity {
|
||||
this.launchOwnerUuid = owner != null ? owner.getUUID() : null;
|
||||
this.setTarget(null);
|
||||
this.setNoGravity(false);
|
||||
if (owner != null && AntarchyGravityApi.isGravityInverted(owner)) {
|
||||
AntarchyGravityApi.setAirborneGravityDirection(this, AntarchyGravityApi.getGravityDirection(owner), true, AntarchyGravityTransition.INSTANT);
|
||||
if (owner != null && GravityApi.isGravityInverted(owner)) {
|
||||
GravityApi.setAirborneGravityDirection(this, GravityApi.getGravityDirection(owner), true, GravityTransition.INSTANT);
|
||||
}
|
||||
this.setDeltaMovement(velocity);
|
||||
this.hasImpulse = true;
|
||||
@@ -732,20 +732,20 @@ public class MissileSquidEntity extends Monster implements GeoEntity {
|
||||
this.setAnimationState(ANIM_IDLE);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+8
-8
@@ -4,9 +4,9 @@ import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -687,20 +687,20 @@ public class MolevoreEntity extends Monster implements GeoEntity {
|
||||
return forward.normalize().dot(toTarget.normalize()) >= minimumDot;
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
Vec3 local = AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
Vec3 local = GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return new Vec3(local.x, 0.0D, local.z);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -357,12 +357,12 @@ public class OctopusBombEntity extends Monster implements GeoEntity {
|
||||
public void launchAsExplosiveProjectile(net.minecraft.world.entity.Entity launcher, Vec3 velocity) {
|
||||
this.explosiveImpact = true;
|
||||
this.explosiveLauncherId = launcher != null ? launcher.getUUID() : null;
|
||||
if (launcher != null && com.craisinlord.antarchy.content.gravity.AntarchyGravityApi.isGravityInverted(launcher)) {
|
||||
com.craisinlord.antarchy.content.gravity.AntarchyGravityApi.setAirborneGravityDirection(
|
||||
if (launcher != null && com.craisinlord.anthology.gravity.GravityApi.isGravityInverted(launcher)) {
|
||||
com.craisinlord.anthology.gravity.GravityApi.setAirborneGravityDirection(
|
||||
this,
|
||||
com.craisinlord.antarchy.content.gravity.AntarchyGravityApi.getGravityDirection(launcher),
|
||||
com.craisinlord.anthology.gravity.GravityApi.getGravityDirection(launcher),
|
||||
true,
|
||||
com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition.INSTANT
|
||||
com.craisinlord.anthology.gravity.GravityTransition.INSTANT
|
||||
);
|
||||
}
|
||||
this.setDeltaMovement(velocity);
|
||||
|
||||
+6
-6
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -245,12 +245,12 @@ public class OuranwoodDeerEntity extends Animal implements GeoEntity {
|
||||
return MIN_QUIRK_COOLDOWN + this.random.nextInt(MAX_QUIRK_COOLDOWN - MIN_QUIRK_COOLDOWN + 1);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-8
@@ -7,9 +7,9 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.movement.DreamSandLowGravityAccess;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
@@ -663,8 +663,8 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
return false;
|
||||
}
|
||||
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(focus);
|
||||
Vec3 localMotion = AntarchyGravityRotationUtil.vecWorldToPlayer(focus.getDeltaMovement(), gravityDirection);
|
||||
GravityDirection gravityDirection = GravityApi.getGravityDirection(focus);
|
||||
Vec3 localMotion = GravityRotationUtil.vecWorldToPlayer(focus.getDeltaMovement(), gravityDirection);
|
||||
double descentThreshold = Math.max(0.02D, this.cfgDangerousFallSpeed);
|
||||
boolean invertedGravity = gravityDirection.isInverted();
|
||||
if (invertedGravity ? localMotion.y < descentThreshold : localMotion.y > -descentThreshold) {
|
||||
@@ -1008,7 +1008,7 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
}
|
||||
|
||||
private int getGravitySupportDistance(Player focus, int maxDistanceBlocks) {
|
||||
Direction gravityDown = AntarchyGravityRotationUtil.getGravityDownDirection(focus);
|
||||
Direction gravityDown = GravityRotationUtil.getGravityDownDirection(focus);
|
||||
Direction supportFace = gravityDown.getOpposite();
|
||||
BlockPos cursor = focus.blockPosition();
|
||||
for (int distance = 1; distance <= maxDistanceBlocks; distance++) {
|
||||
@@ -1047,7 +1047,7 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
double radius = Mth.lerp(1.0D - orbitBlend, desiredMin * 0.35D, desiredMax * 0.85D);
|
||||
Vec3 tetherAnchor = focus.position().add(focus.getDeltaMovement().scale(0.75D));
|
||||
double angle = orbitTime * (this.getId() % 2 == 0 ? 1.0D : -1.0D);
|
||||
double verticalOffset = AntarchyGravityApi.isGravityInverted(focus) ? -2.15D : 1.15D;
|
||||
double verticalOffset = GravityApi.isGravityInverted(focus) ? -2.15D : 1.15D;
|
||||
double y = tetherAnchor.y + verticalOffset + Math.sin(orbitTime * 0.8D) * 0.2D;
|
||||
return new Vec3(
|
||||
tetherAnchor.x + Math.cos(angle) * radius,
|
||||
@@ -1057,7 +1057,7 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
}
|
||||
|
||||
private Vec3 getPurpleProtectTarget(Player focus) {
|
||||
double verticalOffset = AntarchyGravityApi.isGravityInverted(focus) ? -0.95D : 0.95D;
|
||||
double verticalOffset = GravityApi.isGravityInverted(focus) ? -0.95D : 0.95D;
|
||||
Vec3 tetherAnchor = focus.position().add(focus.getDeltaMovement().scale(0.85D));
|
||||
Vec3 sideOffset = Vec3.directionFromRotation(0.0F, focus.getYRot() + 90.0F).scale(0.45D);
|
||||
return new Vec3(
|
||||
|
||||
+8
-8
@@ -4,9 +4,9 @@ import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -875,20 +875,20 @@ public class RollyPollyEntity extends TamableAnimal implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+6
-6
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -229,15 +229,15 @@ public class ScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void commitLunge(LivingEntity target, double horizontalSpeed, double verticalSpeed) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
Vec3 horizontal = new Vec3(localLunge.x, 0.0D, localLunge.z);
|
||||
if (horizontal.lengthSqr() < 1.0E-4D) {
|
||||
return;
|
||||
}
|
||||
horizontal = horizontal.normalize().scale(horizontalSpeed);
|
||||
Vec3 localImpulse = new Vec3(horizontal.x, verticalSpeed, horizontal.z);
|
||||
Vec3 worldImpulse = AntarchyGravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
Vec3 worldImpulse = GravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(worldImpulse.x, worldImpulse.y, worldImpulse.z));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
+6
-6
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -235,12 +235,12 @@ public class SpitBugEntity extends Monster implements GeoEntity {
|
||||
this.playSound(AntarchySoundEvents.SPIT_BUG_SPIT.get(), 1.0F, 0.85F + this.random.nextFloat() * 0.15F);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private final class SpitAttackGoal extends Goal {
|
||||
|
||||
+9
-9
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -412,7 +412,7 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
this.getNavigation().stop();
|
||||
this.setDeltaMovement(Vec3.ZERO);
|
||||
this.move(MoverType.SELF, Vec3.ZERO);
|
||||
this.setPos(this.getX(), AntarchyGravityApi.isGravityInverted(this) ? clingPos.getY() + 1.01D : clingPos.getY() - this.getBbHeight() - 0.01D, this.getZ());
|
||||
this.setPos(this.getX(), GravityApi.isGravityInverted(this) ? clingPos.getY() + 1.01D : clingPos.getY() - this.getBbHeight() - 0.01D, this.getZ());
|
||||
}
|
||||
|
||||
private void tickPouncing() {
|
||||
@@ -544,7 +544,7 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
return false;
|
||||
}
|
||||
double x = pos.getX() + 0.5D;
|
||||
double y = AntarchyGravityApi.isGravityInverted(this)
|
||||
double y = GravityApi.isGravityInverted(this)
|
||||
? pos.getY() + 1.01D
|
||||
: pos.getY() - this.getBbHeight() - 0.01D;
|
||||
double z = pos.getZ() + 0.5D;
|
||||
@@ -952,8 +952,8 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Direction gravityDownDirection() {
|
||||
@@ -961,11 +961,11 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.block.entity.WaspNestBlockEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -331,12 +331,12 @@ public class WaspEntity extends Monster implements GeoEntity, FlyingAnimal {
|
||||
return !this.onGround();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private void realignHitbox() {
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -566,7 +566,7 @@ public class BrutalflyEntity extends Monster implements GeoEntity {
|
||||
|
||||
private boolean shouldSwipe(LivingEntity target, FightPhase phase) {
|
||||
double horizontalDistanceSqr = new Vec3(target.getX() - this.getX(), 0.0D, target.getZ() - this.getZ()).lengthSqr();
|
||||
Vec3 localDelta = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), AntarchyGravityApi.getGravityDirection(this));
|
||||
Vec3 localDelta = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), GravityApi.getGravityDirection(this));
|
||||
horizontalDistanceSqr = new Vec3(localDelta.x, 0.0D, localDelta.z).lengthSqr();
|
||||
boolean beneathBoss = horizontalDistanceSqr <= 16.0D && localDelta.y <= 2.0D;
|
||||
return beneathBoss || this.distanceToSqr(target) <= phase.swipeRangeSqr;
|
||||
@@ -579,7 +579,7 @@ public class BrutalflyEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void tickSwipe(LivingEntity target) {
|
||||
Vec3 divePoint = target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 1.0D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 divePoint = target.position().add(GravityRotationUtil.vecPlayerToWorld(0.0D, 1.0D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.getMoveControl().setWantedPosition(divePoint.x, divePoint.y, divePoint.z, 1.45D);
|
||||
|
||||
if (this.animationTicks == 8) {
|
||||
@@ -608,7 +608,7 @@ public class BrutalflyEntity extends Monster implements GeoEntity {
|
||||
dz = this.random.nextDouble() - 0.5D;
|
||||
}
|
||||
target.knockback(SWIPE_KNOCKBACK, -dx, -dz);
|
||||
target.setDeltaMovement(target.getDeltaMovement().add(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 0.3D, 0.0D, AntarchyGravityApi.getGravityDirection(this))));
|
||||
target.setDeltaMovement(target.getDeltaMovement().add(GravityRotationUtil.vecPlayerToWorld(0.0D, 0.3D, 0.0D, GravityApi.getGravityDirection(this))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity.nightmare;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -170,9 +170,9 @@ public class NightmareBiteEntity extends Entity implements GeoEntity {
|
||||
}
|
||||
|
||||
private void updateTrackingPosition(LivingEntity target, double progress) {
|
||||
AntarchyGravityDirection targetGravity = AntarchyGravityApi.getGravityDirection(target);
|
||||
if (AntarchyGravityApi.getGravityDirection(this) != targetGravity) {
|
||||
AntarchyGravityApi.setGravityDirection(this, targetGravity);
|
||||
GravityDirection targetGravity = GravityApi.getGravityDirection(target);
|
||||
if (GravityApi.getGravityDirection(this) != targetGravity) {
|
||||
GravityApi.setGravityDirection(this, targetGravity);
|
||||
}
|
||||
Vec3 forward = target.getLookAngle().multiply(1.0D, 0.0D, 1.0D);
|
||||
if (forward.lengthSqr() < 1.0E-4D) {
|
||||
@@ -182,12 +182,12 @@ public class NightmareBiteEntity extends Entity implements GeoEntity {
|
||||
forward = new Vec3(0.0D, 0.0D, 1.0D);
|
||||
}
|
||||
forward = forward.normalize();
|
||||
Vec3 localUp = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 localUp = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 1.0D, 0.0D, targetGravity);
|
||||
Vec3 right = forward.cross(localUp).normalize();
|
||||
double sideOffset = START_SIDE_OFFSET + (END_SIDE_OFFSET - START_SIDE_OFFSET) * progress;
|
||||
double backOffset = START_BACK_OFFSET + (END_BACK_OFFSET - START_BACK_OFFSET) * progress;
|
||||
Vec3 bodyCenter = target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 bodyCenter = target.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, target.getBbHeight() * 0.55D, 0.0D, targetGravity));
|
||||
Vec3 desiredPos = bodyCenter
|
||||
.add(right.scale(this.approachSide * sideOffset))
|
||||
@@ -195,7 +195,7 @@ public class NightmareBiteEntity extends Entity implements GeoEntity {
|
||||
Vec3 toTarget = bodyCenter.subtract(desiredPos);
|
||||
this.setPos(desiredPos.x, desiredPos.y, desiredPos.z);
|
||||
if (toTarget.lengthSqr() > 1.0E-4D) {
|
||||
Vec3 localToTarget = AntarchyGravityRotationUtil.vecWorldToPlayer(toTarget, targetGravity);
|
||||
Vec3 localToTarget = GravityRotationUtil.vecWorldToPlayer(toTarget, targetGravity);
|
||||
float yaw = (float) Math.toDegrees(Math.atan2(localToTarget.z, localToTarget.x)) - 90.0F;
|
||||
this.setYRot(yaw);
|
||||
}
|
||||
|
||||
+15
-15
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
@@ -746,14 +746,14 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
: target.getEyePosition();
|
||||
Vec3 lunge = lungeTarget.subtract(this.getEyePosition());
|
||||
if (lunge.lengthSqr() > 1.0E-4D) {
|
||||
AntarchyGravityDirection direction = this.gravityDirection();
|
||||
Vec3 normalized = AntarchyGravityRotationUtil.vecWorldToPlayer(lunge, direction).normalize();
|
||||
GravityDirection direction = this.gravityDirection();
|
||||
Vec3 normalized = GravityRotationUtil.vecWorldToPlayer(lunge, direction).normalize();
|
||||
double verticalBoost = this.shouldUseFlyingLocomotion() ? 0.34D : 0.18D;
|
||||
Vec3 current = AntarchyGravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
Vec3 current = GravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
double upward = this.shouldUseFlyingLocomotion()
|
||||
? Math.max(normalized.y * verticalBoost, -0.08D)
|
||||
: normalized.y * verticalBoost;
|
||||
this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(
|
||||
normalized.x * 0.85D,
|
||||
current.y * 0.18D + upward,
|
||||
normalized.z * 0.85D,
|
||||
@@ -1106,26 +1106,26 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void knockAway(LivingEntity target, double horizontalStrength, double verticalStrength) {
|
||||
AntarchyGravityDirection direction = this.gravityDirection();
|
||||
GravityDirection direction = this.gravityDirection();
|
||||
Vec3 localDirection = this.toLocalPlane(target.position().subtract(this.position()));
|
||||
if (localDirection.lengthSqr() < 1.0E-4D) localDirection = this.toLocalPlane(this.getViewVector(1.0F));
|
||||
if (localDirection.lengthSqr() < 1.0E-4D) localDirection = new Vec3(1.0D, 0.0D, 0.0D);
|
||||
Vec3 localPush = localDirection.normalize().scale(horizontalStrength);
|
||||
Vec3 worldPush = AntarchyGravityRotationUtil.vecPlayerToWorld(localPush.x, verticalStrength, localPush.z, direction);
|
||||
Vec3 worldPush = GravityRotationUtil.vecPlayerToWorld(localPush.x, verticalStrength, localPush.z, direction);
|
||||
target.push(worldPush.x, worldPush.y, worldPush.z);
|
||||
target.hurtMarked = true;
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
@@ -1174,7 +1174,7 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private boolean tryBreakBlocksToTarget(LivingEntity target) {
|
||||
Direction gravityDown = AntarchyGravityRotationUtil.getGravityDownDirection(this);
|
||||
Direction gravityDown = GravityRotationUtil.getGravityDownDirection(this);
|
||||
BlockPos.MutableBlockPos cursor = this.blockPosition().mutable();
|
||||
for (int i = 0; i <= 16; i++) {
|
||||
if (this.level().getBlockState(cursor).is(AntarchyTags.Blocks.NIGHTMARE_BREAKABLE)) {
|
||||
@@ -1336,7 +1336,7 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private boolean isTooCloseToCeiling() {
|
||||
Direction gravityUp = AntarchyGravityRotationUtil.getGravityDownDirection(this).getOpposite();
|
||||
Direction gravityUp = GravityRotationUtil.getGravityDownDirection(this).getOpposite();
|
||||
BlockPos current = this.blockPosition();
|
||||
for (int i = 1; i <= FLIGHT_CEILING_CLEARANCE_BLOCKS; i++) {
|
||||
if (!this.level().isEmptyBlock(current.relative(gravityUp, i))) return true;
|
||||
|
||||
+17
-17
@@ -5,8 +5,8 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectEligibility;
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectHooks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.network.KingJudgmentFlashSync;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
@@ -821,8 +821,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
this.setRoyalFlying(true);
|
||||
this.getMoveControl().setWantedPosition(landing.x, landing.y, landing.z, 1.35D);
|
||||
this.tickKingLandingIndicator();
|
||||
Vec3 localLandingDelta = AntarchyGravityRotationUtil.vecWorldToPlayer(
|
||||
this.position().subtract(landing), AntarchyGravityApi.getGravityDirection(this));
|
||||
Vec3 localLandingDelta = GravityRotationUtil.vecWorldToPlayer(
|
||||
this.position().subtract(landing), GravityApi.getGravityDirection(this));
|
||||
double horizontalDistanceSquared = this.position().subtract(landing)
|
||||
.multiply(1.0D, 0.0D, 1.0D).lengthSqr();
|
||||
boolean reachedLanding = this.onGround()
|
||||
@@ -928,8 +928,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
this.performWingGust(level, target);
|
||||
}
|
||||
this.setRoyalFlying(true);
|
||||
this.addGravityAwareImpulse(this, AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
this.addGravityAwareImpulse(this, GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
@@ -943,8 +943,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
double radius = Mth.lerp(progress, 4.0D, STOMP_RADIUS);
|
||||
for (int index = 0; index < 36; index++) {
|
||||
double angle = Mth.TWO_PI * index / 36.0D;
|
||||
Vec3 indicator = this.kingLandingWaypoint.add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 indicator = this.kingLandingWaypoint.add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
level.sendParticles(ParticleTypes.ELECTRIC_SPARK,
|
||||
this.kingLandingWaypoint.x + Math.cos(angle) * radius,
|
||||
indicator.y,
|
||||
@@ -963,7 +963,7 @@ public class KingEntity extends RoyalBossEntity {
|
||||
for (double radius : radii) {
|
||||
double x = target.getX() + Math.cos(angle) * radius;
|
||||
double z = target.getZ() + Math.sin(angle) * radius;
|
||||
double y = AntarchyGravityApi.isGravityInverted(this)
|
||||
double y = GravityApi.isGravityInverted(this)
|
||||
? target.position().y - 0.1D
|
||||
: this.groundYBelow(x, z) + 0.1D;
|
||||
Vec3 candidate = new Vec3(x, y, z);
|
||||
@@ -974,7 +974,7 @@ public class KingEntity extends RoyalBossEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
double fallbackY = AntarchyGravityApi.isGravityInverted(this)
|
||||
double fallbackY = GravityApi.isGravityInverted(this)
|
||||
? target.position().y - 0.1D
|
||||
: this.groundYBelow(target.getX(), target.getZ()) + 0.1D;
|
||||
Vec3 fallback = new Vec3(target.getX(), fallbackY, target.getZ());
|
||||
@@ -986,7 +986,7 @@ public class KingEntity extends RoyalBossEntity {
|
||||
// Last resort: land directly beneath the King if the target ring is obstructed.
|
||||
// This still gives Close Quarters a committed ground sequence instead of silently
|
||||
// remaining airborne over difficult tree geometry.
|
||||
double directY = AntarchyGravityApi.isGravityInverted(this)
|
||||
double directY = GravityApi.isGravityInverted(this)
|
||||
? this.position().y - 0.1D
|
||||
: this.groundYBelow(this.getX(), this.getZ()) + 0.1D;
|
||||
Vec3 direct = new Vec3(this.getX(), directY, this.getZ());
|
||||
@@ -1632,8 +1632,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
continue;
|
||||
}
|
||||
living.hurt(this.damageSources().mobAttack(this), this.scaleRoyalDamage(12.0D));
|
||||
Vec3 lift = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.45D, 0.0D, AntarchyGravityApi.getGravityDirection(living));
|
||||
Vec3 lift = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.45D, 0.0D, GravityApi.getGravityDirection(living));
|
||||
this.addGravityAwareImpulse(living, this.royalChargeDirection.scale(2.1D).add(lift));
|
||||
living.hasImpulse = true;
|
||||
level.sendParticles(ParticleTypes.END_ROD, living.getX(), living.getY() + living.getBbHeight() * 0.5D,
|
||||
@@ -1821,8 +1821,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
float falloff = (float) Math.max(0.2D, 1.0D - distance / (STOMP_RADIUS + 6.0D));
|
||||
living.hurt(source, base * falloff);
|
||||
Vec3 push = living.position().subtract(this.position()).normalize().scale(2.4D * falloff);
|
||||
Vec3 vertical = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.85D, 0.0D, AntarchyGravityApi.getGravityDirection(living));
|
||||
Vec3 vertical = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.85D, 0.0D, GravityApi.getGravityDirection(living));
|
||||
this.addGravityAwareImpulse(living, new Vec3(push.x, 0.0D, push.z).add(vertical));
|
||||
living.hasImpulse = true;
|
||||
}
|
||||
@@ -2125,8 +2125,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
}
|
||||
|
||||
private void sendRoyalJudgmentTelegraph(ServerLevel level, LivingEntity target, int elapsedTicks) {
|
||||
Vec3 targetPoint = target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.35D, 0.0D, AntarchyGravityApi.getGravityDirection(target)));
|
||||
Vec3 targetPoint = target.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.35D, 0.0D, GravityApi.getGravityDirection(target)));
|
||||
double pulse = 0.8D + Math.min(1.0D, elapsedTicks / 20.0D) * 0.5D;
|
||||
for (RoyalHead.Slot slot : RoyalHead.Slot.values()) {
|
||||
RoyalHead head = this.royalHead(slot);
|
||||
|
||||
+28
-28
@@ -6,10 +6,10 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.entity.ManticoreEntity;
|
||||
import com.craisinlord.antarchy.content.entity.nightmare.NightmareBiteEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityTransition;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationApi;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationFieldEntity;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
@@ -576,7 +576,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
Vec3 away = this.position().subtract(target.position()).multiply(1.0D, 0.0D, 1.0D);
|
||||
double baseAngle = away.lengthSqr() > 1.0E-4D
|
||||
? Math.atan2(away.z, away.x) : this.random.nextDouble() * Mth.TWO_PI;
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
double[] radii = {10.0D, 14.0D, 18.0D, 7.0D};
|
||||
for (int angleIndex = 0; angleIndex < 12; angleIndex++) {
|
||||
double angle = baseAngle + angleIndex * Mth.TWO_PI / 12.0D;
|
||||
@@ -614,8 +614,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double progress = this.queenLandingStage == QueenLandingStage.TELEGRAPH
|
||||
? 1.0D - this.queenLandingStageTicks / (double) LANDING_TELEGRAPH_TICKS : 1.0D;
|
||||
double radius = Mth.lerp(progress, 4.0D, 18.0D);
|
||||
Vec3 indicator = this.queenLandingWaypoint.add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 indicator = this.queenLandingWaypoint.add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
for (int index = 0; index < 40; index++) {
|
||||
double angle = Mth.TWO_PI * index / 40.0D;
|
||||
level.sendParticles(ParticleTypes.REVERSE_PORTAL,
|
||||
@@ -639,8 +639,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
60, 7.0D, 1.0D, 7.0D, 0.12D);
|
||||
}
|
||||
this.setRoyalFlying(true);
|
||||
this.addGravityAwareImpulse(this, AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
this.addGravityAwareImpulse(this, GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
@@ -905,7 +905,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
queen.setPersistenceRequired();
|
||||
queen.setNoGravity(false);
|
||||
ThoraxisUndersideManager.applyUndersideInversion(queen);
|
||||
AntarchyGravityApi.setAirborneGravityDirection(queen, AntarchyGravityDirection.UP, true, new AntarchyGravityTransition(12));
|
||||
GravityApi.setAirborneGravityDirection(queen, GravityDirection.UP, true, new GravityTransition(12));
|
||||
queen.resetFallDistance();
|
||||
return level.addFreshEntity(queen) ? queen : null;
|
||||
}
|
||||
@@ -979,7 +979,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
Vec3 behindTarget = target.position().add(towardTarget.scale(8.0D));
|
||||
Vec3 lateral = new Vec3(-towardTarget.z, 0.0D, towardTarget.x);
|
||||
float tearYaw = (float) Math.toDegrees(Math.atan2(-towardTarget.x, towardTarget.z));
|
||||
double vertical = AntarchyGravityApi.isGravityInverted(this) ? -2.0D : 2.0D;
|
||||
double vertical = GravityApi.isGravityInverted(this) ? -2.0D : 2.0D;
|
||||
for (int i = 0; i < pairs; i++) {
|
||||
double forwardScatter = 3.0D + this.random.nextDouble() * 9.0D;
|
||||
double lateralScatter = (this.random.nextDouble() * 2.0D - 1.0D) * 11.0D;
|
||||
@@ -1173,7 +1173,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
}
|
||||
|
||||
private void spawnQueenWingPressure(ServerLevel level) {
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int ring = 1; ring <= 3; ring++) {
|
||||
double radius = ring * 3.2D;
|
||||
int samples = 14 + ring * 4;
|
||||
@@ -1181,9 +1181,9 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double angle = Mth.TWO_PI * sample / samples;
|
||||
double localX = Math.cos(angle) * radius;
|
||||
double localZ = Math.sin(angle) * radius;
|
||||
Vec3 point = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 point = this.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
localX, this.getBbHeight() * 0.45D, localZ, gravity));
|
||||
Vec3 velocity = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 velocity = GravityRotationUtil.vecPlayerToWorld(
|
||||
Math.cos(angle) * 0.2D, 0.025D, Math.sin(angle) * 0.2D, gravity);
|
||||
level.sendParticles(ACCEL_DUST, point.x, point.y, point.z,
|
||||
0, velocity.x, velocity.y, velocity.z, 1.0D);
|
||||
@@ -1258,8 +1258,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double distance = Math.max(1.0D, living.distanceTo(this));
|
||||
living.hurt(source, this.scaleRoyalDamage(12.0D * Math.max(0.25D, 1.0D - distance / 24.0D)));
|
||||
Vec3 push = living.position().subtract(this.position()).normalize().scale(1.3D);
|
||||
Vec3 vertical = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.65D, 0.0D, AntarchyGravityApi.getGravityDirection(living));
|
||||
Vec3 vertical = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.65D, 0.0D, GravityApi.getGravityDirection(living));
|
||||
this.addGravityAwareImpulse(living, new Vec3(push.x, 0.0D, push.z).add(vertical));
|
||||
living.hasImpulse = true;
|
||||
}
|
||||
@@ -1281,7 +1281,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
|
||||
private Vec3 selectBlackHoleAnchor(LivingEntity target) {
|
||||
double vertical = 2.0D + this.random.nextDouble() * 2.0D;
|
||||
if (AntarchyGravityApi.isGravityInverted(this)) {
|
||||
if (GravityApi.isGravityInverted(this)) {
|
||||
vertical = -vertical;
|
||||
}
|
||||
return target.position().add(
|
||||
@@ -1399,8 +1399,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
int elapsed = GRAVITY_STOMP_TELEGRAPH_TICKS - this.gravityStompTelegraphTicks;
|
||||
if (this.tickCount % 2 == 0) {
|
||||
double radius = Mth.lerp(elapsed / (double) GRAVITY_STOMP_TELEGRAPH_TICKS, 3.0D, 18.0D);
|
||||
Vec3 surfaceCenter = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 surfaceCenter = this.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.spawnQueenTelegraphSpokes(level, surfaceCenter, radius);
|
||||
}
|
||||
this.playQueenTelegraphBeat(level, this.gravityStompTelegraphTicks,
|
||||
@@ -1460,7 +1460,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
this.queenEffectBounds(CRUSHING_GRAVITY_RADIUS),
|
||||
living -> this.canDamageWithRoyalAttack(living)
|
||||
&& this.withinQueenEffectRange(living, CRUSHING_GRAVITY_RADIUS))) {
|
||||
double downSign = AntarchyGravityApi.isGravityInverted(living) ? 1.0D : -1.0D;
|
||||
double downSign = GravityApi.isGravityInverted(living) ? 1.0D : -1.0D;
|
||||
this.spawnCrushingGravityArrow(level, living, downSign, progress);
|
||||
}
|
||||
}
|
||||
@@ -1543,7 +1543,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double orbitRadius = Mth.lerp(Math.min(1.0D, progress * 1.6D), 1.0D, DEBRIS_CYCLONE_ORBIT_RADIUS);
|
||||
double spinSpeed = Mth.lerp(progress, 0.12D, 0.55D);
|
||||
int count = this.debrisCycloneBlocks.size();
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int index = 0; index < count; index++) {
|
||||
FallingBlockEntity block = this.debrisCycloneBlocks.get(index);
|
||||
if (!block.isAlive()) continue;
|
||||
@@ -1551,7 +1551,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double localX = Math.cos(angle) * orbitRadius;
|
||||
double localZ = Math.sin(angle) * orbitRadius;
|
||||
double localY = this.getBbHeight() * 0.5D + Math.sin(this.tickCount * 0.1D + index) * 0.4D;
|
||||
Vec3 point = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(localX, localY, localZ, gravity));
|
||||
Vec3 point = this.position().add(GravityRotationUtil.vecPlayerToWorld(localX, localY, localZ, gravity));
|
||||
block.setPos(point.x - 0.5D, point.y - 0.5D, point.z - 0.5D);
|
||||
block.setDeltaMovement(Vec3.ZERO);
|
||||
if (this.tickCount % 2 == 0) {
|
||||
@@ -1598,7 +1598,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
this.playRoyalSound(AntarchySoundEvents.QUEEN_ROAR.get(), 0.75F);
|
||||
if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
Vec3 center = this.position();
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
int gathered = 0;
|
||||
for (int attempt = 0; attempt < GRAVITIC_UPHEAVAL_BLOCK_COUNT * 3
|
||||
&& gathered < GRAVITIC_UPHEAVAL_BLOCK_COUNT; attempt++) {
|
||||
@@ -1670,14 +1670,14 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
|
||||
private void spawnBlackHoleFunnel(ServerLevel level, Vec3 center, double fieldRadius, double progress) {
|
||||
double rotation = this.tickCount * 0.35D;
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int tier = 0; tier < 4; tier++) {
|
||||
double tierProgress = tier / 3.0D;
|
||||
double radius = Mth.lerp(progress, fieldRadius * (0.25D + tierProgress * 0.5D), 0.7D);
|
||||
double localY = -1.5D + tierProgress * 4.5D;
|
||||
for (int point = 0; point < 10; point++) {
|
||||
double angle = rotation + tier * 0.65D + Mth.TWO_PI * point / 10.0D;
|
||||
Vec3 particlePos = center.add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 particlePos = center.add(GravityRotationUtil.vecPlayerToWorld(
|
||||
Math.cos(angle) * radius, localY, Math.sin(angle) * radius, gravity));
|
||||
level.sendParticles(ParticleTypes.REVERSE_PORTAL,
|
||||
particlePos.x, particlePos.y, particlePos.z,
|
||||
@@ -1742,13 +1742,13 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
private void spawnAccelerationHelix(ServerLevel level, double progress) {
|
||||
double rotation = this.tickCount * Mth.lerp(progress, 0.24D, 0.62D);
|
||||
double radius = Mth.lerp(progress, 2.8D, 0.75D);
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int strand = 0; strand < 2; strand++) {
|
||||
for (int segment = 0; segment < 9; segment++) {
|
||||
double heightProgress = segment / 8.0D;
|
||||
double angle = rotation + strand * Math.PI + heightProgress * Mth.TWO_PI * 1.5D;
|
||||
double localY = 0.4D + heightProgress * (this.getBbHeight() + 2.0D);
|
||||
Vec3 particlePos = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 particlePos = this.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
Math.cos(angle) * radius, localY, Math.sin(angle) * radius, gravity));
|
||||
level.sendParticles(AntarchyObjects.LUCID_BOLT_IMPACT_SMALL.get(),
|
||||
particlePos.x, particlePos.y, particlePos.z,
|
||||
@@ -1849,7 +1849,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
if (entity == this || isFieldImmune(entity) || entity instanceof Player player && player.isCreative()) {
|
||||
continue;
|
||||
}
|
||||
double downSign = AntarchyGravityApi.isGravityInverted(entity) ? 1.0D : -1.0D;
|
||||
double downSign = GravityApi.isGravityInverted(entity) ? 1.0D : -1.0D;
|
||||
entity.setDeltaMovement(entity.getDeltaMovement().add(0.0D, downSign * CRUSHING_GRAVITY_STRENGTH, 0.0D));
|
||||
entity.hasImpulse = true;
|
||||
if (entity instanceof LivingEntity living && this.tickCount % 8 == 0) {
|
||||
|
||||
+15
-15
@@ -10,8 +10,8 @@ import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamTerrainMode;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamElement;
|
||||
import com.craisinlord.antarchy.content.entity.royal.attack.RoyalAttackLane;
|
||||
import com.craisinlord.antarchy.content.entity.royal.attack.RoyalAttackScheduler;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -526,7 +526,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
if (this.isFlyingBoss()) {
|
||||
this.moveControl = this.isRoyalFlying() ? this.flyingMoveControl : this.groundMoveControl;
|
||||
this.navigation = this.isRoyalFlying() ? this.flyingNavigation : this.groundNavigation;
|
||||
this.setNoGravity(!AntarchyGravityApi.isGravityInverted(this));
|
||||
this.setNoGravity(!GravityApi.isGravityInverted(this));
|
||||
if (!this.isRoyalFlying()) {
|
||||
this.setNoGravity(false);
|
||||
}
|
||||
@@ -750,8 +750,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
}
|
||||
|
||||
protected final void addGravityAwareImpulse(Entity entity, Vec3 worldImpulse) {
|
||||
AntarchyGravityApi.setWorldVelocity(entity,
|
||||
AntarchyGravityApi.getWorldVelocity(entity).add(worldImpulse));
|
||||
GravityApi.setWorldVelocity(entity,
|
||||
GravityApi.getWorldVelocity(entity).add(worldImpulse));
|
||||
}
|
||||
|
||||
protected final boolean isRoyalPhaseTransitionActive() {
|
||||
@@ -937,7 +937,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
this.aerialCombatAnchor = null;
|
||||
this.aerialCombatAnchorTicks = 0;
|
||||
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
double groundBelowTarget = this.groundYBelow(wanted.x, wanted.z);
|
||||
double wantedY = this.landingForCombat
|
||||
? (inverted ? target.getY() + target.getBbHeight() - this.getBbHeight() : groundBelowTarget)
|
||||
@@ -964,7 +964,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
if (!this.isFlyingBoss() || this.managesOwnCombatLocomotion()) {
|
||||
return;
|
||||
}
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
double groundY = this.groundYBelow(this.getX(), this.getZ());
|
||||
if (this.landingForCombat) {
|
||||
if (!target.onGround()) {
|
||||
@@ -1007,7 +1007,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
this.entityData.set(ROYAL_FLYING, flying);
|
||||
this.moveControl = flying ? this.flyingMoveControl : this.groundMoveControl;
|
||||
this.navigation = flying ? this.flyingNavigation : this.groundNavigation;
|
||||
this.setNoGravity(flying && !AntarchyGravityApi.isGravityInverted(this));
|
||||
this.setNoGravity(flying && !GravityApi.isGravityInverted(this));
|
||||
}
|
||||
|
||||
protected double groundYBelow(double x, double z) {
|
||||
@@ -1016,7 +1016,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
}
|
||||
|
||||
private void tickFlyingAltitude() {
|
||||
if (AntarchyGravityApi.isGravityInverted(this)) {
|
||||
if (GravityApi.isGravityInverted(this)) {
|
||||
return;
|
||||
}
|
||||
if (this.onGround()) {
|
||||
@@ -1155,8 +1155,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
forward.x * spec.forwardOffset() + right.x * spec.lateralOffset(),
|
||||
spec.yOffset(),
|
||||
forward.z * spec.forwardOffset() + right.z * spec.lateralOffset());
|
||||
return this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
AntarchyGravityApi.getGravityDirection(this)));
|
||||
return this.position().add(GravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
GravityApi.getGravityDirection(this)));
|
||||
}
|
||||
|
||||
protected Vec3 beamAnchor(RoyalHead head) {
|
||||
@@ -1166,8 +1166,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
protected Vec3 beamDirection(RoyalHead head) {
|
||||
float yaw = this.getYRot() * Mth.DEG_TO_RAD;
|
||||
Vec3 localDirection = new Vec3(-Math.sin(yaw), 0.0D, Math.cos(yaw));
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localDirection,
|
||||
AntarchyGravityApi.getGravityDirection(this)).normalize();
|
||||
return GravityRotationUtil.vecPlayerToWorld(localDirection,
|
||||
GravityApi.getGravityDirection(this)).normalize();
|
||||
}
|
||||
|
||||
protected boolean targetInBeamLine(RoyalHead head, LivingEntity target) {
|
||||
@@ -1197,8 +1197,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
forward.x * BEAM_MUZZLE_FORWARD + right.x * lateral,
|
||||
vertical,
|
||||
forward.z * BEAM_MUZZLE_FORWARD + right.z * lateral);
|
||||
return new Vec3(x, y, z).add(AntarchyGravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
AntarchyGravityApi.getGravityDirection(this)));
|
||||
return new Vec3(x, y, z).add(GravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
GravityApi.getGravityDirection(this)));
|
||||
}
|
||||
|
||||
protected double royalBeamMinimumRange() {
|
||||
|
||||
+8
-8
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity.stratoshark;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -607,20 +607,20 @@ public class StratosharkEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+4
-4
@@ -2,8 +2,8 @@ package com.craisinlord.antarchy.content.entity.vortex;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -203,7 +203,7 @@ public class VortexEntity extends Monster implements GeoEntity {
|
||||
private void tickCombatMovement(LivingEntity target) {
|
||||
this.faceTowards(target.position().add(0.0D, target.getBbHeight() * 0.5D, 0.0D), 12.0F, 8.0F);
|
||||
Vec3 gravityUp = Vec3.atLowerCornerOf(
|
||||
AntarchyGravityRotationUtil.getGravityDownDirection(this).getOpposite().getNormal());
|
||||
GravityRotationUtil.getGravityDownDirection(this).getOpposite().getNormal());
|
||||
Vec3 hoverPosition = target.position().add(gravityUp.scale(2.5D));
|
||||
this.getMoveControl().setWantedPosition(hoverPosition.x, hoverPosition.y, hoverPosition.z, 0.38D);
|
||||
|
||||
@@ -256,7 +256,7 @@ public class VortexEntity extends Monster implements GeoEntity {
|
||||
double distance = direction.length();
|
||||
Vec3 drift = distance > 1.0E-6D ? direction.scale(0.24D / distance) : this.getViewVector(1.0F).scale(0.24D);
|
||||
WindVortexEntity vortex = WindVortexEntity.create(serverLevel, windVortexTypeSupplier.get(), origin, Vec3.ZERO, this, true);
|
||||
vortex.setAxis(AntarchyGravityRotationUtil.getGravityDownDirection(this).getOpposite());
|
||||
vortex.setAxis(GravityRotationUtil.getGravityDownDirection(this).getOpposite());
|
||||
vortex.setTravel(drift);
|
||||
vortex.setTravelDuration(Mth.clamp((int) Math.ceil(distance / drift.length()), 8, 36));
|
||||
vortex.setHoming(false);
|
||||
|
||||
+7
-7
@@ -2,8 +2,8 @@ package com.craisinlord.antarchy.content.entity.vortex;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -508,7 +508,7 @@ public class WindVortexEntity extends Entity {
|
||||
.add(tangent.scale(spin))
|
||||
.add(basis.axis.scale(axialSpeed))
|
||||
.scale(ENTITY_FORCE_SPEED_SCALE);
|
||||
Vec3 current = AntarchyGravityApi.getWorldVelocity(entity);
|
||||
Vec3 current = GravityApi.getWorldVelocity(entity);
|
||||
Vec3 updatedMovement = current.lerp(wanted, 0.72D);
|
||||
if (this.travelling) {
|
||||
updatedMovement = updatedMovement.add(this.travelVelocity.scale(0.8D * ENTITY_FORCE_SPEED_SCALE));
|
||||
@@ -516,12 +516,12 @@ public class WindVortexEntity extends Entity {
|
||||
if (mode == VortexMode.UPWARD && entity.onGround()) {
|
||||
double minRise = (entity instanceof Player ? 0.38D : 0.3D) * ENTITY_FORCE_SPEED_SCALE;
|
||||
Vec3 gravityUp = Vec3.atLowerCornerOf(
|
||||
AntarchyGravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
GravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
double minimumAxialSpeed = Math.max(updatedMovement.dot(gravityUp), minRise);
|
||||
updatedMovement = updatedMovement.add(gravityUp.scale(minimumAxialSpeed - updatedMovement.dot(gravityUp)));
|
||||
entity.setOnGround(false);
|
||||
}
|
||||
AntarchyGravityApi.setWorldVelocity(entity, updatedMovement);
|
||||
GravityApi.setWorldVelocity(entity, updatedMovement);
|
||||
if (entity instanceof Player) {
|
||||
entity.setOnGround(false);
|
||||
}
|
||||
@@ -572,7 +572,7 @@ public class WindVortexEntity extends Entity {
|
||||
double arc = Mth.clamp(distance * 0.06D, 0.25D, 1.1D) * ENTITY_FORCE_SPEED_SCALE;
|
||||
double power = this.launchStrength * Mth.clamp(distance / 6.0D, 0.6D, 2.0D) * ENTITY_FORCE_SPEED_SCALE;
|
||||
Vec3 gravityUp = Vec3.atLowerCornerOf(
|
||||
AntarchyGravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
GravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
this.setWorldVelocity(entity, direction.scale(power).add(gravityUp.scale(arc)));
|
||||
entity.fallDistance = 0.0F;
|
||||
entity.hasImpulse = true;
|
||||
@@ -592,7 +592,7 @@ public class WindVortexEntity extends Entity {
|
||||
}
|
||||
|
||||
private void setWorldVelocity(Entity entity, Vec3 velocity) {
|
||||
AntarchyGravityApi.setWorldVelocity(entity, velocity);
|
||||
GravityApi.setWorldVelocity(entity, velocity);
|
||||
}
|
||||
|
||||
private DamageSource damageSource() {
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
public interface AntarchyGravityAccess {
|
||||
AntarchyGravityDirection antarchy$getGravityDirection();
|
||||
|
||||
AntarchyGravityDirection antarchy$getPrevGravityDirection();
|
||||
|
||||
boolean antarchy$isGravityForced();
|
||||
|
||||
int antarchy$getGravityTransitionDuration();
|
||||
|
||||
int antarchy$getGravityTransitionRemaining();
|
||||
|
||||
void antarchy$setGravityState(AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition);
|
||||
|
||||
void antarchy$setAirborneGravityState(AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition);
|
||||
|
||||
void antarchy$applySyncedGravityState(
|
||||
AntarchyGravityDirection direction,
|
||||
AntarchyGravityDirection previousDirection,
|
||||
boolean forced,
|
||||
int transitionDuration,
|
||||
int transitionRemaining
|
||||
);
|
||||
}
|
||||
-238
@@ -1,238 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class AntarchyGravityApi {
|
||||
public interface GravitySyncDispatcher {
|
||||
void onGravityStateChanged(Entity entity);
|
||||
}
|
||||
|
||||
private static GravitySyncDispatcher syncDispatcher = entity -> {
|
||||
};
|
||||
|
||||
private AntarchyGravityApi() {
|
||||
}
|
||||
|
||||
public static AntarchyGravityDirection getGravityDirection(Entity entity) {
|
||||
return access(entity).antarchy$getGravityDirection();
|
||||
}
|
||||
|
||||
public static AntarchyGravityDirection getPrevGravityDirection(Entity entity) {
|
||||
return access(entity).antarchy$getPrevGravityDirection();
|
||||
}
|
||||
|
||||
public static boolean isGravityForced(Entity entity) {
|
||||
return access(entity).antarchy$isGravityForced();
|
||||
}
|
||||
|
||||
public static boolean isGravityInverted(Entity entity) {
|
||||
return getGravityDirection(entity).isInverted();
|
||||
}
|
||||
|
||||
public static int getTransitionDuration(Entity entity) {
|
||||
return access(entity).antarchy$getGravityTransitionDuration();
|
||||
}
|
||||
|
||||
public static int getTransitionRemaining(Entity entity) {
|
||||
return access(entity).antarchy$getGravityTransitionRemaining();
|
||||
}
|
||||
|
||||
public static float getGravityFlipProgress(Entity entity, float partialTick) {
|
||||
AntarchyGravityAccess access = access(entity);
|
||||
AntarchyGravityDirection current = access.antarchy$getGravityDirection();
|
||||
AntarchyGravityDirection previous = access.antarchy$getPrevGravityDirection();
|
||||
int duration = access.antarchy$getGravityTransitionDuration();
|
||||
int remaining = access.antarchy$getGravityTransitionRemaining();
|
||||
if (duration <= 0 || current == previous) {
|
||||
return current.isInverted() ? 1.0F : 0.0F;
|
||||
}
|
||||
|
||||
float elapsed = duration - remaining + partialTick;
|
||||
float fraction = Math.max(0.0F, Math.min(1.0F, elapsed / duration));
|
||||
return previous.isInverted() ? 1.0F - fraction : fraction;
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction) {
|
||||
setGravityDirection(entity, direction, false, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction, AntarchyGravityTransition transition) {
|
||||
setGravityDirection(entity, direction, false, transition);
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction, boolean forced) {
|
||||
setGravityDirection(entity, direction, forced, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition) {
|
||||
access(entity).antarchy$setGravityState(direction, forced, transition);
|
||||
}
|
||||
|
||||
public static void setForcedGravityDirection(Entity entity, AntarchyGravityDirection direction) {
|
||||
setForcedGravityDirection(entity, direction, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void setForcedGravityDirection(Entity entity, AntarchyGravityDirection direction, AntarchyGravityTransition transition) {
|
||||
access(entity).antarchy$setGravityState(direction, true, transition);
|
||||
}
|
||||
|
||||
public static void setAirborneGravityDirection(Entity entity, AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition) {
|
||||
access(entity).antarchy$setAirborneGravityState(direction, forced, transition);
|
||||
}
|
||||
|
||||
public static void clearForcedGravity(Entity entity) {
|
||||
access(entity).antarchy$setGravityState(AntarchyGravityDirection.DOWN, false, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void applySyncedState(
|
||||
Entity entity,
|
||||
AntarchyGravityDirection direction,
|
||||
AntarchyGravityDirection previousDirection,
|
||||
boolean forced,
|
||||
int transitionDuration,
|
||||
int transitionRemaining
|
||||
) {
|
||||
access(entity).antarchy$applySyncedGravityState(direction, previousDirection, forced, transitionDuration, transitionRemaining);
|
||||
}
|
||||
|
||||
public static void setSyncDispatcher(GravitySyncDispatcher dispatcher) {
|
||||
syncDispatcher = dispatcher;
|
||||
}
|
||||
|
||||
public static void notifyGravityStateChanged(Entity entity) {
|
||||
syncDispatcher.onGravityStateChanged(entity);
|
||||
}
|
||||
|
||||
public static Vec3 getWorldVelocity(Entity entity) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(entity.getDeltaMovement(), getGravityDirection(entity));
|
||||
}
|
||||
|
||||
public static void setWorldVelocity(Entity entity, Vec3 worldVelocity) {
|
||||
entity.setDeltaMovement(AntarchyGravityRotationUtil.vecWorldToPlayer(worldVelocity, getGravityDirection(entity)));
|
||||
}
|
||||
|
||||
public static Vec3 getEyeOffset(Entity entity) {
|
||||
return AntarchyGravityRotationUtil.getEyeOffset(entity, entity.getEyeHeight());
|
||||
}
|
||||
|
||||
public static double eyeX(Entity entity) {
|
||||
return isGravityInverted(entity) ? entity.getEyePosition().x : entity.getX();
|
||||
}
|
||||
|
||||
public static double eyeY(Entity entity) {
|
||||
return isGravityInverted(entity) ? entity.getEyePosition().y : entity.getY();
|
||||
}
|
||||
|
||||
public static double eyeZ(Entity entity) {
|
||||
return isGravityInverted(entity) ? entity.getEyePosition().z : entity.getZ();
|
||||
}
|
||||
|
||||
public static Vec3 deltaMovement(net.minecraft.world.entity.LivingEntity target) {
|
||||
return isGravityInverted(target) ? getWorldVelocity(target) : target.getDeltaMovement();
|
||||
}
|
||||
|
||||
public static double projectileSpawnX(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
return projectileSpawnVec(shooter).x;
|
||||
}
|
||||
|
||||
public static double projectileSpawnY(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
return projectileSpawnVec(shooter).y;
|
||||
}
|
||||
|
||||
public static double projectileSpawnZ(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
return projectileSpawnVec(shooter).z;
|
||||
}
|
||||
|
||||
public static double rangedBodyTargetX(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getX();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getBbHeight() * 0.3333333333333333D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).x;
|
||||
}
|
||||
|
||||
public static double rangedBodyTargetY(net.minecraft.world.entity.LivingEntity target, double heightScale) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getY(heightScale);
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getBbHeight() * 0.3333333333333333D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).y;
|
||||
}
|
||||
|
||||
public static double rangedBodyTargetZ(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getZ();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getBbHeight() * 0.3333333333333333D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).z;
|
||||
}
|
||||
|
||||
public static double rangedEyeTargetX(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getX();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getEyeHeight() - 1.100000023841858D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).x;
|
||||
}
|
||||
|
||||
public static double rangedEyeTargetY(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getEyeY();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getEyeHeight() - 1.100000023841858D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).y + 1.100000023841858D;
|
||||
}
|
||||
|
||||
public static double rangedEyeTargetZ(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getZ();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getEyeHeight() - 1.100000023841858D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).z;
|
||||
}
|
||||
|
||||
public static double rangedSqrt(double value, net.minecraft.world.entity.LivingEntity target) {
|
||||
return isGravityInverted(target) ? Math.sqrt(Math.sqrt(value)) : Math.sqrt(value);
|
||||
}
|
||||
|
||||
private static AntarchyGravityAccess access(Entity entity) {
|
||||
if (entity instanceof AntarchyGravityAccess access) {
|
||||
return access;
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Entity " + entity + " is missing Antarchy gravity state");
|
||||
}
|
||||
|
||||
private static Vec3 projectileSpawnVec(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
AntarchyGravityDirection direction = getGravityDirection(shooter);
|
||||
if (!direction.isInverted()) {
|
||||
return new Vec3(shooter.getX(), shooter.getEyeY() - 0.1D, shooter.getZ());
|
||||
}
|
||||
return shooter.getEyePosition().subtract(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 0.1D, 0.0D, direction));
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public enum AntarchyGravityDirection {
|
||||
DOWN(0, "down", false),
|
||||
UP(1, "up", true);
|
||||
|
||||
private final int id;
|
||||
private final String serializedName;
|
||||
private final boolean inverted;
|
||||
|
||||
AntarchyGravityDirection(int id, String serializedName, boolean inverted) {
|
||||
this.id = id;
|
||||
this.serializedName = serializedName;
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getSerializedName() {
|
||||
return this.serializedName;
|
||||
}
|
||||
|
||||
public boolean isInverted() {
|
||||
return this.inverted;
|
||||
}
|
||||
|
||||
public static AntarchyGravityDirection byId(int id) {
|
||||
return id == UP.id ? UP : DOWN;
|
||||
}
|
||||
|
||||
public static Optional<AntarchyGravityDirection> parse(String value) {
|
||||
for (AntarchyGravityDirection direction : values()) {
|
||||
if (direction.serializedName.equalsIgnoreCase(value)) {
|
||||
return Optional.of(direction);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public final class AntarchyGravityRotationUtil {
|
||||
private AntarchyGravityRotationUtil() {
|
||||
}
|
||||
|
||||
public static Vec3 vecWorldToPlayer(Vec3 vector, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
return new Vec3(-vector.x, -vector.y, vector.z);
|
||||
}
|
||||
|
||||
public static Vec3 vecWorldToPlayer(double x, double y, double z, AntarchyGravityDirection direction) {
|
||||
return vecWorldToPlayer(new Vec3(x, y, z), direction);
|
||||
}
|
||||
|
||||
public static Vec3 vecPlayerToWorld(Vec3 vector, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
return new Vec3(-vector.x, -vector.y, vector.z);
|
||||
}
|
||||
|
||||
public static Vec3 vecPlayerToWorld(double x, double y, double z, AntarchyGravityDirection direction) {
|
||||
return vecPlayerToWorld(new Vec3(x, y, z), direction);
|
||||
}
|
||||
|
||||
public static Vec3 maskPlayerToWorld(Vec3 vector, AntarchyGravityDirection direction) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static Vec3 getEyeOffset(Entity entity, double eyeHeight) {
|
||||
return vecPlayerToWorld(new Vec3(0.0D, eyeHeight, 0.0D), AntarchyGravityApi.getGravityDirection(entity));
|
||||
}
|
||||
|
||||
public static Vec3 getEyeOffset(Entity entity, double eyeHeight, float partialTick) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted() && AntarchyGravityApi.getGravityFlipProgress(entity, partialTick) <= 0.0F) {
|
||||
return new Vec3(0.0D, eyeHeight, 0.0D);
|
||||
}
|
||||
|
||||
Vector3f offset = new Vector3f(0.0F, (float) eyeHeight, 0.0F);
|
||||
offset.rotate(getWorldRotationQuaternion(entity, partialTick));
|
||||
return new Vec3(offset.x(), offset.y(), offset.z());
|
||||
}
|
||||
|
||||
public static AABB boxPlayerToWorld(AABB box, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return box;
|
||||
}
|
||||
|
||||
return new AABB(
|
||||
vecPlayerToWorld(new Vec3(box.minX, box.minY, box.minZ), direction),
|
||||
vecPlayerToWorld(new Vec3(box.maxX, box.maxY, box.maxZ), direction)
|
||||
);
|
||||
}
|
||||
|
||||
public static AABB boxWorldToPlayer(AABB box, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return box;
|
||||
}
|
||||
|
||||
return new AABB(
|
||||
vecWorldToPlayer(new Vec3(box.minX, box.minY, box.minZ), direction),
|
||||
vecWorldToPlayer(new Vec3(box.maxX, box.maxY, box.maxZ), direction)
|
||||
);
|
||||
}
|
||||
|
||||
public static Quaternionf getWorldRotationQuaternion(Entity entity, float partialTick) {
|
||||
return rotationAroundNegativeZ(180.0F * AntarchyGravityApi.getGravityFlipProgress(entity, partialTick));
|
||||
}
|
||||
|
||||
public static Quaternionf getCameraRotationQuaternion(Entity entity, float partialTick) {
|
||||
return rotationAroundNegativeZ(-180.0F * AntarchyGravityApi.getGravityFlipProgress(entity, partialTick));
|
||||
}
|
||||
|
||||
public static Vec2 rotWorldToPlayer(float yaw, float pitch, AntarchyGravityDirection direction) {
|
||||
Vec3 vector = vecWorldToPlayer(rotToVec(yaw, pitch), direction);
|
||||
return vecToRot(vector);
|
||||
}
|
||||
|
||||
public static Vec2 rotPlayerToWorld(float yaw, float pitch, AntarchyGravityDirection direction) {
|
||||
Vec3 vector = vecPlayerToWorld(rotToVec(yaw, pitch), direction);
|
||||
return vecToRot(vector);
|
||||
}
|
||||
|
||||
public static Direction getGravityDownDirection(Entity entity) {
|
||||
return AntarchyGravityApi.isGravityInverted(entity) ? Direction.UP : Direction.DOWN;
|
||||
}
|
||||
|
||||
public static BlockPos getSupportingBlockPos(Entity entity, double offset) {
|
||||
Direction direction = getGravityDownDirection(entity);
|
||||
Vec3 pos = entity.position().add(
|
||||
direction.getStepX() * offset,
|
||||
direction.getStepY() * offset,
|
||||
direction.getStepZ() * offset
|
||||
);
|
||||
return BlockPos.containing(pos);
|
||||
}
|
||||
|
||||
private static Quaternionf rotationAroundNegativeZ(float degrees) {
|
||||
return new Quaternionf().fromAxisAngleDeg(0.0F, 0.0F, -1.0F, degrees);
|
||||
}
|
||||
|
||||
private static Vec3 rotToVec(float yaw, float pitch) {
|
||||
double radPitch = pitch * 0.017453292F;
|
||||
double radNegYaw = -yaw * 0.017453292F;
|
||||
double cosNegYaw = Math.cos(radNegYaw);
|
||||
double sinNegYaw = Math.sin(radNegYaw);
|
||||
double cosPitch = Math.cos(radPitch);
|
||||
double sinPitch = Math.sin(radPitch);
|
||||
return new Vec3(sinNegYaw * cosPitch, -sinPitch, cosNegYaw * cosPitch);
|
||||
}
|
||||
|
||||
private static Vec2 vecToRot(Vec3 vector) {
|
||||
double sinPitch = -vector.y;
|
||||
double radPitch = Math.asin(sinPitch);
|
||||
double cosPitch = Math.cos(radPitch);
|
||||
double sinNegYaw = vector.x / cosPitch;
|
||||
double cosNegYaw = Math.max(-1.0D, Math.min(1.0D, vector.z / cosPitch));
|
||||
double radNegYaw = Math.acos(cosNegYaw);
|
||||
if (sinNegYaw < 0.0D) {
|
||||
radNegYaw = Math.PI * 2.0D - radNegYaw;
|
||||
}
|
||||
|
||||
return new Vec2((float) (-radNegYaw / 0.017453292F), (float) (radPitch / 0.017453292F));
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
public record AntarchyGravityTransition(int durationTicks) {
|
||||
public static final AntarchyGravityTransition INSTANT = new AntarchyGravityTransition(0);
|
||||
|
||||
public AntarchyGravityTransition {
|
||||
durationTicks = Math.max(0, durationTicks);
|
||||
}
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public final class AntarchyMountedGravityHelper {
|
||||
private static final AntarchyGravityTransition STACK_TRANSITION = new AntarchyGravityTransition(12);
|
||||
|
||||
private AntarchyMountedGravityHelper() {
|
||||
}
|
||||
|
||||
public static void syncConnectedStack(Entity entity) {
|
||||
if (entity == null || entity.level().isClientSide()) {
|
||||
return;
|
||||
}
|
||||
syncRootStack(entity.getRootVehicle(), null);
|
||||
}
|
||||
|
||||
public static void syncConnectedStackIgnoring(Entity entity, LivingEntity ignoredEffectSource) {
|
||||
if (entity == null || entity.level().isClientSide()) {
|
||||
return;
|
||||
}
|
||||
syncRootStack(entity.getRootVehicle(), ignoredEffectSource);
|
||||
}
|
||||
|
||||
public static void syncSeparatedStacks(Entity previousVehicle, Entity detachedEntity) {
|
||||
if (previousVehicle != null && !previousVehicle.level().isClientSide()) {
|
||||
syncRootStack(previousVehicle.getRootVehicle(), null);
|
||||
}
|
||||
if (detachedEntity != null && !detachedEntity.level().isClientSide()) {
|
||||
syncRootStack(detachedEntity.getRootVehicle(), null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void syncRootStack(Entity root, LivingEntity ignoredEffectSource) {
|
||||
boolean shouldInvert = stackHasInvertedEffect(root, ignoredEffectSource);
|
||||
applyGravityState(root, shouldInvert);
|
||||
for (Entity passenger : root.getIndirectPassengers()) {
|
||||
applyGravityState(passenger, shouldInvert);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean stackHasInvertedEffect(Entity root, LivingEntity ignoredEffectSource) {
|
||||
if (hasInvertedEffect(root, ignoredEffectSource)) {
|
||||
return true;
|
||||
}
|
||||
for (Entity passenger : root.getIndirectPassengers()) {
|
||||
if (hasInvertedEffect(passenger, ignoredEffectSource)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasInvertedEffect(Entity entity, LivingEntity ignoredEffectSource) {
|
||||
return entity instanceof LivingEntity living
|
||||
&& living != ignoredEffectSource
|
||||
&& living.hasEffect(AntarchyObjects.INVERTED_EFFECT.get());
|
||||
}
|
||||
|
||||
private static void applyGravityState(Entity entity, boolean shouldInvert) {
|
||||
if (shouldInvert) {
|
||||
if (AntarchyGravityApi.getGravityDirection(entity) != AntarchyGravityDirection.UP) {
|
||||
AntarchyGravityApi.setForcedGravityDirection(entity, AntarchyGravityDirection.UP, STACK_TRANSITION);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (AntarchyGravityApi.isGravityForced(entity)) {
|
||||
AntarchyGravityApi.setGravityDirection(entity, AntarchyGravityDirection.DOWN, false, STACK_TRANSITION);
|
||||
}
|
||||
}
|
||||
}
|
||||
-214
@@ -1,214 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.PathNavigationRegion;
|
||||
import net.minecraft.world.level.pathfinder.Node;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.level.pathfinder.PathfindingContext;
|
||||
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
|
||||
|
||||
public class GravityWalkNodeEvaluator extends WalkNodeEvaluator {
|
||||
private static final long LOG_TIME_THRESHOLD_NANOS = 25_000_000L;
|
||||
|
||||
private long antarchy$prepareStartNanos;
|
||||
private int antarchy$nodeProbeCount;
|
||||
|
||||
private static final int[] START_Y_SEARCH = {0, 1, -1, 2, -2};
|
||||
private static final int[][] INVERTED_CARDINAL_NEIGHBOR_OFFSETS = {
|
||||
{1, 0, 0},
|
||||
{-1, 0, 0},
|
||||
{0, 0, 1},
|
||||
{0, 0, -1}
|
||||
};
|
||||
private static final int[][] INVERTED_DIAGONAL_NEIGHBOR_OFFSETS = {
|
||||
{1, 0, 1},
|
||||
{1, 0, -1},
|
||||
{-1, 0, 1},
|
||||
{-1, 0, -1}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void prepare(PathNavigationRegion sourceIn, Mob mob) {
|
||||
super.prepare(sourceIn, mob);
|
||||
this.antarchy$prepareStartNanos = System.nanoTime();
|
||||
this.antarchy$nodeProbeCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
if (this.mob != null && AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
long elapsedNanos = System.nanoTime() - this.antarchy$prepareStartNanos;
|
||||
if (elapsedNanos > LOG_TIME_THRESHOLD_NANOS) {
|
||||
com.craisinlord.antarchy.Antarchy.LOGGER.warn(
|
||||
"[antarchy-gravity] slow inverted pathfind: type={} uuid={} pos=({}, {}, {}) nodeProbes={} elapsedMs={}",
|
||||
this.mob.getType(), this.mob.getUUID(),
|
||||
this.mob.getX(), this.mob.getY(), this.mob.getZ(),
|
||||
this.antarchy$nodeProbeCount, elapsedNanos / 1_000_000.0
|
||||
);
|
||||
}
|
||||
}
|
||||
super.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getStart() {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return super.getStart();
|
||||
}
|
||||
|
||||
int x = Mth.floor(this.mob.getX());
|
||||
int z = Mth.floor(this.mob.getZ());
|
||||
int y = Mth.floor(this.mob.getY() + this.mob.getBbHeight()) - 1;
|
||||
Node node = this.antarchy$findStartNode(x, y, z);
|
||||
// A floor-oriented start is a different coordinate model and must not
|
||||
// be mixed into an inverted search. PathFinder treats null as a clean
|
||||
// no-path result.
|
||||
return node;
|
||||
}
|
||||
|
||||
private Node antarchy$findStartNode(int x, int y, int z) {
|
||||
for (int dy : START_Y_SEARCH) {
|
||||
int candidateY = y + dy;
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
Node node = this.antarchy$createStartNode(x + dx, candidateY, z + dz);
|
||||
if (node != null) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Node antarchy$createStartNode(int x, int y, int z) {
|
||||
this.antarchy$nodeProbeCount++;
|
||||
if (!this.antarchy$hasCeilingSupport(this.currentContext, x, y, z)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PathType type = this.getPathTypeOfMob(this.currentContext, x, y, z, this.mob);
|
||||
float malus = this.mob.getPathfindingMalus(type);
|
||||
if (malus < 0.0F || type == PathType.OPEN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Node node = this.getNode(x, y, z);
|
||||
node.type = type;
|
||||
node.costMalus = malus;
|
||||
return node;
|
||||
}
|
||||
|
||||
private boolean antarchy$hasCeilingSupport(PathfindingContext context, int x, int y, int z) {
|
||||
for (int dx = 0; dx < this.entityWidth; dx++) {
|
||||
for (int dz = 0; dz < this.entityDepth; dz++) {
|
||||
BlockPos ceilingPos = new BlockPos(x + dx, y + 1, z + dz);
|
||||
if (!context.level().getBlockState(ceilingPos).isFaceSturdy(context.level(), ceilingPos, Direction.DOWN)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathType getPathTypeOfMob(PathfindingContext context, int x, int y, int z, Mob mob) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(mob)) {
|
||||
return super.getPathTypeOfMob(context, x, y, z, mob);
|
||||
}
|
||||
|
||||
if (!this.antarchy$hasCeilingSupport(context, x, y, z)) {
|
||||
return PathType.OPEN;
|
||||
}
|
||||
|
||||
PathType result = PathType.WALKABLE;
|
||||
for (int dw = 0; dw < this.entityWidth; dw++) {
|
||||
for (int dd = 0; dd < this.entityDepth; dd++) {
|
||||
for (int dh = 0; dh < this.entityHeight; dh++) {
|
||||
PathType type = this.getPathType(context, x + dw, y - dh, z + dd);
|
||||
float malus = mob.getPathfindingMalus(type);
|
||||
if (malus < 0.0F) {
|
||||
return type;
|
||||
}
|
||||
if (malus >= mob.getPathfindingMalus(result)) {
|
||||
result = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNeighbors(Node[] neighbors, Node current) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return super.getNeighbors(neighbors, current);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
Node[] cardinalNeighbors = new Node[INVERTED_CARDINAL_NEIGHBOR_OFFSETS.length];
|
||||
for (int i = 0; i < INVERTED_CARDINAL_NEIGHBOR_OFFSETS.length; i++) {
|
||||
int[] offset = INVERTED_CARDINAL_NEIGHBOR_OFFSETS[i];
|
||||
Node neighbor = this.antarchy$getNeighbor(current.x + offset[0], current.y, current.z + offset[2]);
|
||||
cardinalNeighbors[i] = neighbor;
|
||||
if (neighbor != null) {
|
||||
neighbors[count++] = neighbor;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < INVERTED_DIAGONAL_NEIGHBOR_OFFSETS.length; i++) {
|
||||
int[] offset = INVERTED_DIAGONAL_NEIGHBOR_OFFSETS[i];
|
||||
if (!this.antarchy$canUseDiagonal(cardinalNeighbors, i)) {
|
||||
continue;
|
||||
}
|
||||
Node neighbor = this.antarchy$getNeighbor(current.x + offset[0], current.y, current.z + offset[2]);
|
||||
if (neighbor != null) {
|
||||
neighbors[count++] = neighbor;
|
||||
}
|
||||
}
|
||||
|
||||
// Relative "up" for an inverted mob is world-Y down. Keep both
|
||||
// vertical directions available so a one-block ceiling step can be
|
||||
// represented in the path instead of trapping the mob below it.
|
||||
Node stepTowardInvertedUp = this.antarchy$getNeighbor(current.x, current.y - 1, current.z);
|
||||
if (stepTowardInvertedUp != null) {
|
||||
neighbors[count++] = stepTowardInvertedUp;
|
||||
}
|
||||
Node stepTowardInvertedDown = this.antarchy$getNeighbor(current.x, current.y + 1, current.z);
|
||||
if (stepTowardInvertedDown != null) {
|
||||
neighbors[count++] = stepTowardInvertedDown;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private boolean antarchy$canUseDiagonal(Node[] cardinalNeighbors, int diagonalIndex) {
|
||||
return switch (diagonalIndex) {
|
||||
case 0 -> cardinalNeighbors[0] != null && cardinalNeighbors[2] != null;
|
||||
case 1 -> cardinalNeighbors[0] != null && cardinalNeighbors[3] != null;
|
||||
case 2 -> cardinalNeighbors[1] != null && cardinalNeighbors[2] != null;
|
||||
case 3 -> cardinalNeighbors[1] != null && cardinalNeighbors[3] != null;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
private Node antarchy$getNeighbor(int x, int y, int z) {
|
||||
this.antarchy$nodeProbeCount++;
|
||||
PathType type = this.getPathTypeOfMob(this.currentContext, x, y, z, this.mob);
|
||||
if (type == PathType.OPEN || this.mob.getPathfindingMalus(type) < 0.0F) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Node node = this.getNode(x, y, z);
|
||||
if (node.closed) {
|
||||
return null;
|
||||
}
|
||||
node.type = type;
|
||||
node.costMalus = this.mob.getPathfindingMalus(type);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Converts a projectile launch vector from its shooter's gravity frame to world space. */
|
||||
public final class ProjectileLaunchGravity {
|
||||
private ProjectileLaunchGravity() {
|
||||
}
|
||||
|
||||
public static Vec3 toWorld(Vec3 launchDirection, AntarchyGravityDirection gravityDirection) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(launchDirection, gravityDirection);
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/** Exposes Scorched Guns' base ProjectileEntity fields to mixins targeting its subclasses. */
|
||||
public interface ScgunsProjectileAccess {
|
||||
@Nullable LivingEntity antarchy$getScgunsShooter();
|
||||
double antarchy$getScgunsModifiedGravity();
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.item;
|
||||
|
||||
import com.craisinlord.antarchy.content.block.AntimetalScaffoldingBlock;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.Item;
|
||||
@@ -24,7 +24,7 @@ public class AntimetalScaffoldingItem extends ScaffoldingBlockItem {
|
||||
Level level = context.getLevel();
|
||||
BlockState clickedState = level.getBlockState(clickedPos);
|
||||
Block block = this.getBlock();
|
||||
boolean inverted = context.getPlayer() != null && AntarchyGravityApi.isGravityInverted(context.getPlayer());
|
||||
boolean inverted = context.getPlayer() != null && GravityApi.isGravityInverted(context.getPlayer());
|
||||
|
||||
if (!clickedState.is(block)) {
|
||||
return AntimetalScaffoldingBlock.getDistance(level, clickedPos, inverted) == 7 ? null : context;
|
||||
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
package com.craisinlord.antarchy.content.item;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.network.ImpactShakeSync;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -105,10 +105,10 @@ public final class AttitudeAdjusterSlamManager {
|
||||
return false;
|
||||
}
|
||||
PLAYER_SLAMS.put(player.getUUID(), new PlayerSlamState(player.getUUID(), hand, player.serverLevel().dimension().location().toString(), player.serverLevel().getGameTime() + SLAM_TIMEOUT_TICKS, player.fallDistance));
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityRotationUtil.getGravityDownDirection(player) == Direction.UP ? AntarchyGravityDirection.UP : AntarchyGravityDirection.DOWN;
|
||||
GravityDirection gravityDirection = GravityRotationUtil.getGravityDownDirection(player) == Direction.UP ? GravityDirection.UP : GravityDirection.DOWN;
|
||||
Vec3 motion = player.getDeltaMovement();
|
||||
Vec3 localMotion = AntarchyGravityRotationUtil.vecWorldToPlayer(motion, gravityDirection);
|
||||
player.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(new Vec3(localMotion.x * 0.25D, PLAYER_SLAM_START_VELOCITY, localMotion.z * 0.25D), gravityDirection));
|
||||
Vec3 localMotion = GravityRotationUtil.vecWorldToPlayer(motion, gravityDirection);
|
||||
player.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(new Vec3(localMotion.x * 0.25D, PLAYER_SLAM_START_VELOCITY, localMotion.z * 0.25D), gravityDirection));
|
||||
player.hurtMarked = true;
|
||||
player.fallDistance = 0.0F;
|
||||
player.swing(hand, true);
|
||||
@@ -168,10 +168,10 @@ public final class AttitudeAdjusterSlamManager {
|
||||
if (!player.onGround()) {
|
||||
continue;
|
||||
}
|
||||
Direction gravityDown = AntarchyGravityRotationUtil.getGravityDownDirection(player);
|
||||
Direction gravityDown = GravityRotationUtil.getGravityDownDirection(player);
|
||||
Vec3 impactPos = player.position();
|
||||
BlockPos groundPos = getSlamSurfacePos(player, gravityDown);
|
||||
double localVerticalSpeed = AntarchyGravityRotationUtil.vecWorldToPlayer(player.getDeltaMovement(), gravityDown == Direction.UP ? AntarchyGravityDirection.UP : AntarchyGravityDirection.DOWN).y;
|
||||
double localVerticalSpeed = GravityRotationUtil.vecWorldToPlayer(player.getDeltaMovement(), gravityDown == Direction.UP ? GravityDirection.UP : GravityDirection.DOWN).y;
|
||||
double impactStrength = Math.max(Math.abs(Math.min(localVerticalSpeed, PLAYER_SLAM_START_VELOCITY)), Math.max(state.startFallDistance, player.fallDistance) * 0.15D);
|
||||
float damage = (float) Mth.clamp(PLAYER_SLAM_BASE_DAMAGE + impactStrength * PLAYER_SLAM_DAMAGE_SCALE * 10.0D, PLAYER_SLAM_BASE_DAMAGE, PLAYER_SLAM_MAX_DAMAGE);
|
||||
AABB area = new AABB(impactPos.x - PLAYER_SLAM_RADIUS, impactPos.y - 1.5D, impactPos.z - PLAYER_SLAM_RADIUS, impactPos.x + PLAYER_SLAM_RADIUS, impactPos.y + 2.5D, impactPos.z + PLAYER_SLAM_RADIUS);
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.client.model.ResourceBackedGeoItemModel;
|
||||
import com.craisinlord.antarchy.content.entity.lucid.LucidBoltEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -292,7 +292,7 @@ public class BigBerthaItem extends SwordItem implements GeoItem {
|
||||
Vec3 impactPos = new Vec3(target.getX(), target.getY(0.8D), target.getZ());
|
||||
LucidBoltEntity.spawnImpactParticles(level, impactPos);
|
||||
level.sendParticles(ParticleTypes.PORTAL, impactPos.x, impactPos.y, impactPos.z, 12, 0.25D, 0.25D, 0.25D, 0.08D);
|
||||
if (!AntarchyGravityApi.isGravityInverted(player)) {
|
||||
if (!GravityApi.isGravityInverted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.client.model.ResourceBackedGeoItemModel;
|
||||
import com.craisinlord.antarchy.content.client.renderer.AnimatedHeldItemRenderer;
|
||||
import com.craisinlord.antarchy.content.entity.vortex.WindVortexEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.ChatFormatting;
|
||||
@@ -77,15 +77,15 @@ public class EyeOfTheStormItem extends Item implements GeoItem {
|
||||
false
|
||||
);
|
||||
vortex.setMode(WindVortexEntity.VortexMode.UPWARD);
|
||||
vortex.setAxis(AntarchyGravityApi.isGravityInverted(player) ? Direction.DOWN : Direction.UP);
|
||||
vortex.setAxis(GravityApi.isGravityInverted(player) ? Direction.DOWN : Direction.UP);
|
||||
vortex.setVortexSize((float) AntarchySettings.eyeOfTheStormUpdraftHeight(), (float) AntarchySettings.eyeOfTheStormUpdraftRadius());
|
||||
vortex.setVortexDurationTicks(AntarchySettings.eyeOfTheStormUpdraftDurationTicks());
|
||||
serverLevel.addFreshEntity(vortex);
|
||||
|
||||
Vec3 gravityUp = Vec3.atLowerCornerOf(
|
||||
(AntarchyGravityApi.isGravityInverted(player) ? Direction.DOWN : Direction.UP).getNormal());
|
||||
AntarchyGravityApi.setWorldVelocity(player,
|
||||
AntarchyGravityApi.getWorldVelocity(player).add(gravityUp.scale(AntarchySettings.eyeOfTheStormUpdraftLaunchStrength())));
|
||||
(GravityApi.isGravityInverted(player) ? Direction.DOWN : Direction.UP).getNormal());
|
||||
GravityApi.setWorldVelocity(player,
|
||||
GravityApi.getWorldVelocity(player).add(gravityUp.scale(AntarchySettings.eyeOfTheStormUpdraftLaunchStrength())));
|
||||
player.hasImpulse = true;
|
||||
player.resetFallDistance();
|
||||
player.getCooldowns().addCooldown(this, AntarchySettings.eyeOfTheStormUpdraftCooldownTicks());
|
||||
@@ -133,7 +133,7 @@ public class EyeOfTheStormItem extends Item implements GeoItem {
|
||||
true
|
||||
);
|
||||
vortex.setMode(WindVortexEntity.VortexMode.UPWARD);
|
||||
vortex.setAxis(owner != null && AntarchyGravityApi.isGravityInverted(owner) ? Direction.DOWN : Direction.UP);
|
||||
vortex.setAxis(owner != null && GravityApi.isGravityInverted(owner) ? Direction.DOWN : Direction.UP);
|
||||
vortex.setVortexSize((float) AntarchySettings.eyeOfTheStormSurgeHeight(), (float) AntarchySettings.eyeOfTheStormSurgeRadius());
|
||||
vortex.setVortexDurationTicks(AntarchySettings.eyeOfTheStormSurgeDurationTicks());
|
||||
vortex.setVortexStrengths(AntarchySettings.eyeOfTheStormSurgePullStrength(), AntarchySettings.eyeOfTheStormSurgeReturnStrength());
|
||||
|
||||
+7
-7
@@ -4,8 +4,8 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.client.model.ResourceBackedGeoItemModel;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import it.unimi.dsi.fastutil.longs.Long2BooleanMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2BooleanOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||
@@ -527,11 +527,11 @@ public class GravityGunItem extends Item implements GeoItem {
|
||||
|
||||
private static Vec3 getHoldVector(Player player) {
|
||||
Vec3 look = getRawLookVector(player);
|
||||
if (!AntarchyGravityApi.isGravityInverted(player)) {
|
||||
if (!GravityApi.isGravityInverted(player)) {
|
||||
return look;
|
||||
}
|
||||
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(look, AntarchyGravityApi.getGravityDirection(player));
|
||||
return GravityRotationUtil.vecWorldToPlayer(look, GravityApi.getGravityDirection(player));
|
||||
}
|
||||
|
||||
private static Vec3 getRawLookVector(Player player) {
|
||||
@@ -540,14 +540,14 @@ public class GravityGunItem extends Item implements GeoItem {
|
||||
}
|
||||
|
||||
private static Vec2 getHoldRotation(Player player) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(player)) {
|
||||
if (!GravityApi.isGravityInverted(player)) {
|
||||
return new Vec2(player.getYRot(), player.getXRot());
|
||||
}
|
||||
|
||||
return AntarchyGravityRotationUtil.rotWorldToPlayer(
|
||||
return GravityRotationUtil.rotWorldToPlayer(
|
||||
player.getYRot(),
|
||||
player.getXRot(),
|
||||
AntarchyGravityApi.getGravityDirection(player)
|
||||
GravityApi.getGravityDirection(player)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ import com.craisinlord.antarchy.content.block.entity.PortalGunPortalFaceRecord;
|
||||
import com.craisinlord.antarchy.content.block.entity.PortalGunPortalCellAccess;
|
||||
import com.craisinlord.antarchy.content.client.model.ResourceBackedGeoItemModel;
|
||||
import com.craisinlord.antarchy.content.client.renderer.AnimatedHeldItemRenderer;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.antarchy.content.network.PortalGunPrimaryPayload;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPlacement;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunMoonMath;
|
||||
@@ -390,9 +390,9 @@ public class PortalGunItem extends Item implements GeoItem {
|
||||
|
||||
private Vec3 worldLook(LivingEntity entity) {
|
||||
Vec3 look = entity.getLookAngle();
|
||||
return AntarchyGravityApi.isGravityInverted(entity)
|
||||
? com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
look, AntarchyGravityApi.getGravityDirection(entity))
|
||||
return GravityApi.isGravityInverted(entity)
|
||||
? com.craisinlord.anthology.gravity.GravityRotationUtil.vecPlayerToWorld(
|
||||
look, GravityApi.getGravityDirection(entity))
|
||||
: look;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.client.model.ResourceBackedGeoItemModel;
|
||||
import com.craisinlord.antarchy.content.client.renderer.AnimatedHeldItemRenderer;
|
||||
import com.craisinlord.antarchy.content.entity.OctopusBombEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
@@ -165,11 +165,11 @@ public class RpoLauncherItem extends ProjectileWeaponItem implements GeoItem {
|
||||
|
||||
float yaw = player.getYRot() + yawOffset;
|
||||
Vec3 localDirection = Vec3.directionFromRotation(new Vec2(player.getXRot(), yaw));
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(player);
|
||||
Vec3 direction = AntarchyGravityRotationUtil.vecPlayerToWorld(localDirection, gravity).normalize();
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(player);
|
||||
Vec3 direction = GravityRotationUtil.vecPlayerToWorld(localDirection, gravity).normalize();
|
||||
Vec3 spawn = player.getEyePosition().add(direction.scale(0.55D));
|
||||
projectileBomb.moveTo(spawn.x, spawn.y, spawn.z, yaw, player.getXRot());
|
||||
projectileBomb.launchAsExplosiveProjectile(player, direction.scale(AntarchySettings.rpoLauncherLaunchVelocity()).add(AntarchyGravityApi.deltaMovement(player)));
|
||||
projectileBomb.launchAsExplosiveProjectile(player, direction.scale(AntarchySettings.rpoLauncherLaunchVelocity()).add(GravityApi.deltaMovement(player)));
|
||||
level.addFreshEntity(projectileBomb);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -5,9 +5,9 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.client.model.ResourceBackedGeoItemModel;
|
||||
import com.craisinlord.antarchy.content.entity.MissileSquidEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
@@ -166,11 +166,11 @@ public class SquidzookaItem extends ProjectileWeaponItem implements GeoItem {
|
||||
|
||||
float yaw = player.getYRot() + yawOffset;
|
||||
Vec3 localDirection = Vec3.directionFromRotation(new Vec2(player.getXRot(), yaw));
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(player);
|
||||
Vec3 direction = AntarchyGravityRotationUtil.vecPlayerToWorld(localDirection, gravity).normalize();
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(player);
|
||||
Vec3 direction = GravityRotationUtil.vecPlayerToWorld(localDirection, gravity).normalize();
|
||||
Vec3 spawn = player.getEyePosition().add(direction.scale(0.45D));
|
||||
projectileSquid.moveTo(spawn.x, spawn.y, spawn.z, yaw, player.getXRot());
|
||||
projectileSquid.launchAsProjectile(player, direction.scale(AntarchySettings.squidzookaLaunchVelocity()).add(AntarchyGravityApi.deltaMovement(player)));
|
||||
projectileSquid.launchAsProjectile(player, direction.scale(AntarchySettings.squidzookaLaunchVelocity()).add(GravityApi.deltaMovement(player)));
|
||||
level.addFreshEntity(projectileSquid);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -2,8 +2,8 @@ package com.craisinlord.antarchy.content.item;
|
||||
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.entity.WormHookProjectileEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.util.WormHookRope;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -161,11 +161,11 @@ public final class WormHookTetherManager {
|
||||
}
|
||||
|
||||
private static Vec3 getWorldMotion(ServerPlayer player) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(player.getDeltaMovement(), AntarchyGravityApi.getGravityDirection(player));
|
||||
return GravityRotationUtil.vecPlayerToWorld(player.getDeltaMovement(), GravityApi.getGravityDirection(player));
|
||||
}
|
||||
|
||||
private static void setWorldMotion(ServerPlayer player, Vec3 worldMotion) {
|
||||
player.setDeltaMovement(AntarchyGravityRotationUtil.vecWorldToPlayer(worldMotion, AntarchyGravityApi.getGravityDirection(player)));
|
||||
player.setDeltaMovement(GravityRotationUtil.vecWorldToPlayer(worldMotion, GravityApi.getGravityDirection(player)));
|
||||
}
|
||||
|
||||
private static void tickFlyingSound(ServerPlayer player, TetherState state) {
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package com.craisinlord.antarchy.content.movement;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.client.PortalGunRollClientState;
|
||||
import com.craisinlord.antarchy.content.entity.BedBugEntity;
|
||||
import com.craisinlord.antarchy.content.entity.portal.DimensionalTearEntity;
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.craisinlord.anthology.effect.AnthologyEffects;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityHooks;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
||||
public final class AntarchyGravityHooks {
|
||||
private AntarchyGravityHooks() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
GravityHooks.addInvertedRegion(ThoraxisUndersideManager::isInUnderside);
|
||||
GravityHooks.addInvertedFluid(AntarchyFluidChecks::isAntiwater);
|
||||
GravityHooks.addLoadListener(AntarchyGravityHooks::clearStaleUndersideInversion);
|
||||
}
|
||||
|
||||
public static void registerClient() {
|
||||
GravityHooks.addCameraRollSource(PortalGunRollClientState::getRollDegrees);
|
||||
}
|
||||
|
||||
private static void clearStaleUndersideInversion(Entity entity) {
|
||||
if (!(entity instanceof Mob mob)
|
||||
|| !GravityApi.isGravityInverted(mob)
|
||||
|| !GravityApi.isGravityForced(mob)) {
|
||||
return;
|
||||
}
|
||||
MobEffectInstance invertedEffect = mob.getEffect(AnthologyEffects.inverted());
|
||||
boolean aboveUndersideExit = ThoraxisUndersideManager.isAboveUndersideExit(mob);
|
||||
int nearbyDimensionalTears = countNearbyDimensionalTears(mob);
|
||||
if (invertedEffect != null
|
||||
&& invertedEffect.isAmbient()
|
||||
&& !invertedEffect.isVisible()
|
||||
&& aboveUndersideExit) {
|
||||
clearInversion(mob);
|
||||
Antarchy.LOGGER.warn(
|
||||
"[antarchy-gravity] cleared stale underside inversion from loaded mob type={} uuid={} pos=({}, {}, {}) dim={} effectDuration={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect.getDuration(), nearbyDimensionalTears
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (invertedEffect != null
|
||||
&& mob instanceof BedBugEntity
|
||||
&& aboveUndersideExit
|
||||
&& ThoraxisUndersideManager.isThoraxis(mob.level())) {
|
||||
clearInversion(mob);
|
||||
Antarchy.LOGGER.warn(
|
||||
"[antarchy-gravity] cleared loaded inverted bed bug above underside exit type={} uuid={} pos=({}, {}, {}) dim={} effectDuration={} effectAmbient={} effectVisible={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect.getDuration(), invertedEffect.isAmbient(), invertedEffect.isVisible(), nearbyDimensionalTears
|
||||
);
|
||||
return;
|
||||
}
|
||||
Antarchy.LOGGER.info(
|
||||
"[antarchy-gravity] loaded inverted mob type={} uuid={} pos=({}, {}, {}) dim={} hasInvertedEffect={} effectDuration={} effectAmbient={} effectVisible={} aboveUndersideExit={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect != null,
|
||||
invertedEffect != null ? invertedEffect.getDuration() : -1,
|
||||
invertedEffect != null && invertedEffect.isAmbient(),
|
||||
invertedEffect != null && invertedEffect.isVisible(),
|
||||
aboveUndersideExit,
|
||||
nearbyDimensionalTears
|
||||
);
|
||||
}
|
||||
|
||||
private static void clearInversion(Mob mob) {
|
||||
mob.removeEffect(AnthologyEffects.inverted());
|
||||
GravityApi.resetGravityState(mob);
|
||||
}
|
||||
|
||||
private static int countNearbyDimensionalTears(Mob mob) {
|
||||
if (!(mob.level() instanceof ServerLevel serverLevel)) {
|
||||
return -1;
|
||||
}
|
||||
return serverLevel.getEntitiesOfClass(
|
||||
DimensionalTearEntity.class,
|
||||
mob.getBoundingBox().inflate(48.0D),
|
||||
Entity::isAlive
|
||||
).size();
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.network;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public record GravityStatePayload(
|
||||
int entityId,
|
||||
int directionId,
|
||||
int previousDirectionId,
|
||||
boolean forced,
|
||||
int transitionDuration,
|
||||
int transitionRemaining
|
||||
) implements CustomPacketPayload {
|
||||
public static final Type<GravityStatePayload> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "gravity_state"));
|
||||
public static final StreamCodec<ByteBuf, GravityStatePayload> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.VAR_INT,
|
||||
GravityStatePayload::entityId,
|
||||
ByteBufCodecs.VAR_INT,
|
||||
GravityStatePayload::directionId,
|
||||
ByteBufCodecs.VAR_INT,
|
||||
GravityStatePayload::previousDirectionId,
|
||||
ByteBufCodecs.BOOL,
|
||||
GravityStatePayload::forced,
|
||||
ByteBufCodecs.VAR_INT,
|
||||
GravityStatePayload::transitionDuration,
|
||||
ByteBufCodecs.VAR_INT,
|
||||
GravityStatePayload::transitionRemaining,
|
||||
GravityStatePayload::new
|
||||
);
|
||||
|
||||
public GravityStatePayload(int entityId, AntarchyGravityDirection direction, AntarchyGravityDirection previousDirection, boolean forced, int transitionDuration, int transitionRemaining) {
|
||||
this(entityId, direction.getId(), previousDirection.getId(), forced, transitionDuration, transitionRemaining);
|
||||
}
|
||||
|
||||
public AntarchyGravityDirection direction() {
|
||||
return AntarchyGravityDirection.byId(this.directionId);
|
||||
}
|
||||
|
||||
public AntarchyGravityDirection previousDirection() {
|
||||
return AntarchyGravityDirection.byId(this.previousDirectionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<GravityStatePayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -2,7 +2,7 @@ package com.craisinlord.antarchy.content.portalgun;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.antarchy.content.block.entity.PortalGunPortalBaseBlockEntity;
|
||||
import com.craisinlord.antarchy.content.block.entity.PortalGunPortalCellAccess;
|
||||
import com.craisinlord.antarchy.content.block.entity.PortalGunPortalFaceRecord;
|
||||
@@ -388,7 +388,7 @@ public class PortalGunPortalEntity extends Entity implements GeoEntity {
|
||||
}
|
||||
|
||||
public PortalTransit computeTransit(Entity entity, PortalGunPortalEntity destination, AABB box, Vec3 velocity, Vec3 look) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
if (!GravityApi.isGravityInverted(entity)) {
|
||||
return computeTransit(destination, box, velocity, look);
|
||||
}
|
||||
PortalGunWorldPortalShape source = this.getWorldPortalShape();
|
||||
@@ -951,7 +951,7 @@ public class PortalGunPortalEntity extends Entity implements GeoEntity {
|
||||
Vec3 memberLook;
|
||||
if (root) {
|
||||
memberLook = transit.look();
|
||||
} else if (AntarchyGravityApi.isGravityInverted(member)) {
|
||||
} else if (GravityApi.isGravityInverted(member)) {
|
||||
Vec3 worldLook = PortalGunTransitMath.entityVelocityToWorld(member, state.look());
|
||||
memberLook = PortalGunTransitMath.entityVelocityFromWorld(member,
|
||||
PortalGunTransformUtil.transformVector(this, destination, worldLook).normalize());
|
||||
@@ -961,7 +961,7 @@ public class PortalGunPortalEntity extends Entity implements GeoEntity {
|
||||
Vec3 memberMotion;
|
||||
if (root) {
|
||||
memberMotion = transit.velocity();
|
||||
} else if (AntarchyGravityApi.isGravityInverted(member)) {
|
||||
} else if (GravityApi.isGravityInverted(member)) {
|
||||
Vec3 worldMotion = PortalGunTransitMath.entityVelocityToWorld(member, state.motion());
|
||||
memberMotion = PortalGunTransitMath.entityVelocityFromWorld(member,
|
||||
PortalGunTransformUtil.transformVector(this, destination, worldMotion));
|
||||
@@ -971,7 +971,7 @@ public class PortalGunPortalEntity extends Entity implements GeoEntity {
|
||||
float yaw = PortalGunTransformUtil.yawFromLook(memberLook);
|
||||
float pitch = PortalGunTransformUtil.pitchFromLook(memberLook);
|
||||
float fallDistance = PortalGunTransitMath.exitFallDistance(member.fallDistance,
|
||||
AntarchyGravityApi.isGravityInverted(member) ? PortalGunTransitMath.entityVelocityToWorld(member, memberMotion) : memberMotion,
|
||||
GravityApi.isGravityInverted(member) ? PortalGunTransitMath.entityVelocityToWorld(member, memberMotion) : memberMotion,
|
||||
member);
|
||||
if (member instanceof ServerPlayer player && root && clientAuthoritative) {
|
||||
player.moveTo(memberExitPos.x, memberExitPos.y, memberExitPos.z, yaw, pitch);
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
package com.craisinlord.antarchy.content.portalgun;
|
||||
|
||||
import com.craisinlord.antarchy.content.item.PortalGunItem;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityTransition;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@@ -126,7 +126,7 @@ public class PortalGunProjectileEntity extends ThrowableItemProjectile {
|
||||
}
|
||||
|
||||
public void configure(PortalGunPortalEntity.PortalSide side, UUID gunId, ItemStack gunStack) {
|
||||
AntarchyGravityApi.setAirborneGravityDirection(this, AntarchyGravityDirection.DOWN, false, AntarchyGravityTransition.INSTANT);
|
||||
GravityApi.setAirborneGravityDirection(this, GravityDirection.DOWN, false, GravityTransition.INSTANT);
|
||||
this.entityData.set(SIDE, side.ordinal());
|
||||
this.gunId = gunId;
|
||||
this.setItem(gunStack.copyWithCount(1));
|
||||
|
||||
+9
-9
@@ -1,8 +1,8 @@
|
||||
package com.craisinlord.antarchy.content.portalgun;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -70,7 +70,7 @@ public final class PortalGunTransitMath {
|
||||
}
|
||||
|
||||
public static Vec3 entityPosition(AABB box, Entity entity) {
|
||||
return entityPosition(box, AntarchyGravityApi.isGravityInverted(entity));
|
||||
return entityPosition(box, GravityApi.isGravityInverted(entity));
|
||||
}
|
||||
|
||||
public static Vec3 entityPosition(AABB box, boolean inverted) {
|
||||
@@ -81,25 +81,25 @@ public final class PortalGunTransitMath {
|
||||
}
|
||||
|
||||
public static Vec3 entityVelocityToWorld(Entity entity, Vec3 velocity) {
|
||||
return entityVelocityToWorld(velocity, AntarchyGravityApi.isGravityInverted(entity));
|
||||
return entityVelocityToWorld(velocity, GravityApi.isGravityInverted(entity));
|
||||
}
|
||||
|
||||
public static Vec3 entityVelocityToWorld(Vec3 velocity, boolean inverted) {
|
||||
if (!inverted) {
|
||||
return velocity;
|
||||
}
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(velocity, AntarchyGravityDirection.UP);
|
||||
return GravityRotationUtil.vecPlayerToWorld(velocity, GravityDirection.UP);
|
||||
}
|
||||
|
||||
public static Vec3 entityVelocityFromWorld(Entity entity, Vec3 velocity) {
|
||||
return entityVelocityFromWorld(velocity, AntarchyGravityApi.isGravityInverted(entity));
|
||||
return entityVelocityFromWorld(velocity, GravityApi.isGravityInverted(entity));
|
||||
}
|
||||
|
||||
public static Vec3 entityVelocityFromWorld(Vec3 velocity, boolean inverted) {
|
||||
if (!inverted) {
|
||||
return velocity;
|
||||
}
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(velocity, AntarchyGravityDirection.UP);
|
||||
return GravityRotationUtil.vecWorldToPlayer(velocity, GravityDirection.UP);
|
||||
}
|
||||
|
||||
public static Vec3 exitVelocity(PortalGunWorldPortalShape source, PortalGunWorldPortalShape destination, Vec3 velocity, double minUpwardExitSpeed, double maxExitSpeed) {
|
||||
@@ -122,7 +122,7 @@ public final class PortalGunTransitMath {
|
||||
}
|
||||
|
||||
public static float exitFallDistance(float fallDistance, Vec3 exitVelocity, Entity entity) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
if (!GravityApi.isGravityInverted(entity)) {
|
||||
return exitFallDistance(fallDistance, exitVelocity);
|
||||
}
|
||||
return exitVelocity.y > 0.0D ? fallDistance : 0.0F;
|
||||
|
||||
+25
-39
@@ -4,9 +4,9 @@ import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.advancement.AntarchyAdvancementTriggers;
|
||||
import com.craisinlord.antarchy.content.block.DreamSandBlock;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityTransition;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
@@ -23,7 +23,6 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -33,8 +32,8 @@ import net.minecraft.world.phys.Vec3;
|
||||
public final class ThoraxisUndersideManager {
|
||||
public static final int GRAVITY_FLIP_Y = 0;
|
||||
private static final net.minecraft.resources.ResourceLocation THORAXIS_DIMENSION = net.minecraft.resources.ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "thoraxis");
|
||||
private static final AntarchyGravityTransition TRANSITION = new AntarchyGravityTransition(12);
|
||||
private static final AntarchyGravityTransition THROAT_TRANSITION = new AntarchyGravityTransition(12);
|
||||
private static final GravityTransition TRANSITION = new GravityTransition(12);
|
||||
private static final GravityTransition THROAT_TRANSITION = new GravityTransition(12);
|
||||
private static final int EFFECT_DURATION_TICKS = 50;
|
||||
private static final int EFFECT_REFRESH_THRESHOLD_TICKS = 10;
|
||||
private static final int DISCOVERY_INTERVAL_TICKS = 5;
|
||||
@@ -115,8 +114,8 @@ public final class ThoraxisUndersideManager {
|
||||
boolean shouldInvert = tracked ? entity.getY() < EXIT_UNDERSIDE_Y : entity.getY() < ENTER_UNDERSIDE_Y;
|
||||
|
||||
if (shouldInvert) {
|
||||
boolean needsFlip = AntarchyGravityApi.getGravityDirection(entity) != AntarchyGravityDirection.UP
|
||||
|| !AntarchyGravityApi.isGravityForced(entity);
|
||||
boolean needsFlip = GravityApi.getGravityDirection(entity) != GravityDirection.UP
|
||||
|| !GravityApi.isGravityForced(entity);
|
||||
tracking.forcedItems.add(entity);
|
||||
if (needsFlip && (flipsRemaining <= 0 || !flipReady(tracking, uuid, now))) {
|
||||
continue;
|
||||
@@ -124,22 +123,22 @@ public final class ThoraxisUndersideManager {
|
||||
if (needsFlip) {
|
||||
flipsRemaining--;
|
||||
tracking.lastFlipTick.put(uuid, now);
|
||||
AntarchyGravityApi.setForcedGravityDirection(entity, AntarchyGravityDirection.UP, TRANSITION);
|
||||
GravityApi.setForcedGravityDirection(entity, GravityDirection.UP, TRANSITION);
|
||||
flippedItems++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tracked) {
|
||||
boolean isForcedUp = AntarchyGravityApi.getGravityDirection(entity) == AntarchyGravityDirection.UP
|
||||
&& AntarchyGravityApi.isGravityForced(entity);
|
||||
boolean isForcedUp = GravityApi.getGravityDirection(entity) == GravityDirection.UP
|
||||
&& GravityApi.isGravityForced(entity);
|
||||
if (isForcedUp && !flipReady(tracking, uuid, now)) {
|
||||
continue;
|
||||
}
|
||||
tracking.forcedItems.remove(entity);
|
||||
if (isForcedUp) {
|
||||
tracking.lastFlipTick.put(uuid, now);
|
||||
AntarchyGravityApi.setGravityDirection(entity, AntarchyGravityDirection.DOWN, false, TRANSITION);
|
||||
GravityApi.setGravityDirection(entity, GravityDirection.DOWN, false, TRANSITION);
|
||||
restoredItems++;
|
||||
}
|
||||
evicted.add(entity);
|
||||
@@ -217,7 +216,7 @@ public final class ThoraxisUndersideManager {
|
||||
}
|
||||
|
||||
if (isCrossingGravityBoundary(player)) {
|
||||
boolean toUnderside = AntarchyGravityApi.getGravityDirection(player) == AntarchyGravityDirection.DOWN;
|
||||
boolean toUnderside = GravityApi.getGravityDirection(player) == GravityDirection.DOWN;
|
||||
if (!toUnderside) {
|
||||
refreshInvertedEffect(player);
|
||||
} else {
|
||||
@@ -227,17 +226,17 @@ public final class ThoraxisUndersideManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AntarchyGravityApi.getGravityDirection(player) == AntarchyGravityDirection.DOWN
|
||||
if (GravityApi.getGravityDirection(player) == GravityDirection.DOWN
|
||||
&& player.getY() < UNDERSIDE_ENTRY_BORDER_Y
|
||||
&& flipReady(tracking, player.getUUID(), now)) {
|
||||
AntarchyGravityApi.setAirborneGravityDirection(player, AntarchyGravityDirection.UP, true, THROAT_TRANSITION);
|
||||
GravityApi.setAirborneGravityDirection(player, GravityDirection.UP, true, THROAT_TRANSITION);
|
||||
player.resetFallDistance();
|
||||
tracking.lastFlipTick.put(player.getUUID(), now);
|
||||
refreshInvertedEffect(player);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AntarchyGravityApi.isGravityInverted(player) && player.getY() < EXIT_UNDERSIDE_Y) {
|
||||
if (GravityApi.isGravityInverted(player) && player.getY() < EXIT_UNDERSIDE_Y) {
|
||||
refreshInvertedEffect(player);
|
||||
}
|
||||
}
|
||||
@@ -245,7 +244,7 @@ public final class ThoraxisUndersideManager {
|
||||
|
||||
private static void tickPlayerCrossing(ServerPlayer player, PlayerCrossing crossing, TrackingState tracking, long now) {
|
||||
crossing.ticks++;
|
||||
Vec3 velocity = AntarchyGravityApi.getWorldVelocity(player);
|
||||
Vec3 velocity = GravityApi.getWorldVelocity(player);
|
||||
if (!crossing.flipped) {
|
||||
if (!crossing.toUnderside) {
|
||||
refreshInvertedEffect(player);
|
||||
@@ -274,14 +273,14 @@ public final class ThoraxisUndersideManager {
|
||||
return;
|
||||
}
|
||||
|
||||
AntarchyGravityDirection destination = crossing.toUnderside
|
||||
? AntarchyGravityDirection.UP
|
||||
: AntarchyGravityDirection.DOWN;
|
||||
AntarchyGravityApi.setAirborneGravityDirection(player, destination, crossing.toUnderside, THROAT_TRANSITION);
|
||||
GravityDirection destination = crossing.toUnderside
|
||||
? GravityDirection.UP
|
||||
: GravityDirection.DOWN;
|
||||
GravityApi.setAirborneGravityDirection(player, destination, crossing.toUnderside, THROAT_TRANSITION);
|
||||
double assistedVerticalVelocity = crossing.toUnderside
|
||||
? Math.min(velocity.y, -0.7D)
|
||||
: Math.max(velocity.y, 0.7D);
|
||||
AntarchyGravityApi.setWorldVelocity(player,
|
||||
GravityApi.setWorldVelocity(player,
|
||||
new Vec3(velocity.x, assistedVerticalVelocity, velocity.z));
|
||||
player.resetFallDistance();
|
||||
crossing.flipped = true;
|
||||
@@ -306,10 +305,10 @@ public final class ThoraxisUndersideManager {
|
||||
}
|
||||
|
||||
private static boolean isCrossingGravityBoundary(ServerPlayer player) {
|
||||
Vec3 velocity = AntarchyGravityApi.getWorldVelocity(player);
|
||||
Vec3 velocity = GravityApi.getWorldVelocity(player);
|
||||
AABB swept = player.getBoundingBox().expandTowards(velocity.scale(-1.0D)).inflate(0.08D);
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(player);
|
||||
return direction == AntarchyGravityDirection.DOWN
|
||||
GravityDirection direction = GravityApi.getGravityDirection(player);
|
||||
return direction == GravityDirection.DOWN
|
||||
? swept.minY < UNDERSIDE_ENTRY_BORDER_Y && swept.maxY >= UNDERSIDE_ENTRY_BORDER_Y && velocity.y <= -MIN_ENTRY_CROSSING_SPEED
|
||||
: swept.minY <= GRAVITY_FLIP_Y && swept.maxY > GRAVITY_FLIP_Y && velocity.y >= MIN_CROSSING_SPEED;
|
||||
}
|
||||
@@ -376,25 +375,12 @@ public final class ThoraxisUndersideManager {
|
||||
return isThoraxis(entity.level()) && entity.getY() < GRAVITY_FLIP_Y;
|
||||
}
|
||||
|
||||
public static void normalizeProjectileGravityFrame(Projectile projectile) {
|
||||
boolean stateMismatch = AntarchyGravityApi.getGravityDirection(projectile) != AntarchyGravityDirection.DOWN
|
||||
|| AntarchyGravityApi.isGravityForced(projectile);
|
||||
if (stateMismatch) {
|
||||
AntarchyGravityApi.setAirborneGravityDirection(
|
||||
projectile,
|
||||
AntarchyGravityDirection.DOWN,
|
||||
false,
|
||||
AntarchyGravityTransition.INSTANT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAboveUndersideExit(Entity entity) {
|
||||
return isThoraxis(entity.level()) && entity.getY() >= EXIT_UNDERSIDE_Y;
|
||||
}
|
||||
|
||||
public static boolean shouldInvertInUnderside(Entity entity) {
|
||||
return AntarchyGravityApi.isGravityInverted(entity)
|
||||
return GravityApi.isGravityInverted(entity)
|
||||
&& isInUnderside(entity);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ final class AntarchyRangedAttackPatcher {
|
||||
private static final String LIVING_D_DESC = "(Lnet/minecraft/world/entity/LivingEntity;D)D";
|
||||
private static final String D_LIVING_DESC = "(DLnet/minecraft/world/entity/LivingEntity;)D";
|
||||
private static final String DELTA_MOVEMENT_DESC = "(Lnet/minecraft/world/entity/LivingEntity;)Lnet/minecraft/world/phys/Vec3;";
|
||||
private static final String API_OWNER = "com/craisinlord/antarchy/content/gravity/AntarchyGravityApi";
|
||||
private static final String API_OWNER = "com/craisinlord/anthology/gravity/GravityApi";
|
||||
|
||||
private enum AimMode {
|
||||
BODY,
|
||||
|
||||
+3
-3
@@ -2,8 +2,8 @@ package com.craisinlord.antarchy.mixins;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.block.DreamSandBlock;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.antarchy.content.movement.DreamSandLowGravityAccess;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
@@ -116,7 +116,7 @@ public abstract class DreamSandLowGravityMixin implements DreamSandLowGravityAcc
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$isSupportedByDreamSand(LivingEntity entity) {
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(entity);
|
||||
GravityDirection gravityDirection = GravityApi.getGravityDirection(entity);
|
||||
AABB box = entity.getBoundingBox();
|
||||
BlockPos supportPos = gravityDirection.isInverted()
|
||||
? BlockPos.containing(entity.getX(), box.maxY + 0.05D, entity.getZ())
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.alexscaves;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** Handles Alex's Caves' manually-launched Candy Cane Hook. */
|
||||
@Mixin(targets = "com.github.alexmodguy.alexscaves.server.entity.item.CandyCaneHookEntity")
|
||||
@Pseudo
|
||||
public abstract class AlexsCavesCandyCaneHookMixin {
|
||||
private boolean antarchy$launchAdjusted;
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void antarchy$rotateManualLaunch(CallbackInfo ci) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
if (this.antarchy$launchAdjusted) {
|
||||
return;
|
||||
}
|
||||
this.antarchy$launchAdjusted = true;
|
||||
|
||||
Entity owner = self.getOwner();
|
||||
boolean ownerInverted = owner != null && AntarchyGravityApi.isGravityInverted(owner);
|
||||
if (ownerInverted || ThoraxisUndersideManager.isInUnderside(self)) {
|
||||
AntarchyGravityDirection direction = ownerInverted
|
||||
? AntarchyGravityApi.getGravityDirection(owner)
|
||||
: AntarchyGravityDirection.UP;
|
||||
Vec3 launch = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
self.getDeltaMovement(), direction);
|
||||
self.setDeltaMovement(launch);
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyArg(
|
||||
method = "fling",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;"),
|
||||
index = 1
|
||||
)
|
||||
private double antarchy$invertFlingBoost(double y) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
Entity owner = self.getOwner();
|
||||
return y != 0.0D && (ThoraxisUndersideManager.isInUnderside(self)
|
||||
|| (owner != null && AntarchyGravityApi.isGravityInverted(owner))) ? -y : y;
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.alexscaves;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
/** Corrects Depth Charge's custom tick, which bypasses ThrowableProjectile.tick. */
|
||||
@Mixin(targets = "com.github.alexmodguy.alexscaves.server.entity.item.DepthChargeEntity")
|
||||
@Pseudo
|
||||
public abstract class AlexsCavesDepthChargeMixin {
|
||||
@ModifyArg(
|
||||
method = "tick",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;"),
|
||||
index = 1,
|
||||
require = 0
|
||||
)
|
||||
private double antarchy$invertManualGravity(double y) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
Entity owner = self.getOwner();
|
||||
return !self.isNoGravity() && (ThoraxisUndersideManager.isInUnderside(self)
|
||||
|| (owner != null && AntarchyGravityApi.isGravityInverted(owner))) ? -y : y;
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.alexscaves;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
/** Corrects Tephra's explicit -0.1 Y gravity adjustment. */
|
||||
@Mixin(targets = "com.github.alexmodguy.alexscaves.server.entity.item.TephraEntity")
|
||||
@Pseudo
|
||||
public abstract class AlexsCavesTephraMixin {
|
||||
@ModifyArg(
|
||||
method = "tick",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;", ordinal = 1),
|
||||
index = 1
|
||||
)
|
||||
private double antarchy$invertManualGravity(double y) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
Entity owner = self.getOwner();
|
||||
return !self.isNoGravity() && (ThoraxisUndersideManager.isInUnderside(self)
|
||||
|| (owner != null && AntarchyGravityApi.isGravityInverted(owner))) ? -y : y;
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.alexscaves;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
/** Corrects Water Bolt's explicit -0.07 Y gravity adjustment. */
|
||||
@Mixin(targets = "com.github.alexmodguy.alexscaves.server.entity.item.WaterBoltEntity")
|
||||
@Pseudo
|
||||
public abstract class AlexsCavesWaterBoltMixin {
|
||||
@ModifyArg(
|
||||
method = "tick",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;", ordinal = 1),
|
||||
index = 1
|
||||
)
|
||||
private double antarchy$invertManualGravity(double y) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
Entity owner = self.getOwner();
|
||||
return !self.isNoGravity() && (ThoraxisUndersideManager.isInUnderside(self)
|
||||
|| (owner != null && AntarchyGravityApi.isGravityInverted(owner))) ? -y : y;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.ars_nouveau;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** Handles Ars Nouveau's explicit tickNextPosition gravity adjustment. */
|
||||
@Mixin(targets = "com.hollingsworth.arsnouveau.common.entity.EntityProjectileSpell")
|
||||
@Pseudo
|
||||
public abstract class ArsNouveauProjectileGravityMixin {
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void antarchy$prepareArsProjectile(CallbackInfo ci) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
Entity owner = self.getOwner();
|
||||
if (owner != null && (ThoraxisUndersideManager.isInUnderside(self)
|
||||
|| AntarchyGravityApi.isGravityInverted(owner))) {
|
||||
AntarchyGravityApi.setAirborneGravityDirection(
|
||||
self,
|
||||
AntarchyGravityDirection.UP,
|
||||
false,
|
||||
AntarchyGravityTransition.INSTANT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickNextPosition", at = @At("TAIL"))
|
||||
private void antarchy$invertArsProjectileGravity(CallbackInfo ci) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(self) || self.isNoGravity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ars applies -0.03 directly in tickNextPosition(). Correct that one
|
||||
// application to +0.03 without changing damping or spell effects.
|
||||
self.setDeltaMovement(self.getDeltaMovement().add(0.0D, 0.06D, 0.0D));
|
||||
}
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.irons_spellbooks;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
/** Handles Iron's Spellbooks' custom travel() gravity path. */
|
||||
@Mixin(targets = "io.redspace.ironsspellbooks.entity.spells.AbstractMagicProjectile")
|
||||
@Pseudo
|
||||
public abstract class IronsSpellbooksProjectileGravityMixin {
|
||||
@Shadow public abstract float getSpeed();
|
||||
@Shadow protected abstract double getDefaultGravity();
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void antarchy$prepareMagicProjectile(CallbackInfo ci) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
Entity owner = self.getOwner();
|
||||
boolean inverted = ThoraxisUndersideManager.isInUnderside(self)
|
||||
|| (owner != null && AntarchyGravityApi.isGravityInverted(owner));
|
||||
if (!inverted) {
|
||||
return;
|
||||
}
|
||||
AntarchyGravityApi.setAirborneGravityDirection(
|
||||
self,
|
||||
AntarchyGravityDirection.UP,
|
||||
false,
|
||||
AntarchyGravityTransition.INSTANT
|
||||
);
|
||||
}
|
||||
|
||||
@Inject(method = "shoot", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$rotateMagicProjectileLaunch(Vec3 rotation, CallbackInfo ci) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
Entity owner = self.getOwner();
|
||||
if (owner == null || (!ThoraxisUndersideManager.isInUnderside(self)
|
||||
&& !AntarchyGravityApi.isGravityInverted(owner))) {
|
||||
return;
|
||||
}
|
||||
self.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
rotation,
|
||||
AntarchyGravityApi.getGravityDirection(owner)
|
||||
).scale(this.getSpeed()));
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "travel", at = @At("TAIL"))
|
||||
private void antarchy$invertMagicProjectileGravity(CallbackInfo ci) {
|
||||
Projectile self = (Projectile) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(self) || self.isNoGravity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// AbstractMagicProjectile.travel() already subtracted default gravity.
|
||||
self.setDeltaMovement(self.getDeltaMovement().add(0.0D, 2.0D * this.getDefaultGravity(), 0.0D));
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.scguns;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** Corrects Scorched Guns arrow-derived projectiles with custom tick gravity. */
|
||||
@Mixin(targets = "top.ribs.scguns.entity.projectile.BrassBoltEntity")
|
||||
@Pseudo
|
||||
public abstract class ScgunsArrowGravityMixin {
|
||||
@Inject(method = "tick", at = @At("TAIL"))
|
||||
private void antarchy$invertScgunsArrowGravity(CallbackInfo ci) {
|
||||
AbstractArrow self = (AbstractArrow) (Object) this;
|
||||
if (self.isNoGravity() || (!AntarchyGravityApi.isGravityInverted(self)
|
||||
&& !ThoraxisUndersideManager.isInUnderside(self))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Brass Bolt adds +0.01 after AbstractArrow.tick(); invert that custom
|
||||
// correction to -0.01, without touching normal arrows.
|
||||
self.setDeltaMovement(self.getDeltaMovement().add(0.0D, -0.02D, 0.0D));
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.scguns;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.ScgunsProjectileAccess;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
/*
|
||||
* Shadows must live on the class that declares the field, so the subclasses
|
||||
* reach these through ScgunsProjectileAccess instead.
|
||||
*/
|
||||
@Mixin(targets = "top.ribs.scguns.entity.projectile.ProjectileEntity")
|
||||
@Pseudo
|
||||
public abstract class ScgunsProjectileEntityAccessMixin implements ScgunsProjectileAccess {
|
||||
@Shadow(remap = false) @Nullable protected LivingEntity shooter;
|
||||
@Shadow(remap = false) protected double modifiedGravity;
|
||||
|
||||
@Override
|
||||
public @Nullable LivingEntity antarchy$getScgunsShooter() {
|
||||
return this.shooter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double antarchy$getScgunsModifiedGravity() {
|
||||
return this.modifiedGravity;
|
||||
}
|
||||
}
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.compat.scguns;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.antarchy.content.gravity.ScgunsProjectileAccess;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** Bridges Scorched Guns' Entity-based projectile physics into Antarchy gravity. */
|
||||
@Mixin(targets = {
|
||||
"top.ribs.scguns.entity.projectile.ProjectileEntity",
|
||||
"top.ribs.scguns.entity.projectile.BearPackShellProjectileEntity",
|
||||
"top.ribs.scguns.entity.projectile.KrahgRoundProjectileEntity",
|
||||
"top.ribs.scguns.entity.projectile.LightningProjectileEntity",
|
||||
"top.ribs.scguns.entity.projectile.OsborneSlugProjectileEntity",
|
||||
"top.ribs.scguns.entity.projectile.ShotballProjectileEntity"
|
||||
})
|
||||
@Pseudo
|
||||
public abstract class ScgunsProjectileEntityGravityMixin {
|
||||
@Unique private boolean antarchy$launchDirectionAdjusted;
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void antarchy$prepareScgunsProjectile(CallbackInfo ci) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
LivingEntity shooter = ((ScgunsProjectileAccess) self).antarchy$getScgunsShooter();
|
||||
boolean inverted = ThoraxisUndersideManager.isInUnderside(self)
|
||||
|| (shooter != null && AntarchyGravityApi.isGravityInverted(shooter));
|
||||
if (!inverted) {
|
||||
if (AntarchyGravityApi.isGravityInverted(self) && !AntarchyGravityApi.isGravityForced(self)) {
|
||||
AntarchyGravityApi.setAirborneGravityDirection(
|
||||
self,
|
||||
AntarchyGravityDirection.DOWN,
|
||||
false,
|
||||
AntarchyGravityTransition.INSTANT
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AntarchyGravityApi.setAirborneGravityDirection(
|
||||
self,
|
||||
AntarchyGravityDirection.UP,
|
||||
false,
|
||||
AntarchyGravityTransition.INSTANT
|
||||
);
|
||||
if (!this.antarchy$launchDirectionAdjusted && self.tickCount <= 1) {
|
||||
Vec3 motion = self.getDeltaMovement();
|
||||
if (motion.lengthSqr() > 1.0E-8D) {
|
||||
self.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
motion,
|
||||
AntarchyGravityDirection.UP
|
||||
));
|
||||
}
|
||||
this.antarchy$launchDirectionAdjusted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("TAIL"))
|
||||
private void antarchy$invertScgunsGravity(CallbackInfo ci) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
double modifiedGravity = ((ScgunsProjectileAccess) self).antarchy$getScgunsModifiedGravity();
|
||||
if (!AntarchyGravityApi.isGravityInverted(self) || modifiedGravity == 0.0D) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Scorched Guns already adds modifiedGravity once near tick end. Replace
|
||||
// that downward world-Y acceleration with its upward counterpart.
|
||||
self.setDeltaMovement(self.getDeltaMovement().add(0.0D, -2.0D * modifiedGravity, 0.0D));
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(AbstractArrow.class)
|
||||
/*
|
||||
* Flips arrow gravity from the arrow's current position.
|
||||
*/
|
||||
public abstract class AbstractArrowGravityMixin {
|
||||
|
||||
@WrapOperation(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/projectile/AbstractArrow;applyGravity()V"))
|
||||
private void antarchy$applyArrowGravityUpward(AbstractArrow self, Operation<Void> original) {
|
||||
if (!ThoraxisUndersideManager.isInUnderside(self)) {
|
||||
original.call(self);
|
||||
return;
|
||||
}
|
||||
// Vanilla subtracts gravity from world Y; the Underside adds it instead.
|
||||
double gravity = self.getGravity();
|
||||
self.setDeltaMovement(self.getDeltaMovement().add(0.0D, gravity, 0.0D));
|
||||
}
|
||||
}
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.behavior.BehaviorUtils;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(BehaviorUtils.class)
|
||||
public abstract class BehaviorUtilsGravityMixin {
|
||||
@WrapOperation(
|
||||
method = "throwItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;F)V",
|
||||
at = @At(
|
||||
value = "NEW",
|
||||
target = "(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;"
|
||||
)
|
||||
)
|
||||
private static ItemEntity antarchy$fixThrownItemSpawn(
|
||||
Level level,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
ItemStack stack,
|
||||
Operation<ItemEntity> original,
|
||||
@Local float yOffset,
|
||||
@Local LivingEntity entity
|
||||
) {
|
||||
if (!antarchy$shouldInvertThrownItem(entity)) {
|
||||
return original.call(level, x, y, z, stack);
|
||||
}
|
||||
|
||||
Vec3 eyeOffset = AntarchyGravityRotationUtil.getEyeOffset(entity, entity.getEyeHeight());
|
||||
Vec3 offset = eyeOffset.normalize().scale(yOffset);
|
||||
Vec3 itemPos = entity.position().add(eyeOffset).subtract(offset);
|
||||
ItemEntity itemEntity = original.call(level, itemPos.x(), itemPos.y(), itemPos.z(), stack);
|
||||
AntarchyGravityApi.setGravityDirection(itemEntity, AntarchyGravityApi.getGravityDirection(entity));
|
||||
return itemEntity;
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
method = "throwItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;F)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/item/ItemEntity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"
|
||||
)
|
||||
)
|
||||
private static void antarchy$fixThrownItemVelocity(
|
||||
ItemEntity itemEntity,
|
||||
Vec3 deltaMovement,
|
||||
Operation<Void> original,
|
||||
@Local LivingEntity entity
|
||||
) {
|
||||
if (!antarchy$shouldInvertThrownItem(entity)) {
|
||||
original.call(itemEntity, deltaMovement);
|
||||
return;
|
||||
}
|
||||
|
||||
AntarchyGravityApi.setWorldVelocity(itemEntity, deltaMovement);
|
||||
}
|
||||
|
||||
private static boolean antarchy$shouldInvertThrownItem(LivingEntity entity) {
|
||||
return ThoraxisUndersideManager.shouldInvertInUnderside(entity);
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BubbleColumnBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(BubbleColumnBlock.class)
|
||||
public abstract class BubbleColumnGravityMixin {
|
||||
@Inject(method = "entityInside", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$applyBubbleForces(BlockState state, Level level, BlockPos pos, Entity entity, CallbackInfo ci) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean drag = state.getValue(BubbleColumnBlock.DRAG_DOWN);
|
||||
Vec3 velocity = AntarchyGravityApi.getWorldVelocity(entity);
|
||||
double vertical = drag ? Math.max(-0.9D, velocity.y - 0.03D) : Math.min(1.8D, velocity.y + 0.1D);
|
||||
AntarchyGravityApi.setWorldVelocity(entity, new Vec3(velocity.x, vertical, velocity.z));
|
||||
entity.onAboveBubbleCol(!drag);
|
||||
if (drag) {
|
||||
entity.resetFallDistance();
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemUtils;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BucketItem.class)
|
||||
public abstract class BucketItemGravityMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private Fluid content;
|
||||
|
||||
@Shadow
|
||||
public abstract boolean emptyContents(Player player, Level level, BlockPos pos, BlockHitResult hitResult);
|
||||
|
||||
@Shadow
|
||||
public abstract void checkExtraContent(Player player, Level level, ItemStack stack, BlockPos pos);
|
||||
|
||||
@Inject(method = "use", at = @At("RETURN"), cancellable = true)
|
||||
private void antarchy$allowInvertedFluidPlacement(Level level, Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir) {
|
||||
InteractionResultHolder<ItemStack> result = cir.getReturnValue();
|
||||
if (result.getResult().consumesAction() || this.content == Fluids.EMPTY || !AntarchyGravityApi.isGravityInverted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
HitResult hitResult = player.pick(player.blockInteractionRange(), 1.0F, false);
|
||||
if (!(hitResult instanceof BlockHitResult blockHitResult) || hitResult.getType() != HitResult.Type.BLOCK) {
|
||||
return;
|
||||
}
|
||||
|
||||
Direction face = blockHitResult.getDirection();
|
||||
BlockPos clickedPos = blockHitResult.getBlockPos();
|
||||
BlockState clickedState = level.getBlockState(clickedPos);
|
||||
Block clickedBlock = clickedState.getBlock();
|
||||
BlockPos normalTargetPos = clickedBlock instanceof LiquidBlockContainer && this.content == Fluids.WATER
|
||||
? clickedPos
|
||||
: clickedPos.relative(face);
|
||||
BlockPos invertedTargetPos = clickedPos.relative(face.getOpposite());
|
||||
if (invertedTargetPos.equals(normalTargetPos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!level.mayInteract(player, clickedPos) || !player.mayUseItemAt(invertedTargetPos, face.getOpposite(), stack)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.emptyContents(player, level, invertedTargetPos, null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.checkExtraContent(player, level, stack, invertedTargetPos);
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
CriteriaTriggers.PLACED_BLOCK.trigger(serverPlayer, invertedTargetPos, stack);
|
||||
}
|
||||
player.awardStat(Stats.ITEM_USED.get((BucketItem) (Object) this));
|
||||
ItemStack successStack = ItemUtils.createFilledResult(stack, player, BucketItem.getEmptySuccessItem(stack, player));
|
||||
cir.setReturnValue(InteractionResultHolder.sidedSuccess(successStack, level.isClientSide()));
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.CrossbowItem;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(CrossbowItem.class)
|
||||
/*
|
||||
* Spawns crossbow shots with gravity-aware aim.
|
||||
*/
|
||||
public abstract class CrossbowItemGravityMixin {
|
||||
|
||||
private static final double BOLT_OFFSET = 0.15000000596046448D;
|
||||
|
||||
@WrapOperation(method = "createProjectile",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;getX()D", ordinal = 0))
|
||||
private static double antarchy$fixCrossbowSpawnX(LivingEntity shooter, Operation<Double> original) {
|
||||
if (!antarchy$shouldFixProjectileSpawn(shooter)) return original.call(shooter);
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(shooter);
|
||||
if (!direction.isInverted()) return original.call(shooter);
|
||||
Vec3 offset = AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, BOLT_OFFSET, 0.0D, direction);
|
||||
return shooter.getEyePosition().subtract(offset).x;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "createProjectile",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;getEyeY()D", ordinal = 0))
|
||||
private static double antarchy$fixCrossbowSpawnY(LivingEntity shooter, Operation<Double> original) {
|
||||
if (!antarchy$shouldFixProjectileSpawn(shooter)) return original.call(shooter);
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(shooter);
|
||||
if (!direction.isInverted()) return original.call(shooter);
|
||||
Vec3 offset = AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, BOLT_OFFSET, 0.0D, direction);
|
||||
return shooter.getEyePosition().subtract(offset).y + BOLT_OFFSET;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "createProjectile",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;getZ()D", ordinal = 0))
|
||||
private static double antarchy$fixCrossbowSpawnZ(LivingEntity shooter, Operation<Double> original) {
|
||||
if (!antarchy$shouldFixProjectileSpawn(shooter)) return original.call(shooter);
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(shooter);
|
||||
if (!direction.isInverted()) return original.call(shooter);
|
||||
Vec3 offset = AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, BOLT_OFFSET, 0.0D, direction);
|
||||
return shooter.getEyePosition().subtract(offset).z;
|
||||
}
|
||||
|
||||
private static boolean antarchy$shouldFixProjectileSpawn(LivingEntity shooter) {
|
||||
return ThoraxisUndersideManager.shouldInvertInUnderside(shooter);
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
@Mixin(Direction.class)
|
||||
/*
|
||||
* Fixes facing math that assumes gravity is always down.
|
||||
*/
|
||||
public abstract class DirectionFacingMixin {
|
||||
|
||||
|
||||
@Inject(method = "orderedByNearest", at = @At("HEAD"), cancellable = true)
|
||||
private static void antarchy$fixEntityFacingOrder(Entity entity, CallbackInfoReturnable<Direction[]> cir) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
Vec3 look = entity.getViewVector(1.0F);
|
||||
|
||||
Direction[] sorted = Direction.values();
|
||||
Arrays.sort(sorted, Comparator.comparingDouble(
|
||||
(Direction d) -> d.getStepX() * look.x + d.getStepY() * look.y + d.getStepZ() * look.z
|
||||
).reversed());
|
||||
|
||||
cir.setReturnValue(sorted);
|
||||
}
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EntityCollisionContext.class)
|
||||
/*
|
||||
* Uses gravity-aware entity bounds for block collision checks.
|
||||
*/
|
||||
public abstract class EntityCollisionContextMixin {
|
||||
|
||||
@Shadow @Final private double entityBottom;
|
||||
@Shadow @Final @Nullable private Entity entity;
|
||||
|
||||
@Redirect(
|
||||
method = "<init>(Lnet/minecraft/world/entity/Entity;)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getY()D")
|
||||
)
|
||||
private static double antarchy$fixCollisionContextBottom(Entity entity) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return entity.getY();
|
||||
}
|
||||
|
||||
return AntarchyGravityRotationUtil.boxWorldToPlayer(entity.getBoundingBox(), direction).minY;
|
||||
}
|
||||
|
||||
@Inject(method = "isAbove", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixIsAbove(VoxelShape shape, BlockPos pos, boolean canAscend, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (this.entity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shape.isEmpty()) {
|
||||
cir.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this.entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double baseMinY = AntarchyGravityRotationUtil.boxWorldToPlayer(new AABB(pos), direction).minY;
|
||||
double shapeMaxY = AntarchyGravityRotationUtil.boxWorldToPlayer(
|
||||
shape.bounds().inflate(-1.0E-5D),
|
||||
direction
|
||||
).maxY;
|
||||
cir.setReturnValue(this.entityBottom > baseMinY + shapeMaxY);
|
||||
}
|
||||
}
|
||||
-270
@@ -1,270 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.BlockParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
/*
|
||||
* Rotates entity frame math into local gravity space.
|
||||
*/
|
||||
public abstract class EntityGravityFrameMixin {
|
||||
|
||||
@Shadow protected abstract void onBelowWorld();
|
||||
|
||||
@Inject(method = "makeBoundingBox", at = @At("RETURN"), cancellable = true)
|
||||
private void antarchy$rotateBoundingBox(CallbackInfoReturnable<AABB> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
Vec3 origin = entity.position();
|
||||
AABB localBox = cir.getReturnValue().move(origin.scale(-1.0D));
|
||||
localBox = localBox.move(0.0D, -1.0E-6D, 0.0D);
|
||||
cir.setReturnValue(AntarchyGravityRotationUtil.boxPlayerToWorld(localBox, direction).move(origin));
|
||||
}
|
||||
|
||||
@Inject(method = "getEyeY", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixEyeY(CallbackInfoReturnable<Double> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(entity.position().add(AntarchyGravityRotationUtil.getEyeOffset(entity, entity.getEyeHeight())).y);
|
||||
}
|
||||
|
||||
@Inject(method = "getY(D)D", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixScaledY(double scale, CallbackInfoReturnable<Double> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(entity.position().add(
|
||||
AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, entity.getBbHeight() * scale, 0.0D, direction)
|
||||
).y);
|
||||
}
|
||||
|
||||
@Inject(method = "getEyePosition()Lnet/minecraft/world/phys/Vec3;", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixEyePosition(CallbackInfoReturnable<Vec3> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(entity.position().add(AntarchyGravityRotationUtil.getEyeOffset(entity, entity.getEyeHeight())));
|
||||
}
|
||||
|
||||
@Inject(method = "getEyePosition(F)Lnet/minecraft/world/phys/Vec3;", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixEyePositionInterpolated(float partialTick, CallbackInfoReturnable<Vec3> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
float flipProgress = AntarchyGravityApi.getGravityFlipProgress(entity, partialTick);
|
||||
if (flipProgress <= 0.0F) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(entity.getPosition(partialTick).add(
|
||||
AntarchyGravityRotationUtil.getEyeOffset(entity, entity.getEyeHeight(), partialTick)
|
||||
));
|
||||
}
|
||||
|
||||
@Inject(method = "getViewVector", at = @At("RETURN"), cancellable = true)
|
||||
private void antarchy$rotateViewVector(float partialTick, CallbackInfoReturnable<Vec3> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(AntarchyGravityRotationUtil.vecPlayerToWorld(cir.getReturnValue(), direction));
|
||||
}
|
||||
|
||||
@Inject(method = "getUpVector", at = @At("RETURN"), cancellable = true)
|
||||
private void antarchy$rotateUpVector(float partialTick, CallbackInfoReturnable<Vec3> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(AntarchyGravityRotationUtil.vecPlayerToWorld(cir.getReturnValue(), direction));
|
||||
}
|
||||
|
||||
@Inject(method = "getForward", at = @At("RETURN"), cancellable = true)
|
||||
private void antarchy$rotateForwardVector(CallbackInfoReturnable<Vec3> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(AntarchyGravityRotationUtil.vecPlayerToWorld(cir.getReturnValue(), direction));
|
||||
}
|
||||
|
||||
@Inject(method = "getOnPos(F)Lnet/minecraft/core/BlockPos;", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixSupportingBlockPos(float offset, CallbackInfoReturnable<BlockPos> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(AntarchyGravityRotationUtil.getSupportingBlockPos(entity, offset));
|
||||
}
|
||||
|
||||
@Inject(method = "getBlockPosBelowThatAffectsMyMovement",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixVelocityAffectingPos(CallbackInfoReturnable<BlockPos> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(BlockPos.containing(entity.position().add(0.0D, 0.5000001D, 0.0D)));
|
||||
}
|
||||
|
||||
@Inject(method = "getOnPosLegacy", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixLandingPos(CallbackInfoReturnable<BlockPos> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(BlockPos.containing(entity.position().add(0.0D, 0.20000000298023224D, 0.0D)));
|
||||
}
|
||||
|
||||
@WrapOperation(method = "isInWall",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/phys/AABB;ofSize(Lnet/minecraft/world/phys/Vec3;DDD)Lnet/minecraft/world/phys/AABB;",
|
||||
ordinal = 0))
|
||||
private AABB antarchy$fixIsInWallAABB(Vec3 center, double x, double y, double z, Operation<AABB> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) {
|
||||
return original.call(center, x, y, z);
|
||||
}
|
||||
Vec3 rotated = AntarchyGravityRotationUtil.vecPlayerToWorld(new Vec3(x, y, z), direction);
|
||||
return original.call(center, rotated.x, rotated.y, rotated.z);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "isFree(DDD)Z",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/phys/AABB;move(DDD)Lnet/minecraft/world/phys/AABB;",
|
||||
ordinal = 0))
|
||||
private AABB antarchy$fixIsFreeMoveAABB(AABB instance, double x, double y, double z, Operation<AABB> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) {
|
||||
return original.call(instance, x, y, z);
|
||||
}
|
||||
Vec3 worldOffset = AntarchyGravityRotationUtil.vecPlayerToWorld(new Vec3(x, y, z), direction);
|
||||
return original.call(instance, worldOffset.x, worldOffset.y, worldOffset.z);
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "updateFluidOnEyes", at = @At(value = "STORE"), ordinal = 0)
|
||||
private double antarchy$fixFluidEyeY(double eyeY) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return eyeY;
|
||||
}
|
||||
return entity.getEyePosition().y();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "updateFluidOnEyes", at = @At(value = "STORE"), ordinal = 0)
|
||||
private BlockPos antarchy$fixFluidEyeBlockPos(BlockPos pos) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return pos;
|
||||
}
|
||||
return BlockPos.containing(entity.getEyePosition());
|
||||
}
|
||||
|
||||
@Inject(method = "spawnSprintParticle", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixSprintParticle(CallbackInfo ci) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
ci.cancel();
|
||||
Vec3 ceilPos = entity.position().add(0.0D, 0.20000000298023224D, 0.0D);
|
||||
BlockPos blockPos = BlockPos.containing(ceilPos);
|
||||
var blockState = entity.level().getBlockState(blockPos);
|
||||
if (blockState.getRenderShape() != RenderShape.INVISIBLE) {
|
||||
double w = entity.getBbWidth();
|
||||
Vec3 particlePos = entity.position().add(
|
||||
(entity.getRandom().nextDouble() - 0.5D) * w,
|
||||
0.1D,
|
||||
(entity.getRandom().nextDouble() - 0.5D) * w
|
||||
);
|
||||
Vec3 dm = entity.getDeltaMovement();
|
||||
Vec3 particleVel = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
new Vec3(dm.x * -4.0D, -1.5D, dm.z * -4.0D),
|
||||
direction
|
||||
);
|
||||
entity.level().addParticle(
|
||||
new BlockParticleOption(ParticleTypes.BLOCK, blockState),
|
||||
particlePos.x, particlePos.y, particlePos.z,
|
||||
particleVel.x, particleVel.y, particleVel.z
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "checkBelowWorld", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$checkAboveWorldForInverted(CallbackInfo ci) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
if (entity.getY() > entity.level().getMaxBuildHeight() + 256) {
|
||||
this.onBelowWorld();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "push(Lnet/minecraft/world/entity/Entity;)V",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixEntityPush(Entity other, CallbackInfo ci) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
boolean selfInverted = AntarchyGravityApi.isGravityInverted(self);
|
||||
boolean otherInverted = AntarchyGravityApi.isGravityInverted(other);
|
||||
if (selfInverted == otherInverted) {
|
||||
return;
|
||||
}
|
||||
ci.cancel();
|
||||
if (self.isPassengerOfSameVehicle(other)) {
|
||||
return;
|
||||
}
|
||||
if (other.noPhysics || self.noPhysics) {
|
||||
return;
|
||||
}
|
||||
Vec3 worldOffset = other.getBoundingBox().getCenter().subtract(self.getBoundingBox().getCenter());
|
||||
AntarchyGravityDirection selfDir = AntarchyGravityApi.getGravityDirection(self);
|
||||
Vec3 localOffset = AntarchyGravityRotationUtil.vecWorldToPlayer(worldOffset, selfDir);
|
||||
double dx = localOffset.x;
|
||||
double dz = localOffset.z;
|
||||
double dist = Mth.absMax(dx, dz);
|
||||
if (dist >= 0.009999999776482582D) {
|
||||
dist = Math.sqrt(dist);
|
||||
dx /= dist;
|
||||
dz /= dist;
|
||||
double scale = Math.min(1.0D / dist, 1.0D) * 0.05D;
|
||||
dx *= scale;
|
||||
dz *= scale;
|
||||
if (!self.isVehicle()) {
|
||||
self.push(AntarchyGravityRotationUtil.vecPlayerToWorld(new Vec3(-dx, 0.0D, -dz), selfDir));
|
||||
}
|
||||
if (!other.isVehicle()) {
|
||||
AntarchyGravityDirection otherDir = AntarchyGravityApi.getGravityDirection(other);
|
||||
other.push(AntarchyGravityRotationUtil.vecPlayerToWorld(new Vec3(dx, 0.0D, dz), otherDir));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-320
@@ -1,320 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityAccess;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.antarchy.content.entity.BedBugEntity;
|
||||
import com.craisinlord.antarchy.content.entity.portal.DimensionalTearEntity;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
/*
|
||||
* Adds the base gravity state and sync hooks to entities.
|
||||
*/
|
||||
public abstract class EntityGravityMixin implements AntarchyGravityAccess {
|
||||
@Unique
|
||||
private static final String ANTARCHY_GRAVITY_DIRECTION_TAG = "AntarchyGravityDirection";
|
||||
@Unique
|
||||
private static final String ANTARCHY_PREV_GRAVITY_DIRECTION_TAG = "AntarchyPrevGravityDirection";
|
||||
@Unique
|
||||
private static final String ANTARCHY_GRAVITY_FORCED_TAG = "AntarchyGravityForced";
|
||||
@Unique
|
||||
private static final String ANTARCHY_GRAVITY_TRANSITION_DURATION_TAG = "AntarchyGravityTransitionDuration";
|
||||
@Unique
|
||||
private static final String ANTARCHY_GRAVITY_TRANSITION_REMAINING_TAG = "AntarchyGravityTransitionRemaining";
|
||||
|
||||
@Unique
|
||||
private AntarchyGravityDirection antarchy$gravityDirection = AntarchyGravityDirection.DOWN;
|
||||
@Unique
|
||||
private AntarchyGravityDirection antarchy$prevGravityDirection = AntarchyGravityDirection.DOWN;
|
||||
@Unique
|
||||
private boolean antarchy$gravityForced;
|
||||
@Unique
|
||||
private int antarchy$gravityTransitionDuration;
|
||||
@Unique
|
||||
private int antarchy$gravityTransitionRemaining;
|
||||
|
||||
@Shadow
|
||||
protected abstract AABB makeBoundingBox();
|
||||
|
||||
@Shadow
|
||||
public abstract void setBoundingBox(AABB boundingBox);
|
||||
|
||||
@Inject(method = "saveWithoutId", at = @At("TAIL"))
|
||||
private void antarchy$saveGravityState(CompoundTag tag, CallbackInfoReturnable<CompoundTag> cir) {
|
||||
tag.putString(ANTARCHY_GRAVITY_DIRECTION_TAG, this.antarchy$gravityDirection.getSerializedName());
|
||||
tag.putString(ANTARCHY_PREV_GRAVITY_DIRECTION_TAG, this.antarchy$prevGravityDirection.getSerializedName());
|
||||
tag.putBoolean(ANTARCHY_GRAVITY_FORCED_TAG, this.antarchy$gravityForced);
|
||||
tag.putInt(ANTARCHY_GRAVITY_TRANSITION_DURATION_TAG, this.antarchy$gravityTransitionDuration);
|
||||
tag.putInt(ANTARCHY_GRAVITY_TRANSITION_REMAINING_TAG, this.antarchy$gravityTransitionRemaining);
|
||||
}
|
||||
|
||||
@Inject(method = "load", at = @At("TAIL"))
|
||||
private void antarchy$readGravityState(CompoundTag tag, CallbackInfo ci) {
|
||||
this.antarchy$gravityDirection = AntarchyGravityDirection.parse(tag.getString(ANTARCHY_GRAVITY_DIRECTION_TAG))
|
||||
.orElse(AntarchyGravityDirection.DOWN);
|
||||
this.antarchy$prevGravityDirection = AntarchyGravityDirection.parse(tag.getString(ANTARCHY_PREV_GRAVITY_DIRECTION_TAG))
|
||||
.orElse(this.antarchy$gravityDirection);
|
||||
this.antarchy$gravityForced = tag.getBoolean(ANTARCHY_GRAVITY_FORCED_TAG);
|
||||
this.antarchy$gravityTransitionDuration = Math.max(0, tag.getInt(ANTARCHY_GRAVITY_TRANSITION_DURATION_TAG));
|
||||
this.antarchy$gravityTransitionRemaining = Math.max(0, tag.getInt(ANTARCHY_GRAVITY_TRANSITION_REMAINING_TAG));
|
||||
|
||||
Entity entity = this.antarchy$entity();
|
||||
if (this.antarchy$gravityDirection.isInverted() && this.antarchy$gravityForced
|
||||
&& entity instanceof Mob mob) {
|
||||
MobEffectInstance invertedEffect = mob.getEffect(com.craisinlord.antarchy.content.AntarchyObjects.INVERTED_EFFECT.get());
|
||||
boolean aboveUndersideExit = ThoraxisUndersideManager.isAboveUndersideExit(mob);
|
||||
int nearbyDimensionalTears = this.antarchy$countNearbyDimensionalTears(mob);
|
||||
if (invertedEffect != null
|
||||
&& invertedEffect.isAmbient()
|
||||
&& !invertedEffect.isVisible()
|
||||
&& aboveUndersideExit) {
|
||||
this.antarchy$clearLoadedInversion(mob);
|
||||
com.craisinlord.antarchy.Antarchy.LOGGER.warn(
|
||||
"[antarchy-gravity] cleared stale underside inversion from loaded mob type={} uuid={} pos=({}, {}, {}) dim={} effectDuration={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect.getDuration(), nearbyDimensionalTears
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (invertedEffect != null
|
||||
&& mob instanceof BedBugEntity
|
||||
&& aboveUndersideExit
|
||||
&& ThoraxisUndersideManager.isThoraxis(mob.level())) {
|
||||
this.antarchy$clearLoadedInversion(mob);
|
||||
com.craisinlord.antarchy.Antarchy.LOGGER.warn(
|
||||
"[antarchy-gravity] cleared loaded inverted bed bug above underside exit type={} uuid={} pos=({}, {}, {}) dim={} effectDuration={} effectAmbient={} effectVisible={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect.getDuration(), invertedEffect.isAmbient(), invertedEffect.isVisible(), nearbyDimensionalTears
|
||||
);
|
||||
return;
|
||||
}
|
||||
com.craisinlord.antarchy.Antarchy.LOGGER.info(
|
||||
"[antarchy-gravity] loaded inverted mob type={} uuid={} pos=({}, {}, {}) dim={} hasInvertedEffect={} effectDuration={} effectAmbient={} effectVisible={} aboveUndersideExit={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect != null,
|
||||
invertedEffect != null ? invertedEffect.getDuration() : -1,
|
||||
invertedEffect != null && invertedEffect.isAmbient(),
|
||||
invertedEffect != null && invertedEffect.isVisible(),
|
||||
aboveUndersideExit,
|
||||
nearbyDimensionalTears
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "baseTick", at = @At("TAIL"))
|
||||
private void antarchy$tickGravityTransition(CallbackInfo ci) {
|
||||
if (this.antarchy$gravityTransitionRemaining > 0) {
|
||||
this.antarchy$gravityTransitionRemaining--;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "updateInWaterStateAndDoFluidPushing", at = @At("TAIL"))
|
||||
private void antarchy$resetFallDistanceInAntiwater(CallbackInfoReturnable<Boolean> cir) {
|
||||
Entity entity = this.antarchy$entity();
|
||||
AntarchyGravityDirection direction = this.antarchy$gravityDirection;
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!antarchy$isTouchingAntiwater(entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
entity.resetFallDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AntarchyGravityDirection antarchy$getGravityDirection() {
|
||||
return this.antarchy$gravityDirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AntarchyGravityDirection antarchy$getPrevGravityDirection() {
|
||||
return this.antarchy$prevGravityDirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean antarchy$isGravityForced() {
|
||||
return this.antarchy$gravityForced;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int antarchy$getGravityTransitionDuration() {
|
||||
return this.antarchy$gravityTransitionDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int antarchy$getGravityTransitionRemaining() {
|
||||
return this.antarchy$gravityTransitionRemaining;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void antarchy$setGravityState(AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition) {
|
||||
AntarchyGravityDirection previousDirection = this.antarchy$gravityDirection;
|
||||
boolean changed = this.antarchy$gravityDirection != direction || this.antarchy$gravityForced != forced;
|
||||
if (this.antarchy$gravityDirection != direction) {
|
||||
this.antarchy$adjustPositionForGravityChange(this.antarchy$gravityDirection, direction);
|
||||
this.antarchy$prevGravityDirection = this.antarchy$gravityDirection;
|
||||
this.antarchy$gravityDirection = direction;
|
||||
this.antarchy$gravityTransitionDuration = transition.durationTicks();
|
||||
this.antarchy$gravityTransitionRemaining = transition.durationTicks();
|
||||
this.antarchy$refreshGravityBounds();
|
||||
}
|
||||
|
||||
this.antarchy$gravityForced = forced;
|
||||
if (changed && this.antarchy$entity() instanceof Mob mob) {
|
||||
// Any existing path is expressed in the previous gravity frame.
|
||||
// Keep goals from following stale nodes after a flip.
|
||||
mob.getNavigation().stop();
|
||||
}
|
||||
if (changed && !this.antarchy$entity().level().isClientSide) {
|
||||
AntarchyGravityApi.notifyGravityStateChanged(this.antarchy$entity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void antarchy$setAirborneGravityState(AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition) {
|
||||
Entity entity = this.antarchy$entity();
|
||||
net.minecraft.world.phys.Vec3 worldVelocity = AntarchyGravityApi.getWorldVelocity(entity);
|
||||
this.antarchy$setGravityState(direction, forced, transition);
|
||||
AntarchyGravityApi.setWorldVelocity(entity, worldVelocity);
|
||||
entity.setOnGround(false);
|
||||
entity.resetFallDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void antarchy$applySyncedGravityState(
|
||||
AntarchyGravityDirection direction,
|
||||
AntarchyGravityDirection previousDirection,
|
||||
boolean forced,
|
||||
int transitionDuration,
|
||||
int transitionRemaining
|
||||
) {
|
||||
AntarchyGravityDirection oldDirection = this.antarchy$gravityDirection;
|
||||
this.antarchy$gravityDirection = direction;
|
||||
this.antarchy$prevGravityDirection = previousDirection;
|
||||
this.antarchy$gravityForced = forced;
|
||||
this.antarchy$gravityTransitionDuration = Math.max(0, transitionDuration);
|
||||
this.antarchy$gravityTransitionRemaining = Math.max(0, transitionRemaining);
|
||||
if (oldDirection != direction) {
|
||||
// Do NOT adjust position here — the server entity's position is already
|
||||
// correct (adjusted when gravity first changed on the server). Adjusting
|
||||
// again on the client causes a double-shift on relog, which creates
|
||||
// a position desync and stuttering as the server repeatedly corrects us.
|
||||
this.antarchy$refreshGravityBounds();
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private Entity antarchy$entity() {
|
||||
return (Entity) (Object) this;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void antarchy$refreshGravityBounds() {
|
||||
this.setBoundingBox(this.makeBoundingBox());
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void antarchy$clearLoadedInversion(Mob mob) {
|
||||
mob.removeEffect(com.craisinlord.antarchy.content.AntarchyObjects.INVERTED_EFFECT.get());
|
||||
this.antarchy$gravityDirection = AntarchyGravityDirection.DOWN;
|
||||
this.antarchy$prevGravityDirection = AntarchyGravityDirection.DOWN;
|
||||
this.antarchy$gravityForced = false;
|
||||
this.antarchy$gravityTransitionDuration = 0;
|
||||
this.antarchy$gravityTransitionRemaining = 0;
|
||||
this.antarchy$refreshGravityBounds();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private int antarchy$countNearbyDimensionalTears(Mob mob) {
|
||||
if (!(mob.level() instanceof ServerLevel serverLevel)) {
|
||||
return -1;
|
||||
}
|
||||
return serverLevel.getEntitiesOfClass(
|
||||
DimensionalTearEntity.class,
|
||||
mob.getBoundingBox().inflate(48.0D),
|
||||
Entity::isAlive
|
||||
).size();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void antarchy$adjustPositionForGravityChange(AntarchyGravityDirection oldDirection, AntarchyGravityDirection newDirection) {
|
||||
if (oldDirection == newDirection) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = this.antarchy$entity();
|
||||
double yOffset = newDirection.isInverted() ? entity.getBbHeight() : -entity.getBbHeight();
|
||||
entity.setPos(entity.getX(), entity.getY() + yOffset, entity.getZ());
|
||||
entity.setOnGround(false);
|
||||
entity.resetFallDistance();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "checkFallDamage", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private double antarchy$invertFallDamageY(double worldY) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity) || entity instanceof Player) {
|
||||
return worldY;
|
||||
}
|
||||
|
||||
return -worldY;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$isTouchingAntiwater(Entity entity) {
|
||||
return antarchy$intersectsAntiwater(entity, entity.getBoundingBox().inflate(0.05D));
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$intersectsAntiwater(Entity entity, AABB box) {
|
||||
BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
|
||||
BlockPos min = BlockPos.containing(box.minX, box.minY, box.minZ);
|
||||
BlockPos max = BlockPos.containing(box.maxX, box.maxY, box.maxZ);
|
||||
for (int x = min.getX(); x <= max.getX(); x++) {
|
||||
for (int y = min.getY(); y <= max.getY(); y++) {
|
||||
for (int z = min.getZ(); z <= max.getZ(); z++) {
|
||||
cursor.set(x, y, z);
|
||||
FluidState fluidState = entity.level().getFluidState(cursor);
|
||||
if (com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks.isAntiwater(fluidState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "isSupportedBy", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private BlockPos antarchy$mirrorSupportBlock(BlockPos pos) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
return pos.above();
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyMountedGravityHelper;
|
||||
import com.craisinlord.anthology.gravity.MountedGravityHelper;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@@ -17,7 +17,7 @@ public abstract class EntityMountedGravityMixin {
|
||||
@Inject(method = "startRiding(Lnet/minecraft/world/entity/Entity;Z)Z", at = @At("RETURN"))
|
||||
private void antarchy$syncMountedStack(Entity vehicle, boolean force, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (cir.getReturnValueZ()) {
|
||||
AntarchyMountedGravityHelper.syncConnectedStack((Entity) (Object) this);
|
||||
MountedGravityHelper.syncConnectedStack((Entity) (Object) this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public abstract class EntityMountedGravityMixin {
|
||||
|
||||
@Inject(method = "stopRiding", at = @At("TAIL"))
|
||||
private void antarchy$syncDismountedStacks(CallbackInfo ci) {
|
||||
AntarchyMountedGravityHelper.syncSeparatedStacks(this.antarchy$previousVehicle, (Entity) (Object) this);
|
||||
MountedGravityHelper.syncSeparatedStacks(this.antarchy$previousVehicle, (Entity) (Object) this);
|
||||
this.antarchy$previousVehicle = null;
|
||||
}
|
||||
}
|
||||
-374
@@ -1,374 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.MoverType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
/*
|
||||
* Fixes move/landing logic that assumes down is always down.
|
||||
*/
|
||||
public abstract class EntityMoveMixin {
|
||||
@Unique
|
||||
private static final Logger ANTARCHY_STEP_LOGGER = LoggerFactory.getLogger("Antarchy/GravityStep");
|
||||
@Unique
|
||||
private boolean antarchy$loggedInvertedCollide;
|
||||
@Unique
|
||||
private boolean antarchy$loggedHorizontalBlock;
|
||||
@Unique
|
||||
private boolean antarchy$loggedInvertedMove;
|
||||
@Unique
|
||||
private double antarchy$lastWorldMoveY = 0.0;
|
||||
@Unique
|
||||
private double antarchy$lastPlayerMoveY = 0.0;
|
||||
@Unique
|
||||
private AABB antarchy$moveStartBox;
|
||||
@Unique
|
||||
private Vec3 antarchy$collideWorldMovement = Vec3.ZERO;
|
||||
|
||||
@Inject(method = "move", at = @At("HEAD"))
|
||||
private void antarchy$captureMoveStart(MoverType type, Vec3 movement, CallbackInfo ci) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
this.antarchy$moveStartBox = entity.getBoundingBox();
|
||||
this.antarchy$lastPlayerMoveY = movement.y;
|
||||
if (AntarchyGravityApi.isGravityInverted(entity) && !this.antarchy$loggedInvertedMove) {
|
||||
this.antarchy$loggedInvertedMove = true;
|
||||
ANTARCHY_STEP_LOGGER.warn(
|
||||
"Inverted move entered: entity={} movement={} noPhysics={} onGround={} box={}",
|
||||
entity.getClass().getSimpleName(), movement, entity.noPhysics, entity.onGround(), entity.getBoundingBox());
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "move", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private Vec3 antarchy$movePlayerToWorld(Vec3 movement) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return movement;
|
||||
}
|
||||
|
||||
Vec3 world = AntarchyGravityRotationUtil.vecPlayerToWorld(movement, direction);
|
||||
this.antarchy$lastWorldMoveY = world.y;
|
||||
return world;
|
||||
}
|
||||
|
||||
@ModifyArg(
|
||||
method = "move",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/phys/Vec3;multiply(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;",
|
||||
ordinal = 0
|
||||
),
|
||||
index = 0
|
||||
)
|
||||
private Vec3 antarchy$moveMaskPlayerToWorld(Vec3 multiplier) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
return AntarchyGravityRotationUtil.maskPlayerToWorld(multiplier, direction);
|
||||
}
|
||||
|
||||
@ModifyVariable(
|
||||
method = "move",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V",
|
||||
ordinal = 0
|
||||
),
|
||||
ordinal = 0
|
||||
)
|
||||
private Vec3 antarchy$moveWorldToPlayerAttempted(Vec3 movement) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return movement;
|
||||
}
|
||||
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(movement, direction);
|
||||
}
|
||||
|
||||
@ModifyVariable(
|
||||
method = "move",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V",
|
||||
ordinal = 0
|
||||
),
|
||||
ordinal = 1
|
||||
)
|
||||
private Vec3 antarchy$moveWorldToPlayerResolved(Vec3 movement) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return movement;
|
||||
}
|
||||
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(movement, direction);
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "move", at = @At("TAIL"))
|
||||
private void antarchy$fixVerticalCollisionBelow(MoverType type, Vec3 movement, CallbackInfo ci) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.antarchy$lastPlayerMoveY < 0.0D && this.antarchy$moveStartBox != null) {
|
||||
AABB endBox = entity.getBoundingBox();
|
||||
Vec3 delta = endBox.getCenter().subtract(this.antarchy$moveStartBox.getCenter());
|
||||
AABB sweptBox = this.antarchy$moveStartBox.expandTowards(delta).minmax(endBox).inflate(0.05D);
|
||||
if (antarchy$intersectsAntiwater(entity, sweptBox)) {
|
||||
entity.resetFallDistance();
|
||||
}
|
||||
}
|
||||
|
||||
if (!entity.verticalCollision) return;
|
||||
boolean landedOnCeiling = this.antarchy$lastWorldMoveY > 0.0;
|
||||
entity.verticalCollisionBelow = landedOnCeiling;
|
||||
if (landedOnCeiling) {
|
||||
entity.setOnGround(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "collide", at = @At("HEAD"))
|
||||
private void antarchy$captureCollideWorldMovement(Vec3 movement, CallbackInfoReturnable<Vec3> cir) {
|
||||
this.antarchy$collideWorldMovement = movement;
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (AntarchyGravityApi.isGravityInverted(entity) && !this.antarchy$loggedInvertedCollide) {
|
||||
this.antarchy$loggedInvertedCollide = true;
|
||||
ANTARCHY_STEP_LOGGER.warn(
|
||||
"Inverted collide entered: entity={} movement={} onGround={} maxUpStep={} box={}",
|
||||
entity.getClass().getSimpleName(), movement, entity.onGround(), entity.maxUpStep(), entity.getBoundingBox());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep vanilla's step algorithm in player-local coordinates. Its Y tests,
|
||||
* candidate heights and maxUpStep are all defined in that frame. Only the
|
||||
* physical AABB operations and low-level shape collision belong in world
|
||||
* coordinates.
|
||||
*/
|
||||
@ModifyVariable(
|
||||
method = "collide",
|
||||
at = @At(
|
||||
value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/world/level/Level;getEntityCollisions(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;",
|
||||
ordinal = 0
|
||||
),
|
||||
ordinal = 0
|
||||
)
|
||||
private Vec3 antarchy$collideWorldToPlayer(Vec3 movement) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return movement;
|
||||
}
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(movement, direction);
|
||||
}
|
||||
|
||||
@ModifyArgs(
|
||||
method = "collide",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/phys/AABB;expandTowards(DDD)Lnet/minecraft/world/phys/AABB;"
|
||||
)
|
||||
)
|
||||
private void antarchy$expandStepSearchInWorldFrame(Args args) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
Vec3 world = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
new Vec3(args.get(0), args.get(1), args.get(2)), direction);
|
||||
args.set(0, world.x);
|
||||
args.set(1, world.y);
|
||||
args.set(2, world.z);
|
||||
}
|
||||
|
||||
@ModifyArgs(
|
||||
method = "collide",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/phys/AABB;move(DDD)Lnet/minecraft/world/phys/AABB;"
|
||||
)
|
||||
)
|
||||
private void antarchy$moveStepBoxInWorldFrame(Args args) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
Vec3 world = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
new Vec3(args.get(0), args.get(1), args.get(2)), direction);
|
||||
args.set(0, world.x);
|
||||
args.set(1, world.y);
|
||||
args.set(2, world.z);
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
method = "collide",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Entity;collideBoundingBox(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Lnet/minecraft/world/level/Level;Ljava/util/List;)Lnet/minecraft/world/phys/Vec3;"
|
||||
)
|
||||
)
|
||||
private Vec3 antarchy$collideBoundingBoxInLocalFrame(
|
||||
Entity collisionEntity,
|
||||
Vec3 localMovement,
|
||||
AABB box,
|
||||
Level level,
|
||||
List<VoxelShape> collisions,
|
||||
Operation<Vec3> original
|
||||
) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(collisionEntity);
|
||||
if (!direction.isInverted()) {
|
||||
return original.call(collisionEntity, localMovement, box, level, collisions);
|
||||
}
|
||||
Vec3 worldMovement = AntarchyGravityRotationUtil.vecPlayerToWorld(localMovement, direction);
|
||||
Vec3 worldResult = original.call(collisionEntity, worldMovement, box, level, collisions);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldResult, direction);
|
||||
}
|
||||
|
||||
/*
|
||||
* Vanilla uses collideWithShapes directly for each step-height candidate,
|
||||
* bypassing collideBoundingBox. At this point collide() is operating in the
|
||||
* gravity-local frame, so leaving this call untouched makes an inverted
|
||||
* entity test the candidate in the opposite horizontal and vertical world
|
||||
* directions. The candidate consequently never beats the blocked movement.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "collide",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Entity;collideWithShapes(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/List;)Lnet/minecraft/world/phys/Vec3;"
|
||||
)
|
||||
)
|
||||
private Vec3 antarchy$collideStepCandidateInLocalFrame(
|
||||
Vec3 localMovement,
|
||||
AABB box,
|
||||
List<VoxelShape> collisions,
|
||||
Operation<Vec3> original
|
||||
) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return original.call(localMovement, box, collisions);
|
||||
}
|
||||
Vec3 worldMovement = AntarchyGravityRotationUtil.vecPlayerToWorld(localMovement, direction);
|
||||
Vec3 worldResult = original.call(worldMovement, box, collisions);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldResult, direction);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "collide",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Entity;collectCandidateStepUpHeights(Lnet/minecraft/world/phys/AABB;Ljava/util/List;FF)[F"
|
||||
)
|
||||
)
|
||||
private float[] antarchy$collectGravityAwareStepHeights(
|
||||
AABB box, List<VoxelShape> shapes, float maxStep, float currentY) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(entity);
|
||||
TreeSet<Float> heights = new TreeSet<>();
|
||||
for (VoxelShape shape : shapes) {
|
||||
for (double coord : shape.getCoords(Direction.Axis.Y)) {
|
||||
float height = (float) (inverted ? box.maxY - coord : coord - box.minY);
|
||||
if (height >= 0.0F && height != currentY && height <= maxStep) {
|
||||
heights.add(height);
|
||||
}
|
||||
}
|
||||
}
|
||||
float[] result = new float[heights.size()];
|
||||
int i = 0;
|
||||
for (float height : heights) {
|
||||
result[i++] = height;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "collide",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/world/phys/AABB;minY:D")
|
||||
)
|
||||
private double antarchy$readLocalStepBase(AABB box) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return box.minY;
|
||||
}
|
||||
return -box.maxY;
|
||||
}
|
||||
|
||||
@Inject(method = "collide", at = @At("RETURN"), cancellable = true)
|
||||
private void antarchy$collidePlayerToWorld(Vec3 movement, CallbackInfoReturnable<Vec3> cir) {
|
||||
Entity entity = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
Vec3 worldResult = AntarchyGravityRotationUtil.vecPlayerToWorld(cir.getReturnValue(), direction);
|
||||
Vec3 localMovement = AntarchyGravityRotationUtil.vecWorldToPlayer(this.antarchy$collideWorldMovement, direction);
|
||||
if (!this.antarchy$loggedHorizontalBlock
|
||||
&& (localMovement.x != cir.getReturnValue().x || localMovement.z != cir.getReturnValue().z)) {
|
||||
this.antarchy$loggedHorizontalBlock = true;
|
||||
ANTARCHY_STEP_LOGGER.warn(
|
||||
"Inverted horizontal block: localMovement={} localResult={} worldMovement={} worldResult={} onGround={} maxUpStep={} box={}",
|
||||
localMovement, cir.getReturnValue(), this.antarchy$collideWorldMovement, worldResult,
|
||||
entity.onGround(), entity.maxUpStep(), entity.getBoundingBox());
|
||||
}
|
||||
// Portal-gun collision restoration is temporarily disabled. It can
|
||||
// recurse through Sable's collision redirect and hang the server.
|
||||
cir.setReturnValue(worldResult);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$intersectsAntiwater(Entity entity, AABB box) {
|
||||
BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
|
||||
BlockPos min = BlockPos.containing(box.minX, box.minY, box.minZ);
|
||||
BlockPos max = BlockPos.containing(box.maxX, box.maxY, box.maxZ);
|
||||
for (int x = min.getX(); x <= max.getX(); x++) {
|
||||
for (int y = min.getY(); y <= max.getY(); y++) {
|
||||
for (int z = min.getZ(); z <= max.getZ(); z++) {
|
||||
cursor.set(x, y, z);
|
||||
FluidState fluidState = entity.level().getFluidState(cursor);
|
||||
if (AntarchyFluidChecks.isAntiwater(fluidState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
/*
|
||||
* Entity declares applyGravity in 1.21.1. Restrict the reversed acceleration to
|
||||
* projectiles that are physically inside the Thoraxis Underside.
|
||||
*/
|
||||
public abstract class EntityProjectileGravityMixin {
|
||||
|
||||
@Inject(method = "applyGravity", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$applyProjectileGravityUpward(CallbackInfo ci) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
if (!(self instanceof Projectile projectile)) {
|
||||
return;
|
||||
}
|
||||
if (projectile.isNoGravity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(projectile);
|
||||
if (!inverted && projectile.getOwner() != null) {
|
||||
inverted = AntarchyGravityApi.isGravityInverted(projectile.getOwner());
|
||||
}
|
||||
if (!inverted && !ThoraxisUndersideManager.isInUnderside(projectile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
projectile.setDeltaMovement(
|
||||
projectile.getDeltaMovement().add(0.0D, projectile.getGravity(), 0.0D)
|
||||
);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(Explosion.class)
|
||||
/*
|
||||
* Fixes explosion knockback for inverted gravity.
|
||||
*/
|
||||
public abstract class ExplosionGravityMixin {
|
||||
|
||||
@WrapOperation(method = "explode",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;",
|
||||
ordinal = 0))
|
||||
private Vec3 antarchy$fixExplosionGetVelocity(Entity entity, Operation<Vec3> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) return original.call(entity);
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(original.call(entity), direction);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "explode",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V",
|
||||
ordinal = 0))
|
||||
private void antarchy$fixExplosionSetVelocity(Entity entity, Vec3 velocity, Operation<Void> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
original.call(entity, velocity);
|
||||
return;
|
||||
}
|
||||
original.call(entity, AntarchyGravityRotationUtil.vecWorldToPlayer(velocity, direction));
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(FireworkRocketEntity.class)
|
||||
public abstract class FireworkRocketGravityMixin {
|
||||
|
||||
@WrapOperation(method = "tick",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;getHandHoldingItemAngle(Lnet/minecraft/world/item/Item;)Lnet/minecraft/world/phys/Vec3;"))
|
||||
private Vec3 antarchy$rotateAttachedRocketOffset(LivingEntity entity, Item item, Operation<Vec3> original) {
|
||||
Vec3 offset = original.call(entity, item);
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) {
|
||||
return offset;
|
||||
}
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(offset, direction);
|
||||
}
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.GravityWalkNodeEvaluator;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.navigation.GroundPathNavigation;
|
||||
import net.minecraft.world.level.pathfinder.NodeEvaluator;
|
||||
import net.minecraft.world.level.pathfinder.PathFinder;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(GroundPathNavigation.class)
|
||||
public abstract class GroundPathNavigationMixin {
|
||||
@Inject(method = "createPathFinder", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$useGravityEvaluator(int maxVisitedNodes, CallbackInfoReturnable<PathFinder> cir) {
|
||||
var accessor = (PathNavigationAccessor) (Object) this;
|
||||
NodeEvaluator evaluator = new GravityWalkNodeEvaluator();
|
||||
// GroundPathNavigation enables door passing on its vanilla evaluator.
|
||||
// Preserve that setting when swapping in the gravity-aware evaluator.
|
||||
evaluator.setCanPassDoors(true);
|
||||
accessor.antarchy$setNodeEvaluator(evaluator);
|
||||
cir.setReturnValue(new PathFinder(evaluator, maxVisitedNodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* GroundPathNavigation normalizes entity destinations toward the floor
|
||||
* before delegating to PathNavigation. For inverted mobs, replace that
|
||||
* final destination with a bounded, collision-free ceiling anchor.
|
||||
*/
|
||||
@org.spongepowered.asm.mixin.injection.ModifyArg(
|
||||
method = "createPath(Lnet/minecraft/core/BlockPos;I)Lnet/minecraft/world/level/pathfinder/Path;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/ai/navigation/PathNavigation;createPath(Lnet/minecraft/core/BlockPos;I)Lnet/minecraft/world/level/pathfinder/Path;"
|
||||
),
|
||||
index = 0
|
||||
)
|
||||
private BlockPos antarchy$projectInvertedDestination(BlockPos normalizedDestination) {
|
||||
Mob mob = ((PathNavigationAccessor) (Object) this).antarchy$getMob();
|
||||
if (!AntarchyGravityApi.isGravityInverted(mob)) {
|
||||
return normalizedDestination;
|
||||
}
|
||||
|
||||
EntityDimensions dimensions = mob.getDimensions(mob.getPose());
|
||||
int centerX = normalizedDestination.getX();
|
||||
int centerZ = normalizedDestination.getZ();
|
||||
int baseY = normalizedDestination.getY();
|
||||
int minY = Math.max(mob.level().getMinBuildHeight(), baseY - 32);
|
||||
int maxY = Math.min(mob.level().getMaxBuildHeight() - 2, baseY + 32);
|
||||
for (int candidateY = baseY; candidateY <= maxY; candidateY++) {
|
||||
BlockPos support = new BlockPos(centerX, candidateY + 1, centerZ);
|
||||
if (!mob.level().getBlockState(support).isFaceSturdy(mob.level(), support, Direction.DOWN)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double topY = candidateY + 1.0D - 1.0E-3D;
|
||||
double halfWidth = dimensions.width() / 2.0D;
|
||||
AABB body = new AABB(
|
||||
centerX + 0.5D - halfWidth,
|
||||
topY - dimensions.height(),
|
||||
centerZ + 0.5D - halfWidth,
|
||||
centerX + 0.5D + halfWidth,
|
||||
topY,
|
||||
centerZ + 0.5D + halfWidth
|
||||
).deflate(1.0E-4D);
|
||||
if (mob.level().noCollision(mob, body)) {
|
||||
return new BlockPos(centerX, candidateY, centerZ);
|
||||
}
|
||||
}
|
||||
|
||||
return normalizedDestination;
|
||||
}
|
||||
|
||||
@Inject(method = "getTempMobPos", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$useInvertedMobAnchor(CallbackInfoReturnable<Vec3> cir) {
|
||||
Mob mob = ((PathNavigationAccessor) (Object) this).antarchy$getMob();
|
||||
if (AntarchyGravityApi.isGravityInverted(mob)) {
|
||||
cir.setReturnValue(new Vec3(mob.getX(), mob.getY(), mob.getZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
-297
@@ -1,297 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
/*
|
||||
* Fixes living entity movement/combat bits for inverted gravity.
|
||||
*/
|
||||
public abstract class LivingEntityMixin {
|
||||
|
||||
@WrapOperation(method = "travel",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getY()D"))
|
||||
private double antarchy$fixTravelGetY(LivingEntity entity, Operation<Double> original) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) return original.call(entity);
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(entity.position(), direction).y;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "travel",
|
||||
at = @At(value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;getLookAngle()Lnet/minecraft/world/phys/Vec3;",
|
||||
ordinal = 0),
|
||||
ordinal = 2)
|
||||
private Vec3 antarchy$fixTravelLookAngle(Vec3 vec3) {
|
||||
LivingEntity entity = (LivingEntity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) return vec3;
|
||||
Vec3 localLook = AntarchyGravityRotationUtil.vecWorldToPlayer(vec3, direction);
|
||||
if (!entity.isFallFlying()) {
|
||||
return localLook;
|
||||
}
|
||||
|
||||
// Elytra flight mirror fix on east/west axis
|
||||
return new Vec3(-localLook.x, localLook.y, localLook.z);
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "checkFallDamage", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private double antarchy$invertLivingFallDamageY(double worldY) {
|
||||
LivingEntity entity = (LivingEntity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
return worldY;
|
||||
}
|
||||
if (antarchy$isTouchingAntiwater(entity)) {
|
||||
entity.fallDistance = 0.0F;
|
||||
return 0.0D;
|
||||
}
|
||||
return -worldY;
|
||||
}
|
||||
|
||||
@org.spongepowered.asm.mixin.injection.Inject(method = "calculateEntityAnimation", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixEntityAnimation(boolean flutter, CallbackInfo ci) {
|
||||
LivingEntity entity = (LivingEntity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) return;
|
||||
ci.cancel();
|
||||
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
Vec3 playerPosDelta = AntarchyGravityRotationUtil.vecWorldToPlayer(
|
||||
new Vec3(entity.getX() - entity.xo, entity.getY() - entity.yo, entity.getZ() - entity.zo),
|
||||
direction
|
||||
);
|
||||
double d = playerPosDelta.x;
|
||||
double e = flutter ? playerPosDelta.y : 0.0D;
|
||||
double f = playerPosDelta.z;
|
||||
float g = (float) Math.sqrt(d * d + e * e + f * f) * 4.0F;
|
||||
if (g > 1.0F) g = 1.0F;
|
||||
entity.walkAnimation.update(g, 0.4F);
|
||||
}
|
||||
|
||||
@org.spongepowered.asm.mixin.injection.Inject(method = "wouldNotSuffocateAtTargetPose", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixPoseCheck(Pose pose, CallbackInfoReturnable<Boolean> cir) {
|
||||
LivingEntity entity = (LivingEntity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) return;
|
||||
EntityDimensions dims = entity.getDimensions(pose);
|
||||
Vec3 pos = entity.position();
|
||||
float halfWidth = dims.width() / 2.0F;
|
||||
float height = dims.height();
|
||||
AABB invertedBox = new AABB(
|
||||
pos.x - halfWidth, pos.y - height, pos.z - halfWidth,
|
||||
pos.x + halfWidth, pos.y, pos.z + halfWidth
|
||||
);
|
||||
cir.setReturnValue(entity.level().noCollision(entity, invertedBox));
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$isTouchingAntiwater(LivingEntity entity) {
|
||||
AABB box = entity.getBoundingBox().inflate(0.05D);
|
||||
BlockPos min = BlockPos.containing(box.minX, box.minY, box.minZ);
|
||||
BlockPos max = BlockPos.containing(box.maxX, box.maxY, box.maxZ);
|
||||
BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
|
||||
for (int x = min.getX(); x <= max.getX(); x++) {
|
||||
for (int y = min.getY(); y <= max.getY(); y++) {
|
||||
for (int z = min.getZ(); z <= max.getZ(); z++) {
|
||||
cursor.set(x, y, z);
|
||||
FluidState fluidState = entity.level().getFluidState(cursor);
|
||||
if (AntarchyFluidChecks.isAntiwater(fluidState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@org.spongepowered.asm.mixin.injection.Inject(method = "getLocalBoundsForPose", at = @At("RETURN"), cancellable = true)
|
||||
private void antarchy$fixLocalBoundsForPose(Pose pose, CallbackInfoReturnable<AABB> cir) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) return;
|
||||
AABB box = cir.getReturnValue();
|
||||
box = box.move(0.0D, -1.0E-6D, 0.0D);
|
||||
cir.setReturnValue(AntarchyGravityRotationUtil.boxPlayerToWorld(box, direction));
|
||||
}
|
||||
|
||||
@WrapOperation(method = "hasLineOfSight",
|
||||
at = @At(value = "NEW", target = "(DDD)Lnet/minecraft/world/phys/Vec3;", ordinal = 0))
|
||||
private Vec3 antarchy$fixHasLineOfSightSelf(double x, double y, double z, Operation<Vec3> original) {
|
||||
LivingEntity self = (LivingEntity) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(self)) return original.call(x, y, z);
|
||||
return self.getEyePosition();
|
||||
}
|
||||
|
||||
@WrapOperation(method = "hasLineOfSight",
|
||||
at = @At(value = "NEW", target = "(DDD)Lnet/minecraft/world/phys/Vec3;", ordinal = 1))
|
||||
private Vec3 antarchy$fixHasLineOfSightTarget(double x, double y, double z, Operation<Vec3> original,
|
||||
@Local(argsOnly = true) Entity other) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(other)) return original.call(x, y, z);
|
||||
return other.getEyePosition();
|
||||
}
|
||||
|
||||
@WrapOperation(method = "tick",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getX()D", ordinal = 0))
|
||||
private double antarchy$fixTickBodyRotGetX(LivingEntity entity, Operation<Double> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) return original.call(entity);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(
|
||||
original.call(entity) - entity.xo,
|
||||
entity.getY() - entity.yo,
|
||||
entity.getZ() - entity.zo,
|
||||
direction
|
||||
).x + entity.xo;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "tick",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getZ()D", ordinal = 0))
|
||||
private double antarchy$fixTickBodyRotGetZ(LivingEntity entity, Operation<Double> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted()) return original.call(entity);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(
|
||||
entity.getX() - entity.xo,
|
||||
entity.getY() - entity.yo,
|
||||
original.call(entity) - entity.zo,
|
||||
direction
|
||||
).z + entity.zo;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "blockedByShield",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getX()D", ordinal = 0))
|
||||
private double antarchy$fixShieldAttackerX(LivingEntity attacker, Operation<Double> original) {
|
||||
AntarchyGravityDirection defDir = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!defDir.isInverted()) {
|
||||
if (AntarchyGravityApi.isGravityInverted(attacker)) return attacker.getEyePosition().x;
|
||||
return original.call(attacker);
|
||||
}
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(attacker.getEyePosition(), defDir).x;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "blockedByShield",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getZ()D", ordinal = 0))
|
||||
private double antarchy$fixShieldAttackerZ(LivingEntity attacker, Operation<Double> original) {
|
||||
AntarchyGravityDirection defDir = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!defDir.isInverted()) return original.call(attacker);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(attacker.getEyePosition(), defDir).z;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "blockedByShield",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getX()D", ordinal = 1))
|
||||
private double antarchy$fixShieldDefenderX(LivingEntity shieldUser, Operation<Double> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) return original.call(shieldUser);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(shieldUser.position(), direction).x;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "blockedByShield",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getZ()D", ordinal = 1))
|
||||
private double antarchy$fixShieldDefenderZ(LivingEntity shieldUser, Operation<Double> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) return original.call(shieldUser);
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(shieldUser.position(), direction).z;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "isDamageSourceBlocked",
|
||||
at = @At(value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;calculateViewVector(FF)Lnet/minecraft/world/phys/Vec3;",
|
||||
ordinal = 0),
|
||||
ordinal = 1)
|
||||
private Vec3 antarchy$fixShieldArcViewVector(Vec3 vec3) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) return vec3;
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(vec3, direction);
|
||||
}
|
||||
|
||||
@ModifyArg(method = "playBlockFallSound",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"),
|
||||
index = 0)
|
||||
private BlockPos antarchy$fixBlockFallSoundPos(BlockPos pos) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) return pos;
|
||||
Entity selfEntity = (Entity) (Object) this;
|
||||
return BlockPos.containing(selfEntity.position().add(
|
||||
AntarchyGravityRotationUtil.vecPlayerToWorld(new Vec3(0.0D, -0.20000000298023224D, 0.0D), direction)
|
||||
));
|
||||
}
|
||||
|
||||
@WrapOperation(method = "spawnItemParticles",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;",
|
||||
ordinal = 0))
|
||||
private Vec3 antarchy$fixItemParticlesAdd(Vec3 base, double x, double y, double z, Operation<Vec3> original) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(self);
|
||||
if (!direction.isInverted()) return original.call(base, x, y, z);
|
||||
Vec3 rotated = AntarchyGravityRotationUtil.vecPlayerToWorld(new Vec3(x, y, z), direction);
|
||||
return original.call(self.getEyePosition(), rotated.x, rotated.y, rotated.z);
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "spawnItemParticles",
|
||||
at = @At(value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/world/phys/Vec3;yRot(F)Lnet/minecraft/world/phys/Vec3;",
|
||||
ordinal = 0),
|
||||
ordinal = 0)
|
||||
private Vec3 antarchy$fixItemParticlesYRotVec(Vec3 vec3) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) return vec3;
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(vec3, direction);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "tickEffects",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/Level;addParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)V"))
|
||||
private void antarchy$fixEffectParticles(Level level, ParticleOptions particle,
|
||||
double x, double y, double z, double dx, double dy, double dz,
|
||||
Operation<Void> original) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(self);
|
||||
if (!direction.isInverted()) {
|
||||
original.call(level, particle, x, y, z, dx, dy, dz);
|
||||
return;
|
||||
}
|
||||
Vec3 pos = self.position().subtract(
|
||||
AntarchyGravityRotationUtil.vecPlayerToWorld(self.position().subtract(x, y, z), direction)
|
||||
);
|
||||
original.call(level, particle, pos.x, pos.y, pos.z, dx, dy, dz);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "makePoofParticles",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/Level;addParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)V",
|
||||
ordinal = 0))
|
||||
private void antarchy$fixPoofParticles(Level level, ParticleOptions particle,
|
||||
double x, double y, double z, double dx, double dy, double dz,
|
||||
Operation<Void> original) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(self);
|
||||
if (!direction.isInverted()) {
|
||||
original.call(level, particle, x, y, z, dx, dy, dz);
|
||||
return;
|
||||
}
|
||||
Vec3 pos = self.position().subtract(
|
||||
AntarchyGravityRotationUtil.vecPlayerToWorld(self.position().subtract(x, y, z), direction)
|
||||
);
|
||||
original.call(level, particle, pos.x, pos.y, pos.z, dx, dy, dz);
|
||||
}
|
||||
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MeleeAttackGoal.class)
|
||||
public abstract class MeleeAttackGoalGravityMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
protected PathfinderMob mob;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private double speedModifier;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private boolean followingTargetEvenIfNotSeen;
|
||||
|
||||
@Shadow
|
||||
private int ticksUntilNextAttack;
|
||||
|
||||
@Shadow
|
||||
protected abstract void checkAndPerformAttack(LivingEntity enemy);
|
||||
|
||||
@Inject(method = "canUse", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$useInvertedMelee(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity target = this.mob.getTarget();
|
||||
cir.setReturnValue(this.antarchy$isValidInvertedMeleeTarget(target));
|
||||
}
|
||||
|
||||
@Inject(method = "canContinueToUse", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$continueInvertedMelee(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity target = this.mob.getTarget();
|
||||
cir.setReturnValue(this.antarchy$isValidInvertedMeleeTarget(target));
|
||||
}
|
||||
|
||||
@Inject(method = "start", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$startInvertedMelee(CallbackInfo ci) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity target = this.mob.getTarget();
|
||||
this.mob.getNavigation().stop();
|
||||
this.mob.setAggressive(true);
|
||||
this.ticksUntilNextAttack = 0;
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$tickInvertedMelee(CallbackInfo ci) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity target = this.mob.getTarget();
|
||||
if (!this.antarchy$isValidInvertedMeleeTarget(target)) {
|
||||
this.mob.getNavigation().stop();
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
this.mob.getLookControl().setLookAt(target, 30.0F, 30.0F);
|
||||
// Do not call PathNavigation.moveTo here: that starts the unsafe vanilla
|
||||
// path acquisition path. MoveControl receives a world-space target and
|
||||
// the gravity movement mixin converts it into the inverted frame.
|
||||
this.mob.getMoveControl().setWantedPosition(target.getX(), target.getY(), target.getZ(), this.speedModifier);
|
||||
this.ticksUntilNextAttack = Math.max(0, this.ticksUntilNextAttack - 1);
|
||||
this.checkAndPerformAttack(target);
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
private boolean antarchy$isValidInvertedMeleeTarget(LivingEntity target) {
|
||||
if (target == null || !target.isAlive()) {
|
||||
return false;
|
||||
}
|
||||
if (this.followingTargetEvenIfNotSeen && !this.mob.isWithinRestriction(target.blockPosition())) {
|
||||
return false;
|
||||
}
|
||||
return !(target instanceof Player player) || (!player.isSpectator() && !player.isCreative());
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(Mob.class)
|
||||
/*
|
||||
* Fixes hurt push logic that assumes normal gravity.
|
||||
*/
|
||||
public abstract class MobHurtMixin {
|
||||
@WrapOperation(method = "doHurtTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;getYRot()F"))
|
||||
private float wrapOperation_tryAttack_getYaw_0(Mob attacker, Operation<Float> original, Entity target) {
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(target);
|
||||
if (!gravityDirection.isInverted()) {
|
||||
return original.call(attacker);
|
||||
}
|
||||
return AntarchyGravityRotationUtil.rotWorldToPlayer(original.call(attacker), attacker.getXRot(), gravityDirection).x;
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.control.MoveControl;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MoveControl.class)
|
||||
public abstract class MoveControlGravityMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
protected Mob mob;
|
||||
|
||||
@Shadow
|
||||
protected double wantedX;
|
||||
|
||||
@Shadow
|
||||
protected double wantedY;
|
||||
|
||||
@Shadow
|
||||
protected double wantedZ;
|
||||
|
||||
@Shadow
|
||||
protected double speedModifier;
|
||||
|
||||
@Inject(method = "setWantedPosition", at = @At("TAIL"))
|
||||
private void antarchy$convertInvertedWantedPosition(double x, double y, double z, double speed, CallbackInfo ci) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 worldOffset = new Vec3(x - this.mob.getX(), y - this.mob.getY(), z - this.mob.getZ());
|
||||
Vec3 localOffset = AntarchyGravityRotationUtil.vecWorldToPlayer(
|
||||
worldOffset,
|
||||
AntarchyGravityApi.getGravityDirection(this.mob));
|
||||
this.wantedX = this.mob.getX() + localOffset.x;
|
||||
this.wantedY = this.mob.getY() + localOffset.y;
|
||||
this.wantedZ = this.mob.getZ() + localOffset.z;
|
||||
this.speedModifier = speed;
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.navigation.PathNavigation;
|
||||
import net.minecraft.world.level.pathfinder.NodeEvaluator;
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(PathNavigation.class)
|
||||
/*
|
||||
* Accessor for path nav internals used by gravity fixes.
|
||||
*/
|
||||
public interface PathNavigationAccessor {
|
||||
@Accessor("mob")
|
||||
Mob antarchy$getMob();
|
||||
|
||||
@Accessor("path")
|
||||
Path antarchy$getPath();
|
||||
|
||||
@Accessor("nodeEvaluator")
|
||||
void antarchy$setNodeEvaluator(NodeEvaluator nodeEvaluator);
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(Player.class)
|
||||
/*
|
||||
* Handles player-only gravity sync and movement fixes.
|
||||
*/
|
||||
public abstract class PlayerGravityMixin {
|
||||
@Redirect(
|
||||
method = "travel",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;getLookAngle()Lnet/minecraft/world/phys/Vec3;"))
|
||||
private Vec3 antarchy$rotateTravelLookAngle(Player player) {
|
||||
Vec3 lookAngle = player.getLookAngle();
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(player);
|
||||
if (!direction.isInverted() || player.isFallFlying()) return lookAngle;
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(lookAngle, direction);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "travel",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/core/BlockPos;containing(DDD)Lnet/minecraft/core/BlockPos;"))
|
||||
private BlockPos antarchy$fixTravelBlockPos(double x, double y, double z,
|
||||
Operation<BlockPos> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection((Entity) (Object) this);
|
||||
if (!direction.isInverted()) return original.call(x, y, z);
|
||||
Vec3 rotate = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
new Vec3(0.0D, 0.9D, 0.0D), direction);
|
||||
return original.call(x - rotate.x, y - rotate.y + 0.9D, z - rotate.z);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "attack",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;getYRot()F", ordinal = 0))
|
||||
private float antarchy$fixAttackYaw0(Player attacker, Operation<Float> original,
|
||||
@Local(argsOnly = true) Entity target) {
|
||||
AntarchyGravityDirection targetDir = AntarchyGravityApi.getGravityDirection(target);
|
||||
AntarchyGravityDirection attackerDir = AntarchyGravityApi.getGravityDirection(attacker);
|
||||
if (targetDir == attackerDir) return original.call(attacker);
|
||||
Vec2 worldRot = AntarchyGravityRotationUtil.rotPlayerToWorld(
|
||||
original.call(attacker), attacker.getXRot(), attackerDir);
|
||||
return AntarchyGravityRotationUtil.rotWorldToPlayer(worldRot.x, worldRot.y, targetDir).x;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "attack",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;getYRot()F", ordinal = 1))
|
||||
private float antarchy$fixAttackYaw1(Player attacker, Operation<Float> original,
|
||||
@Local(argsOnly = true) Entity target) {
|
||||
AntarchyGravityDirection targetDir = AntarchyGravityApi.getGravityDirection(target);
|
||||
AntarchyGravityDirection attackerDir = AntarchyGravityApi.getGravityDirection(attacker);
|
||||
if (targetDir == attackerDir) return original.call(attacker);
|
||||
Vec2 worldRot = AntarchyGravityRotationUtil.rotPlayerToWorld(
|
||||
original.call(attacker), attacker.getXRot(), attackerDir);
|
||||
return AntarchyGravityRotationUtil.rotWorldToPlayer(worldRot.x, worldRot.y, targetDir).x;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "attack",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;getYRot()F", ordinal = 2))
|
||||
private float antarchy$fixAttackYaw2(Player attacker, Operation<Float> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(attacker);
|
||||
if (!direction.isInverted()) return original.call(attacker);
|
||||
return AntarchyGravityRotationUtil.rotPlayerToWorld(
|
||||
original.call(attacker), attacker.getXRot(), direction).x;
|
||||
}
|
||||
|
||||
@WrapOperation(method = "attack",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;getYRot()F", ordinal = 3))
|
||||
private float antarchy$fixAttackYaw3(Player attacker, Operation<Float> original) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(attacker);
|
||||
if (!direction.isInverted()) return original.call(attacker);
|
||||
return AntarchyGravityRotationUtil.rotPlayerToWorld(
|
||||
original.call(attacker), attacker.getXRot(), direction).x;
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Player.class)
|
||||
/*
|
||||
* Fixes pose checks for ceiling-walking players.
|
||||
*/
|
||||
public abstract class PlayerPoseFitMixin {
|
||||
|
||||
@Inject(method = "canPlayerFitWithinBlocksAndEntitiesWhen", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$canFitPoseWhenInverted(Pose pose, CallbackInfoReturnable<Boolean> cir) {
|
||||
Player player = (Player) (Object) this;
|
||||
if (!AntarchyGravityApi.isGravityInverted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityDimensions dimensions = player.getDimensions(pose);
|
||||
Vec3 position = player.position();
|
||||
float halfWidth = dimensions.width() / 2.0F;
|
||||
float height = dimensions.height();
|
||||
AABB invertedBox = new AABB(
|
||||
position.x - halfWidth, position.y - height, position.z - halfWidth,
|
||||
position.x + halfWidth, position.y, position.z + halfWidth
|
||||
);
|
||||
cir.setReturnValue(player.level().noCollision(player, invertedBox));
|
||||
}
|
||||
}
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.MoverType;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Player.class)
|
||||
/*
|
||||
* Makes sneaking and edge checks work upside down.
|
||||
*/
|
||||
public abstract class PlayerSneakMixin {
|
||||
|
||||
@Shadow @Final private Abilities abilities;
|
||||
@Shadow protected abstract boolean isStayingOnGroundSurface();
|
||||
|
||||
@Inject(method = "maybeBackOffFromEdge", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$fixSneakEdge(Vec3 movement, MoverType type, CallbackInfoReturnable<Vec3> cir) {
|
||||
Entity this_ = (Entity) (Object) this;
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this_);
|
||||
if (!direction.isInverted()) {
|
||||
return;
|
||||
}
|
||||
float step = this_.maxUpStep();
|
||||
boolean isNearCeiling;
|
||||
if (this_.onGround()) {
|
||||
isNearCeiling = true;
|
||||
} else {
|
||||
float remaining = step - this_.fallDistance;
|
||||
if (remaining > 0.0F) {
|
||||
AABB bb = this_.getBoundingBox();
|
||||
isNearCeiling = !this_.level().noCollision(this_,
|
||||
new AABB(bb.minX, bb.maxY, bb.minZ,
|
||||
bb.maxX, bb.maxY + remaining + 1.0E-5, bb.maxZ));
|
||||
} else {
|
||||
isNearCeiling = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.abilities.flying
|
||||
&& (type == MoverType.SELF || type == MoverType.PLAYER)
|
||||
&& this.isStayingOnGroundSurface()
|
||||
&& isNearCeiling) {
|
||||
Vec3 playerMovement = AntarchyGravityRotationUtil.vecWorldToPlayer(movement, direction);
|
||||
double d = playerMovement.x;
|
||||
double e = playerMovement.z;
|
||||
|
||||
while (d != 0.0D && canFallAtLeastInverted(this_, d, 0.0D, step, direction)) {
|
||||
if (Math.abs(d) <= 0.05D) d = 0.0D;
|
||||
else if (d > 0.0D) d -= 0.05D;
|
||||
else d += 0.05D;
|
||||
}
|
||||
while (e != 0.0D && canFallAtLeastInverted(this_, 0.0D, e, step, direction)) {
|
||||
if (Math.abs(e) <= 0.05D) e = 0.0D;
|
||||
else if (e > 0.0D) e -= 0.05D;
|
||||
else e += 0.05D;
|
||||
}
|
||||
while (d != 0.0D && e != 0.0D && canFallAtLeastInverted(this_, d, e, step, direction)) {
|
||||
if (Math.abs(d) <= 0.05D) d = 0.0D;
|
||||
else if (d > 0.0D) d -= 0.05D;
|
||||
else d += 0.05D;
|
||||
|
||||
if (Math.abs(e) <= 0.05D) e = 0.0D;
|
||||
else if (e > 0.0D) e -= 0.05D;
|
||||
else e += 0.05D;
|
||||
}
|
||||
|
||||
cir.setReturnValue(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
new Vec3(d, playerMovement.y, e), direction));
|
||||
|
||||
} else {
|
||||
cir.setReturnValue(movement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean canFallAtLeastInverted(Entity entity,
|
||||
double dx, double dz,
|
||||
float step,
|
||||
AntarchyGravityDirection direction) {
|
||||
Vec3 worldOffset = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
new Vec3(dx, -step, dz), direction);
|
||||
|
||||
AABB bb = entity.getBoundingBox();
|
||||
AABB probe = bb.move(worldOffset);
|
||||
|
||||
return entity.level().noCollision(entity, probe);
|
||||
}
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.ProjectileLaunchGravity;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Projectile.class)
|
||||
/*
|
||||
* Keeps projectile movement in world space while reversing gravity and launch
|
||||
* direction only inside the Thoraxis Underside.
|
||||
*/
|
||||
public abstract class ProjectileGravityMixin {
|
||||
|
||||
@Inject(method = "shootFromRotation", at = @At("HEAD"))
|
||||
private void antarchy$prepareGravityAwareShot(
|
||||
Entity shooter,
|
||||
float xRot,
|
||||
float yRot,
|
||||
float rotationOffset,
|
||||
float velocity,
|
||||
float inaccuracy,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
ThoraxisUndersideManager.normalizeProjectileGravityFrame((Projectile) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void antarchy$keepWorldMovementFrame(CallbackInfo ci) {
|
||||
ThoraxisUndersideManager.normalizeProjectileGravityFrame((Projectile) (Object) this);
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
method = "shootFromRotation",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/projectile/Projectile;shoot(DDDFF)V"
|
||||
)
|
||||
)
|
||||
private void antarchy$rotateUndersideLaunchDirection(
|
||||
Projectile projectile,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
float velocity,
|
||||
float inaccuracy,
|
||||
Operation<Void> original,
|
||||
@Local(argsOnly = true) Entity shooter
|
||||
) {
|
||||
Vec3 direction = new Vec3(x, y, z);
|
||||
if (AntarchyGravityApi.isGravityInverted(shooter)) {
|
||||
direction = ProjectileLaunchGravity.toWorld(
|
||||
direction,
|
||||
AntarchyGravityApi.getGravityDirection(shooter)
|
||||
);
|
||||
}
|
||||
original.call(projectile, direction.x, direction.y, direction.z, velocity, inaccuracy);
|
||||
}
|
||||
|
||||
}
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.ai.goal.RandomStrollGoal;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(RandomStrollGoal.class)
|
||||
public abstract class RandomStrollGoalGravityMixin {
|
||||
@Unique
|
||||
private static final int ANTARCHY$INVERTED_STROLL_ATTEMPTS = 12;
|
||||
@Unique
|
||||
private static final int ANTARCHY$INVERTED_STROLL_HORIZONTAL_RANGE = 7;
|
||||
@Unique
|
||||
private static final int ANTARCHY$INVERTED_STROLL_VERTICAL_RANGE = 2;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected PathfinderMob mob;
|
||||
|
||||
@Shadow
|
||||
protected double wantedX;
|
||||
|
||||
@Shadow
|
||||
protected double wantedY;
|
||||
|
||||
@Shadow
|
||||
protected double wantedZ;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected double speedModifier;
|
||||
|
||||
@Shadow
|
||||
protected int interval;
|
||||
|
||||
@Shadow
|
||||
protected boolean forceTrigger;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private boolean checkNoActionTime;
|
||||
|
||||
@Unique
|
||||
private int antarchy$invertedStrollTicks;
|
||||
|
||||
@Inject(method = "canUse", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$useInvertedRandomStroll(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.mob.hasControllingPassenger()) {
|
||||
cir.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.forceTrigger) {
|
||||
if (this.checkNoActionTime && this.mob.getNoActionTime() >= 100) {
|
||||
cir.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
int chance = Math.max(1, this.interval);
|
||||
if (this.mob.getRandom().nextInt(chance) != 0) {
|
||||
cir.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cir.setReturnValue(this.antarchy$findInvertedStrollTarget());
|
||||
}
|
||||
|
||||
@Inject(method = "start", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$startInvertedRandomStroll(CallbackInfo ci) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.mob.getNavigation().stop();
|
||||
this.mob.getMoveControl().setWantedPosition(this.wantedX, this.wantedY, this.wantedZ, this.speedModifier);
|
||||
this.antarchy$invertedStrollTicks = 0;
|
||||
this.forceTrigger = false;
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "canContinueToUse", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$continueInvertedRandomStroll(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!AntarchyGravityApi.isGravityInverted(this.mob)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double dx = this.wantedX - this.mob.getX();
|
||||
double dy = this.wantedY - this.mob.getY();
|
||||
double dz = this.wantedZ - this.mob.getZ();
|
||||
boolean arrived = dx * dx + dy * dy + dz * dz <= 1.0D;
|
||||
boolean timedOut = this.antarchy$invertedStrollTicks++ >= 200;
|
||||
if (!arrived && !timedOut && !this.mob.hasControllingPassenger()) {
|
||||
// RandomStrollGoal inherits Goal.tick(), so continuation is the
|
||||
// declared per-tick hook available for refreshing direct movement.
|
||||
this.mob.getMoveControl().setWantedPosition(this.wantedX, this.wantedY, this.wantedZ, this.speedModifier);
|
||||
}
|
||||
cir.setReturnValue(!this.mob.hasControllingPassenger() && !arrived && !timedOut);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$findInvertedStrollTarget() {
|
||||
int baseX = Mth.floor(this.mob.getX());
|
||||
int baseY = Mth.floor(this.mob.getY() + this.mob.getBbHeight()) - 1;
|
||||
int baseZ = Mth.floor(this.mob.getZ());
|
||||
|
||||
for (int attempt = 0; attempt < ANTARCHY$INVERTED_STROLL_ATTEMPTS; attempt++) {
|
||||
int x = baseX + this.mob.getRandom().nextInt(ANTARCHY$INVERTED_STROLL_HORIZONTAL_RANGE * 2 + 1) - ANTARCHY$INVERTED_STROLL_HORIZONTAL_RANGE;
|
||||
int y = baseY + this.mob.getRandom().nextInt(ANTARCHY$INVERTED_STROLL_VERTICAL_RANGE * 2 + 1) - ANTARCHY$INVERTED_STROLL_VERTICAL_RANGE;
|
||||
int z = baseZ + this.mob.getRandom().nextInt(ANTARCHY$INVERTED_STROLL_HORIZONTAL_RANGE * 2 + 1) - ANTARCHY$INVERTED_STROLL_HORIZONTAL_RANGE;
|
||||
if (this.antarchy$isValidInvertedStrollTarget(x, y, z)) {
|
||||
this.wantedX = x + 0.5D;
|
||||
this.wantedY = y + 1.0D - 1.0E-3D;
|
||||
this.wantedZ = z + 0.5D;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$isValidInvertedStrollTarget(int x, int y, int z) {
|
||||
Level level = this.mob.level();
|
||||
BlockPos ceilingPos = new BlockPos(x, y + 1, z);
|
||||
if (!level.getBlockState(ceilingPos).isFaceSturdy(level, ceilingPos, Direction.DOWN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityDimensions dimensions = this.mob.getDimensions(Pose.STANDING);
|
||||
double halfWidth = dimensions.width() / 2.0D;
|
||||
double topY = y + 1.0D - 1.0E-3D;
|
||||
AABB bodyBox = new AABB(
|
||||
x + 0.5D - halfWidth,
|
||||
topY - dimensions.height(),
|
||||
z + 0.5D - halfWidth,
|
||||
x + 0.5D + halfWidth,
|
||||
topY,
|
||||
z + 0.5D + halfWidth
|
||||
).deflate(1.0E-4D);
|
||||
return level.noCollision(this.mob, bodyBox);
|
||||
}
|
||||
}
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(ServerGamePacketListenerImpl.class)
|
||||
/*
|
||||
* Fixes move packet checks for inverted players.
|
||||
*/
|
||||
public abstract class ServerGamePacketListenerMixin {
|
||||
|
||||
@Shadow
|
||||
public ServerPlayer player;
|
||||
|
||||
@Shadow
|
||||
private double lastGoodX;
|
||||
@Shadow
|
||||
private double lastGoodY;
|
||||
@Shadow
|
||||
private double lastGoodZ;
|
||||
|
||||
@ModifyVariable(method = "handleMovePlayer",
|
||||
at = @At(value = "STORE", ordinal = 0),
|
||||
ordinal = 0)
|
||||
private boolean antarchy$fixHandleMovePlayerFlag(boolean originalFlag,
|
||||
ServerboundMovePlayerPacket packet) {
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this.player);
|
||||
if (!gravity.isInverted()) {
|
||||
return originalFlag;
|
||||
}
|
||||
double dx = packet.getX(this.player.getX()) - this.lastGoodX;
|
||||
double dy = packet.getY(this.player.getY()) - this.lastGoodY;
|
||||
double dz = packet.getZ(this.player.getZ()) - this.lastGoodZ;
|
||||
Vec3 localVec = AntarchyGravityRotationUtil.vecWorldToPlayer(new Vec3(dx, dy, dz), gravity);
|
||||
return localVec.y > 0.0;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "handleMovePlayer",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V"))
|
||||
private Vec3 antarchy$fixHandleMovePlayerVector(Vec3 worldDelta) {
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this.player);
|
||||
if (!gravity.isInverted()) {
|
||||
return worldDelta;
|
||||
}
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldDelta, gravity);
|
||||
}
|
||||
|
||||
@ModifyArg(method = "handleMovePlayer",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;setOnGroundWithMovement(ZLnet/minecraft/world/phys/Vec3;)V"),
|
||||
index = 0)
|
||||
private boolean antarchy$fixHandleMovePlayerOnGround(boolean originalOnGround) {
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this.player);
|
||||
if (!gravity.isInverted()) {
|
||||
return originalOnGround;
|
||||
}
|
||||
return originalOnGround || this.player.verticalCollisionBelow || this.player.verticalCollision;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "handleMovePlayer",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;doCheckFallDamage(DDDZ)V"),
|
||||
index = 3)
|
||||
private boolean antarchy$fixHandleMovePlayerFallDamageOnGround(boolean originalOnGround) {
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this.player);
|
||||
if (!gravity.isInverted()) {
|
||||
return originalOnGround;
|
||||
}
|
||||
return originalOnGround || this.player.verticalCollisionBelow || this.player.verticalCollision;
|
||||
}
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
/*
|
||||
* Fixes server-side fall damage for inverted players.
|
||||
*/
|
||||
public abstract class ServerPlayerGravityMixin {
|
||||
@Unique
|
||||
private float antarchy$invertedFallDistance = 0.0F;
|
||||
|
||||
@Inject(method = "doCheckFallDamage", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$cancelFallDamageInAntiwater(double x, double y, double z, boolean onGround, CallbackInfo ci) {
|
||||
ServerPlayer self = (ServerPlayer) (Object) this;
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(self);
|
||||
if (!gravity.isInverted()) {
|
||||
return;
|
||||
}
|
||||
if (!antarchy$isTouchingAntiwater(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.fallDistance = 0.0F;
|
||||
this.antarchy$invertedFallDistance = 0.0F;
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@WrapOperation(method = "doCheckFallDamage",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;checkFallDamage(DZLnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V"))
|
||||
private void antarchy$fixFallDamage(ServerPlayer instance,
|
||||
double worldY, boolean onGround,
|
||||
BlockState state, BlockPos pos,
|
||||
Operation<Void> original,
|
||||
@Local(ordinal = 0) double dx,
|
||||
@Local(ordinal = 1) double dy,
|
||||
@Local(ordinal = 2) double dz) {
|
||||
ServerPlayer self = (ServerPlayer) (Object) this;
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(self);
|
||||
if (!gravity.isInverted()) {
|
||||
this.antarchy$invertedFallDistance = 0.0F;
|
||||
original.call(instance, worldY, onGround, state, pos);
|
||||
return;
|
||||
}
|
||||
if (antarchy$isTouchingAntiwater(self) || antarchy$passedThroughAntiwater(self, dx, dy, dz)) {
|
||||
self.fallDistance = 0.0F;
|
||||
this.antarchy$invertedFallDistance = 0.0F;
|
||||
original.call(instance, 0.0D, onGround, state, pos);
|
||||
return;
|
||||
}
|
||||
Vec3 localVec = AntarchyGravityRotationUtil.vecWorldToPlayer(new Vec3(dx, dy, dz), gravity);
|
||||
if (!onGround) {
|
||||
if (localVec.y < 0.0) {
|
||||
this.antarchy$invertedFallDistance += (float)(-localVec.y);
|
||||
} else {
|
||||
this.antarchy$invertedFallDistance = 0.0F;
|
||||
}
|
||||
} else if (this.antarchy$invertedFallDistance > self.fallDistance) {
|
||||
// Vanilla damage uses fallDistance on landing; keep our own inverted accumulator
|
||||
// in sync because the server pipeline is clearing the field before that point.
|
||||
self.fallDistance = this.antarchy$invertedFallDistance;
|
||||
}
|
||||
original.call(instance, localVec.y, onGround, state, pos);
|
||||
if (onGround) {
|
||||
this.antarchy$invertedFallDistance = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$isTouchingAntiwater(ServerPlayer player) {
|
||||
return antarchy$intersectsAntiwater(player, player.getBoundingBox().inflate(0.05D));
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$passedThroughAntiwater(ServerPlayer player, double dx, double dy, double dz) {
|
||||
AABB sweptBox = player.getBoundingBox().expandTowards(-dx, -dy, -dz).inflate(0.05D);
|
||||
return antarchy$intersectsAntiwater(player, sweptBox);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean antarchy$intersectsAntiwater(ServerPlayer player, AABB box) {
|
||||
BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
|
||||
BlockPos min = BlockPos.containing(box.minX, box.minY, box.minZ);
|
||||
BlockPos max = BlockPos.containing(box.maxX, box.maxY, box.maxZ);
|
||||
for (int x = min.getX(); x <= max.getX(); x++) {
|
||||
for (int y = min.getY(); y <= max.getY(); y++) {
|
||||
for (int z = min.getZ(); z <= max.getZ(); z++) {
|
||||
cursor.set(x, y, z);
|
||||
FluidState fluidState = player.level().getFluidState(cursor);
|
||||
if (AntarchyFluidChecks.isAntiwater(fluidState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.mixins.gravity;
|
||||
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.world.entity.projectile.ThrowableProjectile;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(ThrowableProjectile.class)
|
||||
/*
|
||||
* Flips thrown projectile gravity from the projectile's current position.
|
||||
*/
|
||||
public abstract class ThrowableProjectileGravityMixin {
|
||||
|
||||
@WrapOperation(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/projectile/ThrowableProjectile;applyGravity()V"))
|
||||
private void antarchy$applyThrownProjectileGravityUpward(ThrowableProjectile self, Operation<Void> original) {
|
||||
if (!ThoraxisUndersideManager.isInUnderside(self)) {
|
||||
original.call(self);
|
||||
return;
|
||||
}
|
||||
// Vanilla subtracts gravity from world Y; the Underside adds it instead.
|
||||
double gravity = self.getGravity();
|
||||
self.setDeltaMovement(self.getDeltaMovement().add(0.0D, gravity, 0.0D));
|
||||
}
|
||||
}
|
||||
Loaded 100 of 140 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user