Search in sources :

Example 51 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class CustomMobSpawnPacket method spawn.

@Environment(EnvType.CLIENT)
private static void spawn(int id, UUID uuid, int entityTypeId, double x, double y, double z, float yaw, float pitch, float headYaw, float velocityX, float velocityY, float velocityZ, PacketByteBuf additional) {
    MinecraftClient client = MinecraftClient.getInstance();
    ClientWorld world = client.world;
    if (world == null) {
        return;
    }
    LivingEntity livingEntity = (LivingEntity) EntityType.createInstanceFromId(entityTypeId, world);
    if (livingEntity instanceof CustomPacketEntity) {
        livingEntity.updateTrackedPosition(x, y, z);
        livingEntity.bodyYaw = headYaw;
        livingEntity.headYaw = headYaw;
        livingEntity.setEntityId(id);
        livingEntity.setUuid(uuid);
        livingEntity.updatePositionAndAngles(x, y, z, yaw, pitch);
        livingEntity.setVelocity(velocityX, velocityY, velocityZ);
        ((CustomPacketEntity) livingEntity).readCustomPacket(additional);
        world.addEntity(id, livingEntity);
    } else {
        LOGGER.warn("Skipping Entity with id {}", entityTypeId);
    }
    if (additional.refCnt() > 0) {
        additional.release();
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) MinecraftClient(net.minecraft.client.MinecraftClient) ClientWorld(net.minecraft.client.world.ClientWorld) CustomPacketEntity(net.sistr.littlemaidmodelloader.network.util.CustomPacketEntity) Environment(net.fabricmc.api.Environment)

Example 52 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project Liminal-Library by LudoCrypt.

the class ReverbFilter method update.

public static void update(SoundInstance soundInstance, int sourceID) {
    MinecraftClient client = MinecraftClient.getInstance();
    if (!(ReverbSettings.shouldIgnore(soundInstance.getId()) || client == null || client.world == null)) {
        Optional<ReverbSettings> reverb = ((DimensionTypeAccess) client.world.getDimension()).getLiminalEffects().getReverb();
        if (reverb.isPresent()) {
            for (int i = 0; i < 2; i++) {
                AL11.alSourcei(sourceID, EXTEfx.AL_DIRECT_FILTER, 0);
                AL11.alSource3i(sourceID, EXTEfx.AL_AUXILIARY_SEND_FILTER, update(soundInstance, reverb.get()) ? slot : 0, 0, 0);
                int error = AL11.alGetError();
                if (error == AL11.AL_NO_ERROR) {
                    break;
                } else {
                    LOGGER.warn("OpenAl Error {}", error);
                }
            }
        }
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient)

Example 53 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project Enchanted-Bionics by Bubblie01.

the class FunnyItem method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (world.isClient) {
        MinecraftClient client = MinecraftClient.getInstance();
        EntityRenderer<? super AbstractClientPlayerEntity> renderer = client.getEntityRenderDispatcher().getRenderer(client.player);
        PlayerEntityModel<AbstractClientPlayerEntity> playerEntityModel = ((PlayerEntityRenderer) (renderer)).getModel();
        this.playerEntityModel = playerEntityModel;
        (((PlayerLimbInterface) playerEntityModel)).setSpecificVisible(false, EntityModelPartNames.LEFT_ARM);
    }
    return super.use(world, user, hand);
}
Also used : PlayerEntityRenderer(net.minecraft.client.render.entity.PlayerEntityRenderer) MinecraftClient(net.minecraft.client.MinecraftClient) AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity)

Example 54 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project Enchanted-Bionics by Bubblie01.

the class FunnierItem method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (world.isClient) {
        MinecraftClient client = MinecraftClient.getInstance();
        EntityRenderer<? super AbstractClientPlayerEntity> renderer = client.getEntityRenderDispatcher().getRenderer(client.player);
        PlayerEntityModel<AbstractClientPlayerEntity> playerEntityModel = ((PlayerEntityRenderer) (renderer)).getModel();
        this.playerEntityModel = playerEntityModel;
        (((PlayerLimbInterface) playerEntityModel)).setSpecificVisible(true, EntityModelPartNames.LEFT_ARM);
    }
    return super.use(world, user, hand);
}
Also used : PlayerEntityRenderer(net.minecraft.client.render.entity.PlayerEntityRenderer) MinecraftClient(net.minecraft.client.MinecraftClient) AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity)

Example 55 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project MCDungeonsWeapons by chronosacaria.

the class CombatEventHandler method checkForOffHandAttack.

public static void checkForOffHandAttack() {
    MinecraftClient mc = MinecraftClient.getInstance();
    PlayerEntity player = mc.player;
    HitResult hitResult = mc.crosshairTarget;
    if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().currentScreen == null && !MinecraftClient.getInstance().isPaused() && player != null && !player.isBlocking()) {
        ItemStack offhand = player.getOffHandStack();
        if (offhand.getItem() instanceof IOffhandAttack) {
            if (hitResult instanceof EntityHitResult) {
                if (mc.crosshairTarget != null && mc.interactionManager != null) {
                    mc.interactionManager.attackEntity(player, ((EntityHitResult) mc.crosshairTarget).getEntity());
                }
            }
        }
    }
}
Also used : HitResult(net.minecraft.util.hit.HitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) IOffhandAttack(chronosacaria.mcdw.api.interfaces.IOffhandAttack) MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack) EntityHitResult(net.minecraft.util.hit.EntityHitResult) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)84 ItemStack (net.minecraft.item.ItemStack)12 Text (net.minecraft.text.Text)7 Identifier (net.minecraft.util.Identifier)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 TextRenderer (net.minecraft.client.font.TextRenderer)5 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Entity (net.minecraft.entity.Entity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)3 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3