Search in sources :

Example 11 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project BleachHack by BleachDrinker420.

the class NotebotUtils method play.

private static void play(SoundEvent sound, float pitch) {
    MinecraftClient mc = MinecraftClient.getInstance();
    Vec3d vec = mc.player == null ? Vec3d.ZERO : mc.player.getPos();
    mc.getSoundManager().play(new PositionedSoundInstance(sound, SoundCategory.RECORDS, 3.0F, pitch, vec.x, vec.y, vec.z));
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) PositionedSoundInstance(net.minecraft.client.sound.PositionedSoundInstance) Vec3d(net.minecraft.util.math.Vec3d)

Example 12 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project fabricskyboxes by AMereBagatelle.

the class AbstractSkybox method checkBiomes.

/**
 * @return Whether the current biomes and dimensions are valid for this skybox.
 */
protected boolean checkBiomes() {
    MinecraftClient client = MinecraftClient.getInstance();
    Objects.requireNonNull(client.world);
    Objects.requireNonNull(client.player);
    if (worlds.isEmpty() || worlds.contains(client.world.getRegistryKey().getValue())) {
        return biomes.isEmpty() || biomes.contains(client.world.getRegistryManager().get(Registry.BIOME_KEY).getId(client.world.getBiome(client.player.getBlockPos()).value()));
    }
    return false;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient)

Example 13 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project fabric by FabricMC.

the class MixinMinecraftClient method modifyItemPick.

@ModifyVariable(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSlotWithStack(Lnet/minecraft/item/ItemStack;)I"), method = "doItemPick", ordinal = 0)
public ItemStack modifyItemPick(ItemStack stack) {
    MinecraftClient client = (MinecraftClient) (Object) this;
    ItemStack result = ClientPickBlockApplyCallback.EVENT.invoker().pick(client.player, client.hitResult, stack);
    fabric_itemPickCancelled = result.isEmpty();
    return result;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Example 14 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project fabric by FabricMC.

the class MixinMinecraftClient method fabric_emulateOldPick.

@SuppressWarnings("deprecation")
private ItemStack fabric_emulateOldPick() {
    MinecraftClient client = (MinecraftClient) (Object) this;
    ClientPickBlockCallback.Container ctr = new ClientPickBlockCallback.Container(ItemStack.EMPTY);
    ClientPickBlockCallback.EVENT.invoker().pick(client.player, client.hitResult, ctr);
    return ctr.getStack();
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ClientPickBlockCallback(net.fabricmc.fabric.api.event.client.player.ClientPickBlockCallback)

Example 15 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project fabric by FabricMC.

the class MixinMinecraftClient method fabric_doItemPickWrapper.

@Inject(at = @At("HEAD"), method = "doItemPick", cancellable = true)
private void fabric_doItemPickWrapper(CallbackInfo info) {
    MinecraftClient client = (MinecraftClient) (Object) this;
    // Do a "best effort" emulation of the old events.
    ItemStack stack = ClientPickBlockGatherCallback.EVENT.invoker().pick(client.player, client.hitResult);
    // TODO: Remove in 0.3.0
    if (stack.isEmpty()) {
        stack = fabric_emulateOldPick();
    }
    if (stack.isEmpty()) {
    // fall through
    } else {
        info.cancel();
        // I don't like that we clone vanilla logic here, but it's our best bet for now.
        PlayerInventory playerInventory = client.player.inventory;
        if (client.player.abilities.creativeMode && Screen.hasControlDown() && client.hitResult.getType() == HitResult.Type.BLOCK) {
            BlockEntity be = client.world.getBlockEntity(((BlockHitResult) client.hitResult).getBlockPos());
            if (be != null) {
                stack = addBlockEntityNbt(stack, be);
            }
        }
        stack = ClientPickBlockApplyCallback.EVENT.invoker().pick(client.player, client.hitResult, stack);
        if (stack.isEmpty()) {
            return;
        }
        if (client.player.abilities.creativeMode) {
            playerInventory.addPickBlock(stack);
            client.interactionManager.clickCreativeStack(client.player.getStackInHand(Hand.MAIN_HAND), 36 + playerInventory.selectedSlot);
        } else {
            int slot = playerInventory.getSlotWithStack(stack);
            if (slot >= 0) {
                if (PlayerInventory.isValidHotbarIndex(slot)) {
                    playerInventory.selectedSlot = slot;
                } else {
                    client.interactionManager.pickFromInventory(slot);
                }
            }
        }
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) PlayerInventory(net.minecraft.entity.player.PlayerInventory) ItemStack(net.minecraft.item.ItemStack) BlockEntity(net.minecraft.block.entity.BlockEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

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