added placementRotationFix mixins

This commit is contained in:
DeadlyMC committed 2019-06-01 21:07:58 +05:30
1 parent 4ec6e0e03e
commit db091d68d7
5 files changed
+57 -1

No files matched your search

@@ -0,0 +1,26 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.utils.IEntity;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Direction;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Direction.class)
public abstract class DirectionMixin
{
@Redirect(method = "getEntityFacingOrder", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw(F)F"))
private static float ifGetYaw(Entity entity, float float_1)
{
if (!CarpetSettings.getBool("placementRotationFix"))
{
return -entity.getYaw(1.0F) * 0.017453292F;
}
else
{
return -((IEntity) entity).getMainYaw(1.0F) * 0.017453292F;
}
}
}
@@ -0,0 +1,22 @@
package carpet.mixins;
import carpet.utils.IEntity;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(Entity.class)
public abstract class EntityMixin implements IEntity
{
@Shadow
public float yaw;
@Shadow
public float prevYaw;
public float getMainYaw(float partialTicks)
{
return partialTicks == 1.0F ? this.yaw : MathHelper.lerp(partialTicks, this.prevYaw, this.yaw);
}
}