improved handling of fake players in boats and when pushed by slimeblocks. Fixes #507
This commit is contained in:
1 parent
a6286850b4
commit
9633b402b4
4 files changed
+86
-30
No files matched your search
@@ -1,10 +1,16 @@
|
|||||||
package carpet.mixins;
|
package carpet.mixins;
|
||||||
|
|
||||||
import carpet.fakes.EntityInterface;
|
import carpet.fakes.EntityInterface;
|
||||||
|
import carpet.patches.EntityPlayerMPFake;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
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(Entity.class)
|
@Mixin(Entity.class)
|
||||||
public abstract class EntityMixin implements EntityInterface
|
public abstract class EntityMixin implements EntityInterface
|
||||||
@@ -15,8 +21,18 @@ public abstract class EntityMixin implements EntityInterface
|
|||||||
@Shadow
|
@Shadow
|
||||||
public float prevYaw;
|
public float prevYaw;
|
||||||
|
|
||||||
|
@Shadow public @Nullable abstract Entity getPrimaryPassenger();
|
||||||
|
|
||||||
|
@Shadow public World world;
|
||||||
|
|
||||||
public float getMainYaw(float partialTicks)
|
public float getMainYaw(float partialTicks)
|
||||||
{
|
{
|
||||||
return partialTicks == 1.0F ? this.yaw : MathHelper.lerp(partialTicks, this.prevYaw, this.yaw);
|
return partialTicks == 1.0F ? this.yaw : MathHelper.lerp(partialTicks, this.prevYaw, this.yaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isLogicalSideForUpdatingMovement", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void isFakePlayer(CallbackInfoReturnable<Boolean> cir)
|
||||||
|
{
|
||||||
|
if (getPrimaryPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!world.isClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package carpet.mixins;
|
|
||||||
|
|
||||||
import carpet.CarpetSettings;
|
|
||||||
import net.minecraft.block.entity.PistonBlockEntity;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
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.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(PistonBlockEntity.class)
|
|
||||||
public class PistonBlockEntity_creativeNoClipMixin
|
|
||||||
{
|
|
||||||
@Inject(method = "method_23672", at = @At("HEAD"), cancellable = true)
|
|
||||||
private static void dontPushSpectators(Direction direction, Entity entity, double d, Direction direction2, CallbackInfo ci)
|
|
||||||
{
|
|
||||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) ci.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(DDD)V"))
|
|
||||||
private void ignoreAccel(Entity entity, double x, double y, double z)
|
|
||||||
{
|
|
||||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) return;
|
|
||||||
entity.setVelocity(x,y,z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.CarpetSettings;
|
||||||
|
import carpet.patches.EntityPlayerMPFake;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.entity.PistonBlockEntity;
|
||||||
|
import net.minecraft.block.piston.PistonBehavior;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
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.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(PistonBlockEntity.class)
|
||||||
|
public abstract class PistonBlockEntity_playerHandlingMixin
|
||||||
|
{
|
||||||
|
@Shadow private BlockState pushedBlock;
|
||||||
|
|
||||||
|
@Shadow public abstract Direction getMovementDirection();
|
||||||
|
|
||||||
|
@Inject(method = "method_23672", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void dontPushSpectators(Direction direction, Entity entity, double d, Direction direction2, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) ci.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(DDD)V"))
|
||||||
|
private void ignoreAccel(Entity entity, double x, double y, double z)
|
||||||
|
{
|
||||||
|
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) return;
|
||||||
|
entity.setVelocity(x,y,z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "pushEntities", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/entity/Entity;getPistonBehavior()Lnet/minecraft/block/piston/PistonBehavior;"
|
||||||
|
))
|
||||||
|
private PistonBehavior moveFakePlayers(Entity entity)
|
||||||
|
{
|
||||||
|
if (entity instanceof EntityPlayerMPFake && pushedBlock.isOf(Blocks.SLIME_BLOCK))
|
||||||
|
{
|
||||||
|
Vec3d vec3d = entity.getVelocity();
|
||||||
|
double e = vec3d.x;
|
||||||
|
double f = vec3d.y;
|
||||||
|
double g = vec3d.z;
|
||||||
|
Direction direction = getMovementDirection();
|
||||||
|
switch(direction.getAxis()) {
|
||||||
|
case X:
|
||||||
|
e = (double)direction.getOffsetX();
|
||||||
|
break;
|
||||||
|
case Y:
|
||||||
|
f = (double)direction.getOffsetY();
|
||||||
|
break;
|
||||||
|
case Z:
|
||||||
|
g = (double)direction.getOffsetZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setVelocity(e, f, g);
|
||||||
|
}
|
||||||
|
return entity.getPistonBehavior();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
"WorldChunk_movableTEMixin",
|
"WorldChunk_movableTEMixin",
|
||||||
"PistonHandler_customStickyMixin",
|
"PistonHandler_customStickyMixin",
|
||||||
"PlayerEntity_creativeNoClipMixin",
|
"PlayerEntity_creativeNoClipMixin",
|
||||||
"PistonBlockEntity_creativeNoClipMixin",
|
"PistonBlockEntity_playerHandlingMixin",
|
||||||
"BlockItem_creativeNoClipMixin",
|
"BlockItem_creativeNoClipMixin",
|
||||||
"LivingEntity_creativeFlyMixin"
|
"LivingEntity_creativeFlyMixin"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user