Search in sources :

Example 16 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project BedrockIfy by juancarloscp52.

the class ReachAroundPlacement method checkReachAroundAndExecute.

public void checkReachAroundAndExecute(Hand hand, ItemStack itemStack) {
    ClientPlayerEntity player = client.player;
    if (player == null || client.interactionManager == null)
        return;
    int count = itemStack.getCount();
    Vector3f facing = player.getHorizontalFacing().getUnitVector();
    if (canReachAround()) {
        BlockHitResult blockHitResult;
        if (isNonFullBlock()) {
            blockHitResult = new BlockHitResult(player.getPos().add(facing.getX(), facing.getY() - 1, facing.getZ()), Direction.fromVector((int) -facing.getX(), 0, (int) -facing.getZ()), player.getBlockPos().offset(player.getHorizontalFacing()), false);
        } else {
            blockHitResult = new BlockHitResult(player.getPos().add(facing.getX(), facing.getY(), facing.getZ()), Direction.fromVector((int) -facing.getX(), 0, (int) -facing.getZ()), player.getBlockPos().down().offset(player.getHorizontalFacing()), false);
        }
        ActionResult result = client.interactionManager.interactBlock(player, client.world, hand, blockHitResult);
        if (result.isAccepted()) {
            if (result.shouldSwingHand()) {
                player.swingHand(hand);
                if (!itemStack.isEmpty() && (itemStack.getCount() != count || client.interactionManager.hasCreativeInventory())) {
                    client.gameRenderer.firstPersonRenderer.resetEquipProgress(hand);
                }
            }
        }
    }
}
Also used : ActionResult(net.minecraft.util.ActionResult) Vector3f(net.minecraft.client.util.math.Vector3f) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) BlockHitResult(net.minecraft.util.hit.BlockHitResult)

Example 17 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project ImmersivePortalsMod by qouteall.

the class MyCommandClient method listNearbyPortals.

private static int listNearbyPortals(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    ServerPlayerEntity playerServer = context.getSource().getPlayer();
    ClientPlayerEntity playerClient = MinecraftClient.getInstance().player;
    McHelper.serverLog(playerServer, "Server Portals");
    McHelper.serverLog(playerServer, Helper.myToString(McHelper.getEntitiesNearby(playerServer, Portal.class, 64)));
    McHelper.serverLog(playerServer, "Client Portals");
    McHelper.serverLog(playerServer, Helper.myToString(McHelper.getEntitiesNearby(playerClient, Portal.class, 64)));
    return 0;
}
Also used : ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 18 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project ImmersivePortalsMod by qouteall.

the class ClientTeleportationManager method teleportPlayer.

private void teleportPlayer(Portal portal) {
    if (isTeleportingFrequently()) {
        Helper.err("The Player is Teleporting Frequently");
    }
    lastTeleportGameTime = tickTimeForTeleportation;
    ClientPlayerEntity player = mc.player;
    DimensionType toDimension = portal.dimensionTo;
    if (mc.player.hasPassengers() || mc.player.hasVehicle()) {
        return;
    }
    Vec3d oldPos = player.getPos();
    Vec3d newPos = portal.applyTransformationToPoint(oldPos);
    Vec3d newLastTickPos = portal.applyTransformationToPoint(McHelper.lastTickPosOf(player));
    ClientWorld fromWorld = mc.world;
    DimensionType fromDimension = fromWorld.dimension.getType();
    if (fromDimension != toDimension) {
        ClientWorld toWorld = CGlobal.clientWorldLoader.getOrCreateFakedWorld(toDimension);
        changePlayerDimension(player, fromWorld, toWorld, newPos);
    }
    player.setPosition(newPos.x, newPos.y, newPos.z);
    Helper.setPosAndLastTickPos(player, newPos, newLastTickPos);
    player.networkHandler.sendPacket(MyNetworkClient.createCtsTeleport(fromDimension, oldPos, portal.getUuid()));
    amendChunkEntityStatus(player);
// slowDownIfTooFast(player, 0.5);
}
Also used : DimensionType(net.minecraft.world.dimension.DimensionType) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) ClientWorld(net.minecraft.client.world.ClientWorld) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d)

Example 19 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Hypnotic-Client by Hypnotic-Development.

the class HeldItemRendererMixin method updateHeldItems1.

@Inject(method = "updateHeldItems", at = @At("HEAD"), cancellable = true)
public void updateHeldItems1(CallbackInfo ci) {
    EventVisualCooldown event = new EventVisualCooldown();
    event.call();
    if (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled())
        event.setCancelled(true);
    if (event.isCancelled()) {
        ci.cancel();
        this.prevEquipProgressMainHand = this.equipProgressMainHand;
        this.prevEquipProgressOffHand = this.equipProgressOffHand;
        ClientPlayerEntity clientPlayerEntity = this.client.player;
        ItemStack itemStack = clientPlayerEntity.getMainHandStack();
        ItemStack itemStack2 = clientPlayerEntity.getOffHandStack();
        if (ItemStack.areEqual(this.mainHand, itemStack)) {
            this.mainHand = itemStack;
        }
        if (ItemStack.areEqual(this.offHand, itemStack2)) {
            this.offHand = itemStack2;
        }
        if (clientPlayerEntity.isRiding()) {
            this.equipProgressMainHand = MathHelper.clamp(this.equipProgressMainHand - 0.4F, 0.0F, 1.0F);
            this.equipProgressOffHand = MathHelper.clamp(this.equipProgressOffHand - 0.4F, 0.0F, 1.0F);
        } else {
            // \/ This part here is what changed, it used to calculate with attack progress
            this.equipProgressMainHand += MathHelper.clamp((this.mainHand == itemStack ? 1 : 0.0F) - this.equipProgressMainHand, -0.4F, 0.4F);
            this.equipProgressOffHand += MathHelper.clamp((float) (this.offHand == itemStack2 ? 1 : 0) - this.equipProgressOffHand, -0.4F, 0.4F);
        }
        if (this.equipProgressMainHand < 0.1F) {
            this.mainHand = itemStack;
        }
        if (this.equipProgressOffHand < 0.1F) {
            this.offHand = itemStack2;
        }
    }
}
Also used : OldBlock(dev.hypnotic.module.render.OldBlock) AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) EventVisualCooldown(dev.hypnotic.event.events.EventVisualCooldown) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 20 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project JexClient by DustinRepo.

the class MixinHeldItemRenderer method updateHeldItems1.

@Inject(method = "updateHeldItems", at = @At("HEAD"), cancellable = true)
public void updateHeldItems1(CallbackInfo ci) {
    if (((EventVisualCooldown) new EventVisualCooldown().run()).isCancelled()) {
        ci.cancel();
        this.prevEquipProgressMainHand = this.equipProgressMainHand;
        this.prevEquipProgressOffHand = this.equipProgressOffHand;
        ClientPlayerEntity clientPlayerEntity = this.client.player;
        ItemStack itemStack = clientPlayerEntity.getMainHandStack();
        ItemStack itemStack2 = clientPlayerEntity.getOffHandStack();
        if (ItemStack.areEqual(this.mainHand, itemStack)) {
            this.mainHand = itemStack;
        }
        if (ItemStack.areEqual(this.offHand, itemStack2)) {
            this.offHand = itemStack2;
        }
        if (clientPlayerEntity.isRiding()) {
            this.equipProgressMainHand = MathHelper.clamp(this.equipProgressMainHand - 0.4F, 0.0F, 1.0F);
            this.equipProgressOffHand = MathHelper.clamp(this.equipProgressOffHand - 0.4F, 0.0F, 1.0F);
        } else {
            // \/ This part here is what changed, it used to calculate with attack progress
            this.equipProgressMainHand += MathHelper.clamp((this.mainHand == itemStack ? 1 : 0.0F) - this.equipProgressMainHand, -0.4F, 0.4F);
            this.equipProgressOffHand += MathHelper.clamp((float) (this.offHand == itemStack2 ? 1 : 0) - this.equipProgressOffHand, -0.4F, 0.4F);
        }
        if (this.equipProgressMainHand < 0.1F) {
            this.mainHand = itemStack;
        }
        if (this.equipProgressOffHand < 0.1F) {
            this.offHand = itemStack2;
        }
    }
}
Also used : AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) EventVisualCooldown(me.dustin.jex.event.render.EventVisualCooldown) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)122 Vec3d (net.minecraft.util.math.Vec3d)19 ItemStack (net.minecraft.item.ItemStack)18 Entity (net.minecraft.entity.Entity)14 LivingEntity (net.minecraft.entity.LivingEntity)13 Identifier (net.minecraft.util.Identifier)13 Inject (org.spongepowered.asm.mixin.injection.Inject)13 MinecraftClient (net.minecraft.client.MinecraftClient)12 BlockPos (net.minecraft.util.math.BlockPos)12 ClientWorld (net.minecraft.client.world.ClientWorld)11 PlayerEntity (net.minecraft.entity.player.PlayerEntity)11 Stream (java.util.stream.Stream)10 Hand (net.minecraft.util.Hand)10 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)9 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)8 ArrayList (java.util.ArrayList)8 AmbientEntity (net.minecraft.entity.mob.AmbientEntity)8 WaterCreatureEntity (net.minecraft.entity.mob.WaterCreatureEntity)8 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)7 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)7