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));
}
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;
}
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;
}
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();
}
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);
}
}
}
}
}
Aggregations