Java Code Examples for net.fabricmc.api.EnvType#CLIENT

The following examples show how to use net.fabricmc.api.EnvType#CLIENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WitchWaterBubbleColumnBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) {
	double x = pos.getX();
	double y = pos.getY();
	double z = pos.getZ();
	if (state.get(DRAG)) {
		world.addImportantParticle(ParticleTypes.CURRENT_DOWN, x + 0.5D, y + 0.8D, z, 0.0D, 0.0D, 0.0D);
		if (rand.nextInt(200) == 0) {
			world.playSound(x, y, z, SoundEvents.BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
		}
	} else {
		world.addImportantParticle(ParticleTypes.BUBBLE_COLUMN_UP, x + 0.5D, y, z + 0.5D, 0.0D, 0.04D, 0.0D);
		world.addImportantParticle(ParticleTypes.BUBBLE_COLUMN_UP, x + (double) rand.nextFloat(), y + (double) rand.nextFloat(), z + (double) rand.nextFloat(), 0.0D, 0.04D, 0.0D);
		if (rand.nextInt(200) == 0) {
			world.playSound(x, y, z, SoundEvents.BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
		}
	}
}
 
Example 2
Source File: MinecraftGameProvider.java    From fabric-loader with Apache License 2.0 6 votes vote down vote up
@Override
public boolean locateGame(EnvType envType, ClassLoader loader) {
	this.envType = envType;
	List<String> entrypointClasses;

	if (envType == EnvType.CLIENT) {
		entrypointClasses = Arrays.asList("net.minecraft.client.main.Main", "net.minecraft.client.MinecraftApplet", "com.mojang.minecraft.MinecraftApplet");
	} else {
		entrypointClasses = Arrays.asList("net.minecraft.server.Main", "net.minecraft.server.MinecraftServer", "com.mojang.minecraft.server.MinecraftServer");
	}

	Optional<GameProviderHelper.EntrypointResult> entrypointResult = GameProviderHelper.findFirstClass(loader, entrypointClasses);
	if (!entrypointResult.isPresent()) {
		return false;
	}

	entrypoint = entrypointResult.get().entrypointName;
	gameJar = entrypointResult.get().entrypointPath;
	realmsJar = GameProviderHelper.getSource(loader, "realmsVersion").orElse(null);
	hasModLoader = GameProviderHelper.getSource(loader, "ModLoader.class").isPresent();
	versionData = McVersionLookup.getVersion(gameJar);

	return true;
}
 
Example 3
Source File: WAbstractSlider.java    From LibGui with MIT License 5 votes vote down vote up
@Environment(EnvType.CLIENT)
@Override
public void onMouseScroll(int x, int y, double amount) {
	if (direction == Direction.LEFT || direction == Direction.DOWN) {
		amount = -amount;
	}

	int previous = value;
	value = MathHelper.clamp(value + (int) Math.signum(amount) * MathHelper.ceil(valueToCoordRatio * Math.abs(amount) * 2), min, max);

	if (previous != value) {
		onValueChanged(value);
		pendingDraggingFinishedFromScrolling = true;
	}
}
 
Example 4
Source File: WButton.java    From LibGui with MIT License 5 votes vote down vote up
@Environment(EnvType.CLIENT)
@Override
public void onClick(int x, int y, int button) {
	super.onClick(x, y, button);
	
	if (enabled && isWithinBounds(x, y)) {
		MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));

		if (onClick!=null) onClick.run();
	}
}
 
Example 5
Source File: HallowedFogColorCalculator.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public Vec3d calculate(float v, float v1) {
	World world = MinecraftClient.getInstance().world;
	PlayerEntity player = MinecraftClient.getInstance().player;
	double totalR = 0;
	double totalG = 0;
	double totalB = 0;
	int count = 0;
	int radius = HallowedConfig.HallowedFog.fogSmoothingRadius;
	
	for (int x = 0; x < radius; x++) {
		for (int z = 0; z < radius; z++) {
			BlockPos pos = player.getBlockPos().add(x - (radius / 2), 0, z - (radius / 2));
			
			if (world.getBiomeAccess().getBiome(pos) instanceof HallowedBiomeInfo) {
				HallowedBiomeInfo biomeInfo = (HallowedBiomeInfo) world.getBiomeAccess().getBiome(pos);
				
				totalR += Math.pow(biomeInfo.getFogColor().x, 2);
				totalG += Math.pow(biomeInfo.getFogColor().y, 2);
				totalB += Math.pow(biomeInfo.getFogColor().z, 2);
			}
			count++;
		}
	}
	
	return new Vec3d(Math.sqrt(totalR / count), Math.sqrt(totalG / count), Math.sqrt(totalB / count));
}
 
Example 6
Source File: WAbstractSlider.java    From LibGui with MIT License 5 votes vote down vote up
@Environment(EnvType.CLIENT)
@Override
public WWidget onMouseUp(int x, int y, int button) {
	dragging = false;
	if (draggingFinishedListener != null) draggingFinishedListener.accept(value);
	return super.onMouseUp(x, y, button);
}
 
Example 7
Source File: DefaultFabricationCategory.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public EntryStack getLogo() {
    return EntryStack.create(GalacticraftBlocks.CIRCUIT_FABRICATOR.asItem().getStackForRender());
}
 
Example 8
Source File: ConfigManager.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Environment(EnvType.CLIENT)
Screen getScreen(Screen parent);
 
Example 9
Source File: ElectricCompressorBlockEntity.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public ElectricCompressorStatus getStatusForTooltip() {
    return status;
}
 
Example 10
Source File: WKirbSprite.java    From LibGui with MIT License 4 votes vote down vote up
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
	long now = System.nanoTime() / 1_000_000L;
	
	
	if (pendingFrames.isEmpty()) {
		
		if (LibGuiClient.config.darkMode) {
			switch(state) {
			case AWAKE:
				state = State.FALLING_ASLEEP;
				break;
			case FALLING_ASLEEP:
				state = State.ASLEEP;
				break;
			default:
				//zzzz
				state = State.ASLEEP;
				break;
			}
		} else {
			switch(state) {
			case ASLEEP:
				state = State.WAKING_UP;
				break;
			case WAKING_UP:
				state = State.AWAKE;
				break;
			default:
				state = State.AWAKE;
				break;
			}
		}
		
		switch (state) {
		case ASLEEP: schedule(asleep); break;
		case WAKING_UP: schedule(toAwake); break;
		case AWAKE: schedule(awake); break;
		case FALLING_ASLEEP: schedule(toSleep); break;
		}
	}
	
	float offset = KIRB_WIDTH * currentFrame;
	ScreenDrawing.texturedRect(x, y+8, 32, 32, KIRB, offset, 0, offset+KIRB_WIDTH, 1, 0xFFFFFFFF);
	
	long elapsed = now - lastFrame;
	currentFrameTime += elapsed;
	if (currentFrameTime >= frameTime) {
		if (!pendingFrames.isEmpty()) currentFrame = pendingFrames.remove(0);
		currentFrameTime = 0;
	}
	
	this.lastFrame = now;
}
 
Example 11
Source File: SyncedGuiDescription.java    From LibGui with MIT License 4 votes vote down vote up
@Environment(EnvType.CLIENT)
public void addPainters() {
	if (this.rootPanel!=null && !fullscreen) {
		this.rootPanel.setBackgroundPainter(BackgroundPainter.VANILLA);
	}
}
 
Example 12
Source File: UnlitWallTorchBlock.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState blockState, World world, BlockPos blockPos, Random random) {
    // stop particles from spawning
}
 
Example 13
Source File: MoonBiomeSource.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Environment(EnvType.CLIENT)
public BiomeSource withSeed(long seed) {
    return new MoonBiomeSource(seed, this.biomeSize);
}
 
Example 14
Source File: WWidget.java    From LibGui with MIT License 2 votes vote down vote up
/**
 * Paints this widget.
 *
 * @param matrices the rendering matrix stack
 * @param x        this widget's X coordinate on the screen
 * @param y        this widget's Y coordinate on the screen
 * @param mouseX   the X coordinate of the cursor
 * @param mouseY   the X coordinate of the cursor
 * @since 2.0.0
 */
@Environment(EnvType.CLIENT)
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
}
 
Example 15
Source File: IForgeEffect.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called to draw the {@link StatusEffectInstance} onto the player's inventory when it's active.
 * This can be used to e.g. render {@link StatusEffect} icons from your own texture.
 *
 * @param effect the active {@link StatusEffectInstance}
 * @param gui    the gui instance
 * @param x      the x coordinate
 * @param y      the y coordinate
 * @param z      the z level
 */
@Environment(EnvType.CLIENT)
default void renderInventoryEffect(StatusEffectInstance effect, AbstractInventoryScreen<?> gui, int x, int y, float z) {
}
 
Example 16
Source File: IForgeItem.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns the text renderer used to render tooltips and overlays for this item.
 * Returning null will use the standard text renderer.
 *
 * @param stack The current item stack
 * @return An instance of TextRenderer or null to use default
 */
@Environment(EnvType.CLIENT)
@Nullable
default TextRenderer getFontRenderer(ItemStack stack) {
	return null;
}
 
Example 17
Source File: WWidget.java    From LibGui with MIT License 2 votes vote down vote up
/**
 * Notifies this widget that a character has been typed. This method is subject to key repeat,
 * and may be called for characters that do not directly have a corresponding keyboard key.
 * @param ch the character typed
 */
@Environment(EnvType.CLIENT)
public void onCharTyped(char ch) {
}
 
Example 18
Source File: WWidget.java    From LibGui with MIT License 2 votes vote down vote up
/**
 * Notifies this widget that the mouse has been pressed and released, both while inside its bounds.
 * @param x The X coordinate of the event, in widget-space (0 is the left edge of this widget)
 * @param y The Y coordinate of the event, in widget-space (0 is the top edge of this widget)
 * @param button The mouse button that was used. Button numbering is consistent with LWJGL Mouse (0=left, 1=right, 2=mousewheel click)
 */
@Environment(EnvType.CLIENT)
public void onClick(int x, int y, int button) {
}
 
Example 19
Source File: WItemSlot.java    From LibGui with MIT License 2 votes vote down vote up
/**
 * Gets this slot widget's background painter.
 *
 * @return the background painter
 * @since 2.0.0
 */
@Nullable
@Environment(EnvType.CLIENT)
public BackgroundPainter getBackgroundPainter() {
	return backgroundPainter;
}
 
Example 20
Source File: WWidget.java    From LibGui with MIT License 2 votes vote down vote up
/**
 * Notifies this widget that the mouse has been moved while pressed and inside its bounds.
 *
 * <p>The default implementation calls {@link #onMouseDrag(int, int, int)} for backwards compatibility.
 *
 * @param x The X coordinate of the event, in widget-space (0 is the left edge of this widget)
 * @param y The Y coordinate of the event, in widget-space (0 is the top edge of this widget)
 * @param button The mouse button that was used. Button numbering is consistent with LWJGL Mouse (0=left, 1=right, 2=mousewheel click)
 * @param deltaX The amount of dragging on the X axis
 * @param deltaY The amount of dragging on the Y axis
 *
 * @since 1.5.0
 */
@Environment(EnvType.CLIENT)
public void onMouseDrag(int x, int y, int button, double deltaX, double deltaY) {
	onMouseDrag(x, y, button);
}