net.minecraft.util.Rarity#net.fabricmc.api.EnvType源码实例Demo

下面列出了net.minecraft.util.Rarity#net.fabricmc.api.EnvType 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: fabric-loader   文件: FabricTransformer.java
public static byte[] lwTransformerHook(String name, String transformedName, byte[] bytes) {
	boolean isDevelopment = FabricLauncherBase.getLauncher().isDevelopment();
	EnvType envType = FabricLauncherBase.getLauncher().getEnvironmentType();

	byte[] input = MinecraftGameProvider.TRANSFORMER.transform(name);
	if (input != null) {
		return FabricTransformer.transform(isDevelopment, envType, name, input);
	} else {
		if (bytes != null) {
			return FabricTransformer.transform(isDevelopment, envType, name, bytes);
		} else {
			return null;
		}
	}

}
 
源代码2 项目: LibGui   文件: WTiledSprite.java
@Environment(EnvType.CLIENT)
@Override
public void paintFrame(int x, int y, Identifier texture) {
	// Y Direction (down)
	for (int tileYOffset = 0; tileYOffset < height; tileYOffset += tileHeight) {
		// X Direction (right)
		for (int tileXOffset = 0; tileXOffset < width; tileXOffset += tileWidth) {
			// draw the texture
			ScreenDrawing.texturedRect(
					// at the correct position using tileXOffset and tileYOffset
					x + tileXOffset, y + tileYOffset,
					// but using the set tileWidth and tileHeight instead of the full height and
					// width
					tileWidth, tileHeight,
					// render the current texture
					texture,
					// clips the texture if wanted
					u1, v1, u2, v2, tint);
		}
	}
}
 
源代码3 项目: fabric-loader   文件: MinecraftGameProvider.java
@Override
public void launch(ClassLoader loader) {
	String targetClass = entrypoint;

	if (envType == EnvType.CLIENT && targetClass.contains("Applet")) {
		targetClass = "net.fabricmc.loader.entrypoint.applet.AppletMain";
	}

	try {
		Class<?> c = loader.loadClass(targetClass);
		Method m = c.getMethod("main", String[].class);
		m.invoke(null, (Object) arguments.toArray());
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
源代码4 项目: the-hallow   文件: WitchWaterBubbleColumnBlock.java
@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);
		}
	}
}
 
源代码5 项目: LibGui   文件: WTextField.java
/**
 * From an X offset past the left edge of a TextRenderer.draw, finds out what the closest caret
 * position (division between letters) is.
 * @param s
 * @param x
 * @return
 */
@Environment(EnvType.CLIENT)
public static int getCaretPos(String s, int x) {
	if (x<=0) return 0;
	
	TextRenderer font = MinecraftClient.getInstance().textRenderer;
	int lastAdvance = 0;
	for(int i=0; i<s.length()-1; i++) {
		int advance = font.getWidth(s.substring(0,i+1));
		int charAdvance = advance-lastAdvance;
		if (x<advance + (charAdvance/2)) return i+1;
		
		lastAdvance = advance;
	}
	
	return s.length();
}
 
源代码6 项目: LibGui   文件: WPanel.java
@Environment(EnvType.CLIENT)
@Override
public WWidget onMouseUp(int x, int y, int button) {
	if (children.isEmpty()) return super.onMouseUp(x, y, button);
	for(int i=children.size()-1; i>=0; i--) { //Backwards so topmost widgets get priority
		WWidget child = children.get(i);
		if (    x>=child.getX() &&
				y>=child.getY() &&
				x<child.getX()+child.getWidth() &&
				y<child.getY()+child.getHeight()) {
			return child.onMouseUp(x-child.getX(), y-child.getY(), button);
		}
	}
	return super.onMouseUp(x, y, button);
}
 
源代码7 项目: LibGui   文件: WPlayerInvPanel.java
/**
 * Sets the background painter of this inventory widget's slots.
 *
 * @param painter the new painter
 * @return this panel
 */
@Environment(EnvType.CLIENT)
@Override
public WPanel setBackgroundPainter(BackgroundPainter painter) {
	super.setBackgroundPainter(null);
	inv.setBackgroundPainter(painter);
	hotbar.setBackgroundPainter(painter);
	return this;
}
 
源代码8 项目: fabric-loader   文件: ModMetadataV0.java
@Override
public boolean loadsInEnvironment(EnvType type) {
	switch (side) {
		case UNIVERSAL:
			return true;
		case CLIENT:
			return type == EnvType.CLIENT;
		case SERVER:
			return type == EnvType.SERVER;
		default:
			return false;
	}
}
 
源代码9 项目: Galacticraft-Rewoven   文件: MoonBerryBushBlock.java
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState blockState, World world, BlockPos blockPos, Random random) {
    if (blockState.get(AGE) == 3) {

        double x = blockPos.getX() + 0.5D + (random.nextFloat() - random.nextFloat());
        double y = blockPos.getY() + random.nextFloat();
        double z = blockPos.getZ() + 0.5D + (random.nextFloat() - random.nextFloat());
        int times = random.nextInt(4);

        for (int i = 0; i < times; i++) {
            world.addParticle(new DustParticleEffect(0.5f, 0.5f, 1.0f, 0.6f), x, y, z, 0.0D, 0.0D, 0.0D);
        }
    }
}
 
源代码10 项目: LibGui   文件: WAbstractSlider.java
@Environment(EnvType.CLIENT)
@Override
public void tick() {
	if (draggingFinishedFromScrollingTimer > 0) {
		draggingFinishedFromScrollingTimer--;
	}

	if (pendingDraggingFinishedFromScrolling && draggingFinishedFromScrollingTimer <= 0) {
		if (draggingFinishedListener != null) draggingFinishedListener.accept(value);
		pendingDraggingFinishedFromScrolling = false;
		draggingFinishedFromScrollingTimer = DRAGGING_FINISHED_RATE_LIMIT_FOR_SCROLLING;
	}
}
 
源代码11 项目: LibGui   文件: WToggleButton.java
@Environment(EnvType.CLIENT)
@Override
public void onClick(int x, int y, int button) {
	super.onClick(x, y, button);
	
	MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));

	this.isOn = !this.isOn;
	onToggle(this.isOn);
}
 
源代码12 项目: Galacticraft-Rewoven   文件: CompressorBlock.java
@Override
@Environment(EnvType.CLIENT)
public final void buildTooltip(ItemStack itemStack_1, BlockView blockView_1, List<Text> list_1, TooltipContext tooltipContext_1) {
    if (Screen.hasShiftDown()) {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.compressor").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    } else {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.press_shift").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    }
}
 
源代码13 项目: Galacticraft-Rewoven   文件: CrudeOilFluid.java
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(World world, BlockPos blockPos, FluidState fluidState, Random random) {
    if (random.nextInt(10) == 0) {
        world.addParticle(GalacticraftParticles.DRIPPING_CRUDE_OIL_PARTICLE,
                (double) blockPos.getX() + 0.5D - random.nextGaussian() + random.nextGaussian(),
                (double) blockPos.getY() + 1.1F,
                (double) blockPos.getZ() + 0.5D - random.nextGaussian() + random.nextGaussian(),
                0.0D, 0.0D, 0.0D);
    }
}
 
源代码14 项目: patchwork-api   文件: IForgeWorldType.java
/**
 * Called when the 'Customize' button is pressed on world creation GUI.
 */
@Environment(EnvType.CLIENT)
default void onCustomizeButton(MinecraftClient client, CreateWorldScreen screen) {
	if (this == LevelGeneratorType.FLAT) {
		client.openScreen(new CustomizeFlatLevelScreen(screen, screen.generatorOptionsTag));
	} else if (this == LevelGeneratorType.BUFFET) {
		client.openScreen(new CustomizeBuffetLevelScreen(screen, screen.generatorOptionsTag));
	}
}
 
源代码15 项目: LibGui   文件: WAbstractSlider.java
@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;
	}
}
 
源代码16 项目: LibGui   文件: WText.java
@Environment(EnvType.CLIENT)
@Override
public void onClick(int x, int y, int button) {
	if (button != 0) return; // only left clicks

	Style hoveredTextStyle = getTextStyleAt(x, y);
	if (hoveredTextStyle != null) {
		MinecraftClient.getInstance().currentScreen.handleTextClick(hoveredTextStyle);
	}
}
 
源代码17 项目: Galacticraft-Rewoven   文件: StandardWrenchItem.java
@Override
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack itemStack_1, World world_1, List<Text> list_1, TooltipContext tooltipContext_1) {
    if (Screen.hasShiftDown()) {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.standard_wrench").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    } else {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.press_shift").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    }
}
 
源代码18 项目: LibGui   文件: WText.java
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
	if (wrappedLines == null || wrappingScheduled) {
		wrapLines();
		wrappingScheduled = false;
	}

	TextRenderer font = MinecraftClient.getInstance().textRenderer;

	int yOffset;
	switch (verticalAlignment) {
		case CENTER:
			yOffset = height / 2 - font.fontHeight * wrappedLines.size() / 2;
			break;
		case BOTTOM:
			yOffset = height - font.fontHeight * wrappedLines.size();
			break;
		case TOP:
		default:
			yOffset = 0;
			break;
	}

	for (int i = 0; i < wrappedLines.size(); i++) {
		StringRenderable line = wrappedLines.get(i);
		int c = LibGuiClient.config.darkMode ? darkmodeColor : color;

		ScreenDrawing.drawString(matrices, line, horizontalAlignment, x, y + yOffset + i * font.fontHeight, width, c);
	}

	Style hoveredTextStyle = getTextStyleAt(mouseX, mouseY);
	if (hoveredTextStyle != null) {
		Screen screen = MinecraftClient.getInstance().currentScreen;
		if (screen instanceof TextHoverRendererScreen) {
			((TextHoverRendererScreen) screen).renderTextHover(matrices, hoveredTextStyle, x + mouseX, y + mouseY);
		}
	}
}
 
源代码19 项目: LibGui   文件: WLabeledSlider.java
@Environment(EnvType.CLIENT)
private void drawButton(int x, int y, int state, int width) {
	float px = 1 / 256f;
	float buttonLeft = 0 * px;
	float buttonTop = (46 + (state * 20)) * px;
	int halfWidth = width / 2;
	if (halfWidth > 198) halfWidth = 198;
	float buttonWidth = halfWidth * px;
	float buttonHeight = 20 * px;
	float buttonEndLeft = (200 - halfWidth) * px;

	ScreenDrawing.texturedRect(x, y, halfWidth, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight, 0xFFFFFFFF);
	ScreenDrawing.texturedRect(x + halfWidth, y, halfWidth, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonEndLeft, buttonTop, 200 * px, buttonTop + buttonHeight, 0xFFFFFFFF);
}
 
源代码20 项目: patchwork-api   文件: NetworkEvent.java
@Override
public PlayerEntity getPlayer() {
	if (getPacketEnvironment() == EnvType.CLIENT) {
		throw new UnsupportedOperationException();
	}

	return getSender();
}
 
源代码21 项目: LibGui   文件: WItem.java
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
	RenderSystem.enableDepthTest();

	MinecraftClient mc = MinecraftClient.getInstance();
	ItemRenderer renderer = mc.getItemRenderer();
	renderer.zOffset = 100f;
	renderer.renderInGui(items.get(current), x + getWidth() / 2 - 9, y + getHeight() / 2 - 9);
	renderer.zOffset = 0f;
}
 
源代码22 项目: LibGui   文件: WAbstractSlider.java
@Environment(EnvType.CLIENT)
@Override
public WWidget onMouseDown(int x, int y, int button) {
	// Check if cursor is inside or <=2px away from track
	if (isMouseInsideBounds(x, y)) {
		requestFocus();
	}
	return super.onMouseDown(x, y, button);
}
 
源代码23 项目: LibGui   文件: WTextField.java
@Environment(EnvType.CLIENT)
@Override
public void onCharTyped(char ch) {
	if (this.text.length()<this.maxLength) {
		//snap cursor into bounds if it went astray
		if (cursor<0) cursor=0;
		if (cursor>this.text.length()) cursor = this.text.length();
		
		String before = this.text.substring(0, cursor);
		String after = this.text.substring(cursor, this.text.length());
		this.text = before+ch+after;
		cursor++;
	}
}
 
源代码24 项目: fabric-loader   文件: ModMetadataV1.java
public boolean matches(EnvType type) {
	switch (this) {
		case CLIENT:
			return type == EnvType.CLIENT;
		case SERVER:
			return type == EnvType.SERVER;
		case UNIVERSAL:
			return true;
		default:
			return false;
	}
}
 
源代码25 项目: LibGui   文件: WScrollBar.java
@Environment(EnvType.CLIENT)
@Override
public WWidget onMouseUp(int x, int y, int button) {
	//TODO: Clicking before or after the handle should jump instead of scrolling
	anchor = -1;
	anchorValue = -1;
	sliding = false;
	return this;
}
 
源代码26 项目: fabric-loader   文件: ModMetadataV1.java
@Override
public Collection<String> getMixinConfigs(EnvType type) {
	return Arrays.asList(mixins).stream()
		.filter((e) -> e.environment.matches(type))
		.map((e) -> e.config)
		.collect(Collectors.toList());
}
 
源代码27 项目: LibGui   文件: WAbstractSlider.java
@Environment(EnvType.CLIENT)
@Override
public void onKeyReleased(int ch, int key, int modifiers) {
	if (pendingDraggingFinishedFromKeyboard && (isDecreasingKey(ch, direction) || isIncreasingKey(ch, direction))) {
		if (draggingFinishedListener != null) draggingFinishedListener.accept(value);
		pendingDraggingFinishedFromKeyboard = false;
	}
}
 
源代码28 项目: fabric-loader   文件: MinecraftGameProvider.java
@Override
public boolean canOpenErrorGui() {
	// Disabled on macs due to -XstartOnFirstThread being incompatible with awt but required for lwjgl
	if (System.getProperty("os.name").equals("Mac OS X")) {
		return false;
	}

	if (arguments == null || envType == EnvType.CLIENT) {
		return true;
	}

	List<String> extras = arguments.getExtraArgs();
	return !extras.contains("nogui") && !extras.contains("--nogui");
}
 
源代码29 项目: LibGui   文件: WPanel.java
@Environment(EnvType.CLIENT)
@Override
public WWidget onMouseDown(int x, int y, int button) {
	if (children.isEmpty()) return super.onMouseDown(x, y, button);
	for(int i=children.size()-1; i>=0; i--) { //Backwards so topmost widgets get priority
		WWidget child = children.get(i);
		if (    x>=child.getX() &&
				y>=child.getY() &&
				x<child.getX()+child.getWidth() &&
				y<child.getY()+child.getHeight()) {
			return child.onMouseDown(x-child.getX(), y-child.getY(), button);
		}
	}
	return super.onMouseDown(x, y, button);
}
 
源代码30 项目: Galacticraft-Rewoven   文件: MoonBiomeSource.java
@Environment(EnvType.CLIENT)
public BiomeSource withSeed(long seed) {
    return new MoonBiomeSource(seed, this.biomeSize);
}