Search in sources :

Example 21 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Terracraft by SimplyCmd.

the class MirrorItem method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
    if (// Get server player
    playerEntity instanceof ServerPlayerEntity)
        // Get server player
        player = (ServerPlayerEntity) playerEntity;
    else // Get client player
    if (playerEntity instanceof ClientPlayerEntity)
        clientPlayer = (ClientPlayerEntity) playerEntity;
    if (!tick) {
        final MinecraftClient client = MinecraftClient.getInstance();
        client.particleManager.addEmitter(clientPlayer, ParticleTypes.END_ROD, 30);
        client.gameRenderer.showFloatingItem(this.getDefaultStack());
        player.getWorld().playSound(playerEntity, playerEntity.getBlockPos(), SoundRegistry.ITEM_MAGIC_MIRROR_USE_EVENT, SoundCategory.PLAYERS, 1f, 1f);
        tick = true;
        return TypedActionResult.success(playerEntity.getStackInHand(hand));
    } else {
        return TypedActionResult.fail(playerEntity.getStackInHand(hand));
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 22 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Client by MatHax.

the class DropCommand method drop.

private int drop(PlayerConsumer consumer) throws CommandSyntaxException {
    ClientPlayerEntity player = mc.player;
    assert player != null;
    if (player.isSpectator())
        throw NOT_SPECTATOR.create();
    consumer.accept(player);
    return SINGLE_SUCCESS;
}
Also used : ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 23 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Skyblocker by LifeIsAParadox.

the class ChatHudListenerMixin method onMessage.

@Inject(method = "onChatMessage", at = @At("HEAD"), cancellable = true)
public void onMessage(MessageType messageType, Text message, UUID senderUuid, CallbackInfo ci) {
    if (!Utils.isOnSkyblock)
        return;
    String asString = message.getString();
    ChatFilterResult result = ChatMessageListener.EVENT.invoker().onMessage(message, asString);
    switch(result) {
        case ACTION_BAR:
            ClientPlayerEntity player = client.player;
            // Couldn't have received original message if client was null
            assert player != null;
            player.sendMessage(message, true);
        case FILTER:
            ci.cancel();
    }
}
Also used : ChatFilterResult(me.xmrvizzy.skyblocker.chat.ChatFilterResult) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 24 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Insane by 16underscore.

the class Killaura method lookAtTarget.

private void lookAtTarget(LivingEntity le) {
    ClientPlayerEntity p = mc.player;
    Vec3d pPos = p.getPos(), lePos = le.getPos();
    double deltaX = lePos.getX() - pPos.getX(), deltaY = (lePos.getY() + le.getEyeHeight(le.getPose())) - (pPos.getY() + p.getEyeHeight(p.getPose())), deltaZ = lePos.getZ() - pPos.getZ(), distanceXZ = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
    float pitch = MathHelper.wrapDegrees((float) Math.toDegrees(-MathHelper.atan2(deltaY, distanceXZ))), yaw = MathHelper.wrapDegrees((float) Math.toDegrees(MathHelper.atan2(deltaZ, deltaX)) - 90F);
    p.setPitch(pitch);
    p.setYaw(yaw);
    mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, p.isOnGround()));
    mc.cameraEntity.setPitch(p.prevPitch);
    mc.cameraEntity.setYaw(p.prevYaw);
}
Also used : PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d)

Example 25 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Skyblocker by SkyblockerMod.

the class StatusBarTracker method updateHealth.

private void updateHealth(Matcher m) {
    int value = parseInt(m, 1);
    int max = parseInt(m, 2);
    int overflow = 0;
    ClientPlayerEntity player = null;
    try {
        player = MinecraftClient.getInstance().player;
    }// Is triggered by tests. Couldn't come up with a better solution.
     catch (NullPointerException ignored) {
    }
    if (player != null) {
        int hp = (int) (player.getHealth() * max / player.getMaxHealth());
        overflow = value - hp;
        value = hp;
    } else if (value > max) {
        overflow = value - max;
        value = max;
    }
    if (overflow > max)
        overflow = max;
    this.health = new Resource(value, max, overflow);
}
Also used : ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Aggregations

ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)126 Vec3d (net.minecraft.util.math.Vec3d)20 ItemStack (net.minecraft.item.ItemStack)19 Entity (net.minecraft.entity.Entity)15 MinecraftClient (net.minecraft.client.MinecraftClient)14 ClientWorld (net.minecraft.client.world.ClientWorld)13 LivingEntity (net.minecraft.entity.LivingEntity)13 BlockPos (net.minecraft.util.math.BlockPos)13 Inject (org.spongepowered.asm.mixin.injection.Inject)13 PlayerEntity (net.minecraft.entity.player.PlayerEntity)11 Stream (java.util.stream.Stream)10 Identifier (net.minecraft.util.Identifier)10 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)9 PlayerInventory (net.minecraft.entity.player.PlayerInventory)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