mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 07:17:58 +01:00
Fix a whole bunch of gravity related issues
This commit is contained in:
parent
9e329ac2f9
commit
2dd7fbbb55
19 changed files with 290 additions and 87 deletions
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.client;
|
|||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import com.minelittlepony.common.client.gui.element.Button;
|
||||
import com.minelittlepony.common.event.ScreenInitCallback;
|
||||
|
@ -33,11 +34,14 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.gui.screen.OpenToLanScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreens;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class UnicopiaClient implements ClientModInitializer {
|
||||
|
||||
|
@ -66,6 +70,20 @@ public class UnicopiaClient implements ClientModInitializer {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
public static Vec3d getAdjustedSoundPosition(Vec3d pos) {
|
||||
PlayerCamera cam = getCamera().orElse(null);
|
||||
if (cam == null) {
|
||||
return pos;
|
||||
}
|
||||
Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
|
||||
|
||||
Vector3f rotated = pos.subtract(camera.getPos()).toVector3f();
|
||||
rotated = rotated.rotateAxis(cam.calculateRoll() * MathHelper.RADIANS_PER_DEGREE, 0, 1, 0);
|
||||
|
||||
return new Vec3d(rotated).add(camera.getPos());
|
||||
}
|
||||
|
||||
public static Race getPreferredRace() {
|
||||
if (!Unicopia.getConfig().ignoreMineLP.get()
|
||||
&& MinecraftClient.getInstance().player != null) {
|
||||
|
|
|
@ -8,7 +8,9 @@ import net.minecraft.block.BlockRenderType;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.entity.data.TrackedData;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
@ -35,6 +37,14 @@ public class EntityPhysics<T extends Entity> implements Physics, Copyable<Entity
|
|||
@Override
|
||||
public void tick() {
|
||||
if (isGravityNegative()) {
|
||||
if (isGravityNegative() && !entity.isSneaking() && entity.isInSneakingPose()) {
|
||||
float currentHeight = entity.getDimensions(entity.getPose()).height;
|
||||
float sneakingHeight = entity.getDimensions(EntityPose.STANDING).height;
|
||||
|
||||
entity.move(MovementType.SELF, new Vec3d(0, -(currentHeight - sneakingHeight), 0));
|
||||
entity.setPose(EntityPose.STANDING);
|
||||
}
|
||||
|
||||
if (entity.getY() > entity.getWorld().getHeight() + 64) {
|
||||
entity.damage(entity.getDamageSources().outOfWorld(), 4.0F);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ public interface RotatedView {
|
|||
if (!hasTransform() || rotations.isEmpty()) {
|
||||
return y;
|
||||
}
|
||||
return y - ((y - rotations.peek()) * 2);
|
||||
|
||||
return (rotations.peek() * 2) - y;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import com.minelittlepony.unicopia.util.*;
|
|||
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBlockTags;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
|
@ -253,18 +252,6 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
|
||||
final MutableVector velocity = new MutableVector(entity.getVelocity());
|
||||
|
||||
if (isGravityNegative()) {
|
||||
velocity.y *= -1;
|
||||
}
|
||||
|
||||
if (isGravityNegative() && !entity.isSneaking() && entity.isInSneakingPose()) {
|
||||
float currentHeight = entity.getDimensions(entity.getPose()).height;
|
||||
float sneakingHeight = entity.getDimensions(EntityPose.STANDING).height;
|
||||
|
||||
entity.setPos(entity.getX(), entity.getY() + currentHeight - sneakingHeight, entity.getZ());
|
||||
entity.setPose(EntityPose.STANDING);
|
||||
}
|
||||
|
||||
FlightType type = recalculateFlightType();
|
||||
|
||||
boolean typeChanged = type != lastFlightType;
|
||||
|
@ -396,10 +383,6 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
velocity.z /= heavyness;
|
||||
}
|
||||
|
||||
if (isGravityNegative()) {
|
||||
velocity.y *= -1;
|
||||
}
|
||||
|
||||
entity.setVelocity(velocity.toImmutable());
|
||||
|
||||
if (isFlying() && !entity.isFallFlying() && !pony.getAcrobatics().isHanging() && pony.isClient()) {
|
||||
|
|
|
@ -5,9 +5,7 @@ import java.util.Optional;
|
|||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
|
@ -178,14 +176,6 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck, Equ
|
|||
}
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "travel(Lnet/minecraft/util/math/Vec3d;)V", constant = {
|
||||
@Constant(doubleValue = 0.08D),
|
||||
@Constant(doubleValue = 0.01D)
|
||||
})
|
||||
private double modifyGravity(double initial) {
|
||||
return get().getPhysics().calcGravity(initial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItemUsage(Hand hand, ItemStack stack, int time) {
|
||||
activeItemStack = stack;
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.*;
|
||||
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
||||
import com.minelittlepony.unicopia.item.enchantment.WantItNeedItEnchantment;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
|
@ -33,18 +32,6 @@ abstract class MixinMobEntity extends LivingEntity implements Equine.Container<C
|
|||
get().initAi(goalSelector, targetSelector);
|
||||
}
|
||||
|
||||
@Inject(method = "tickNewAi", at = @At("HEAD"))
|
||||
public void beforeTickAi(CallbackInfo into) {
|
||||
if (get().getPhysics().isGravityNegative()) {
|
||||
((RotatedView)getWorld()).pushRotation((int)getY());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickNewAi", at = @At("RETURN"))
|
||||
public void afterTickAi(CallbackInfo into) {
|
||||
((RotatedView)getWorld()).popRotation();
|
||||
}
|
||||
|
||||
@Inject(method = "prefersNewEquipment(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z",
|
||||
at = @At("HEAD"), cancellable = true)
|
||||
private void onPrefersNewEquipment(ItemStack newStack, ItemStack oldStack, CallbackInfoReturnable<Boolean> info) {
|
||||
|
|
|
@ -97,14 +97,6 @@ abstract class MixinPlayerEntity extends LivingEntity implements Equine.Containe
|
|||
get().getMotion().getDimensions().calculateActiveEyeHeight(dimensions).ifPresent(info::setReturnValue);
|
||||
}
|
||||
|
||||
/*
|
||||
@Inject(method = "getDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;",
|
||||
at = @At("RETURN"),
|
||||
cancellable = true)
|
||||
private void onGetDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
|
||||
get().getMotion().getDimensions().calculateDimensions().ifPresent(info::setReturnValue);
|
||||
}*/
|
||||
|
||||
@Redirect(method = "getDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.function.Supplier;
|
||||
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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
||||
import com.minelittlepony.unicopia.server.world.BlockDestructionManager;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
|
@ -22,20 +16,8 @@ abstract class MixinWorld implements WorldAccess, BlockDestructionManager.Source
|
|||
|
||||
private final Supplier<BlockDestructionManager> destructions = BlockDestructionManager.create((World)(Object)this);
|
||||
|
||||
private int recurseCount = 0;
|
||||
private final Stack<Integer> rotations = new Stack<>();
|
||||
private boolean mirrorEntityStatuses;
|
||||
|
||||
@Override
|
||||
public Stack<Integer> getRotations() {
|
||||
return rotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTransform() {
|
||||
return recurseCount <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirrorEntityStatuses(boolean enable) {
|
||||
mirrorEntityStatuses = enable;
|
||||
|
@ -52,17 +34,5 @@ abstract class MixinWorld implements WorldAccess, BlockDestructionManager.Source
|
|||
entity.handleStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("HEAD"))
|
||||
private BlockPos modifyBlockPos(BlockPos pos) {
|
||||
pos = applyRotation(pos);
|
||||
recurseCount = Math.max(0, recurseCount) + 1;
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Inject(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("RETURN"))
|
||||
public void onSetBlockState(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, CallbackInfoReturnable<Boolean> info) {
|
||||
recurseCount = Math.max(0, recurseCount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ abstract class MixinKeyboardInput extends Input {
|
|||
|
||||
movementSideways = -movementSideways;
|
||||
|
||||
if (player.asEntity().getAbilities().flying && !player.getPhysics().isFlying()) {
|
||||
/*if (player.asEntity().getAbilities().flying && !player.getPhysics().isFlying()) {
|
||||
tmp = jumping;
|
||||
jumping = sneaking;
|
||||
sneaking = tmp;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (EffectUtils.getAmplifier(MinecraftClient.getInstance().player, UEffects.PARALYSIS) > 1) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -21,7 +21,7 @@ abstract class MixinBrain<E extends LivingEntity> {
|
|||
Equine<?> eq = Equine.of(entity).orElse(null);
|
||||
|
||||
if (eq instanceof Living<?> && eq.getPhysics().isGravityNegative()) {
|
||||
((RotatedView)world).pushRotation((int)entity.getY());
|
||||
((RotatedView)world).pushRotation((int)(entity.getY() + entity.getHeight() * 0.5F));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
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;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.Equine;
|
||||
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
||||
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
@Mixin(ClientWorld.class)
|
||||
abstract class MixinClientWorld implements RotatedView {
|
||||
|
||||
@Inject(method = "tickEntity", at = @At("HEAD"))
|
||||
private void beforeTickEntity(Entity entity, CallbackInfo info) {
|
||||
if (entity instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
// pushRotation((int)(entity.getY() + entity.getHeight() * 0.5F));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickEntity", at = @At("RETURN"))
|
||||
private void afterTickEntity(Entity entity, CallbackInfo info) {
|
||||
if (entity instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
// popRotation();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||
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;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.Equine;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@Mixin(value = Entity.class, priority = 29000)
|
||||
abstract class MixinEntity {
|
||||
|
||||
// we invert y when moving
|
||||
@ModifyVariable(method = "move", at = @At("HEAD"), argsOnly = true)
|
||||
private Vec3d modifyMovement(Vec3d movement) {
|
||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
return movement.multiply(1, -1, 1);
|
||||
}
|
||||
return movement;
|
||||
}
|
||||
|
||||
// fix on ground check
|
||||
@Inject(method = "move", at = @At(value = "FIELD", target = "net/minecraft/entity/Entity.groundCollision:Z", shift = Shift.AFTER, ordinal = 0))
|
||||
private void onUpdateOnGroundFlag(MovementType movementType, Vec3d movement, CallbackInfo info) {
|
||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
eq.get().asEntity().groundCollision = eq.get().asEntity().verticalCollision && movement.y > 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
// invert jumping velocity so we can jump
|
||||
@Inject(method = "getJumpVelocityMultiplier", at = @At("RETURN"), cancellable = true)
|
||||
private void onGetJumpVelocityMultiplier(CallbackInfoReturnable<Float> info) {
|
||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
info.setReturnValue(-info.getReturnValue());
|
||||
}
|
||||
}
|
||||
|
||||
// invert offsets so it can properly find the block we're walking on
|
||||
@ModifyVariable(method = "getPosWithYOffset", at = @At("HEAD"), argsOnly = true)
|
||||
private float onGetPosWithYOffset(float offset) {
|
||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
return -(eq.get().asEntity().getHeight() + offset);
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
// fix sprinting particles
|
||||
@Inject(method = "spawnSprintingParticles", at = @At("HEAD"), cancellable = true)
|
||||
protected void spawnSprintingParticles(CallbackInfo info) {
|
||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
eq.get().getPhysics().spawnSprintingParticles();
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
// invert check for walking up a step
|
||||
@ModifyVariable(
|
||||
method = "adjustMovementForCollisions(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Box;Lnet/minecraft/world/World;Ljava/util/List;)Lnet/minecraft/util/math/Vec3d;",
|
||||
at = @At("HEAD"),
|
||||
argsOnly = true)
|
||||
|
||||
private static Vec3d modifyMovementForStepheight(Vec3d movement, @Nullable Entity entity) {
|
||||
if (entity != null && movement.getY() == entity.getStepHeight()) {
|
||||
return movement.multiply(1, -1, 1);
|
||||
}
|
||||
return movement;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import com.minelittlepony.unicopia.entity.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
abstract class MixinLivingEntity extends Entity implements Equine.Container<Living<?>> {
|
||||
|
||||
private MixinLivingEntity() { super(null, null); }
|
||||
|
||||
@ModifyConstant(method = "travel(Lnet/minecraft/util/math/Vec3d;)V", constant = {
|
||||
@Constant(doubleValue = 0.08D),
|
||||
@Constant(doubleValue = 0.01D)
|
||||
})
|
||||
private double modifyGravity(double initial) {
|
||||
return Math.abs(get().getPhysics().calcGravity(initial));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
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;
|
||||
import com.minelittlepony.unicopia.entity.*;
|
||||
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
|
||||
@Mixin(MobEntity.class)
|
||||
abstract class MixinMobEntity extends LivingEntity implements Equine.Container<Creature> {
|
||||
private MixinMobEntity() { super(null, null); }
|
||||
|
||||
@Inject(method = "tickNewAi", at = @At("HEAD"))
|
||||
public void beforeTickAi(CallbackInfo into) {
|
||||
if (get().getPhysics().isGravityNegative()) {
|
||||
((RotatedView)getWorld()).pushRotation((int)(getY() + getHeight() * 0.5F));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickNewAi", at = @At("RETURN"))
|
||||
public void afterTickAi(CallbackInfo into) {
|
||||
((RotatedView)getWorld()).popRotation();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
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;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.Equine;
|
||||
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
abstract class MixinServerWorld implements RotatedView {
|
||||
|
||||
@Inject(method = "tickEntity", at = @At("HEAD"))
|
||||
private void beforeTickEntity(Entity entity, CallbackInfo info) {
|
||||
if (entity instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
// pushRotation((int)(entity.getY() + entity.getHeight() * 0.5F));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickEntity", at = @At("RETURN"))
|
||||
private void afterTickEntity(Entity entity, CallbackInfo info) {
|
||||
if (entity instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
// popRotation();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||
import net.minecraft.client.sound.Source;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@Mixin(Source.class)
|
||||
abstract class MixinSoundSource {
|
||||
@ModifyVariable(method = "setPosition", at = @At("HEAD"), argsOnly = true)
|
||||
private Vec3d modifyPosition(Vec3d pos) {
|
||||
return UnicopiaClient.getAdjustedSoundPosition(pos);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
import java.util.Stack;
|
||||
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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
@Mixin(World.class)
|
||||
abstract class MixinWorld implements WorldAccess, RotatedView {
|
||||
|
||||
private int recurseCount = 0;
|
||||
private final Stack<Integer> rotations = new Stack<>();
|
||||
|
||||
@Override
|
||||
public Stack<Integer> getRotations() {
|
||||
return rotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTransform() {
|
||||
return recurseCount <= 0;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("HEAD"))
|
||||
private BlockPos modifyBlockPos(BlockPos pos) {
|
||||
pos = applyRotation(pos);
|
||||
recurseCount = Math.max(0, recurseCount) + 1;
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Inject(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("RETURN"))
|
||||
public void onSetBlockState(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, CallbackInfoReturnable<Boolean> info) {
|
||||
recurseCount = Math.max(0, recurseCount - 1);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
package com.minelittlepony.unicopia.mixin.gravity;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
|
@ -13,7 +13,6 @@
|
|||
"MixinBlockEntityType",
|
||||
"MixinBlockItem",
|
||||
"MixinBoatEntity",
|
||||
"MixinBrain",
|
||||
"MixinChunkBlockLightProvider",
|
||||
"MutableBlockLightStorage",
|
||||
"MixinDamageSource",
|
||||
|
@ -53,8 +52,14 @@
|
|||
"MixinVanillaBiomeParameters",
|
||||
"MixinWardenEntity",
|
||||
"MixinWorld",
|
||||
"MixinWorldChunk",
|
||||
"PointOfInterestTypesAccessor",
|
||||
"gravity.MixinBrain",
|
||||
"gravity.MixinEntity",
|
||||
"gravity.MixinLivingEntity",
|
||||
"gravity.MixinMobEntity",
|
||||
"gravity.MixinWorld",
|
||||
"gravity.MixinServerWorld",
|
||||
"gravity.MixinWorldChunk",
|
||||
"trinkets.MixinTrinketSurvivalSlot",
|
||||
"trinkets.MixinTrinketItem",
|
||||
"trinkets.MixinTrinketInventory",
|
||||
|
@ -88,7 +93,9 @@
|
|||
"client.MixinWorldRenderer",
|
||||
"client.sodium.MixinSodiumWorldRenderer",
|
||||
"client.minelp.MixinPonyPosture",
|
||||
"trinkets.MixinTrinketCreativeSlot"
|
||||
"trinkets.MixinTrinketCreativeSlot",
|
||||
"gravity.MixinClientWorld",
|
||||
"gravity.MixinSoundSource"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue