当前位置: 首页>>代码示例>>Java>>正文


Java Vec2d类代码示例

本文整理汇总了Java中com.teamwizardry.librarianlib.features.math.Vec2d的典型用法代码示例。如果您正苦于以下问题:Java Vec2d类的具体用法?Java Vec2d怎么用?Java Vec2d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Vec2d类属于com.teamwizardry.librarianlib.features.math包,在下文中一共展示了Vec2d类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GuiBedrockBore

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
public GuiBedrockBore(ContainerBedrockBore container)
{
	super(container, texture.getWidth(), texture.getHeight());
	ComponentSprite background = new ComponentSprite(texture, 0, 0);
	getMainComponents().add(background);
	InventoryWrapperPlayer playerInv = container.playerInv;
	PlayerLayout inventory = BaseLayouts.INSTANCE.player(playerInv);
	inventory.getRoot().setPos(new Vec2d(8, 84));
	
	GridLayout block = BaseLayouts.INSTANCE.grid(container.blockInv.getSlotArray(), container.blockInv.getSlotArray().size());
	block.getSlots()[0][0].setPos(new Vec2d(56, 35));
	block.getSlots()[0][1].setPos(new Vec2d(116, 35));
	
	ComponentSprite progressBar = new ComponentSprite(progress, 77, 37);
	
	double progressPercent = ((double) container.bore.burnTime) / TEBedrockBore.FUEL_TIME;
	Vec2d progressSize = new Vec2d(progress.getWidth() * progressPercent, progress.getHeight());
	progressBar.setSize(progressSize);
	
	background.add(inventory.getRoot(), block.getRoot(), progressBar);
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:22,代码来源:GuiBedrockBore.java

示例2: OptionFill

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
public OptionFill(GuiBuilder builder, ComponentList list, String title, Sprite icon, GuiBuilder.TileType type) {
	super(list, title, icon, false, false);

	component.BUS.hook(ButtonMixin.ButtonClickEvent.class, (event -> {
		if (event.getButton() == EnumMouseButton.LEFT) {
			Vec2d first = builder.getTile(GuiBuilder.TileType.LEFT_SELECTED),
					second = builder.getTile(GuiBuilder.TileType.RIGHT_SELECTED);

			if (first != null && second != null)
				for (int i = first.getXi() < second.getXi() ? first.getXi() : second.getXi();
				     i < (first.getXi() < second.getXi() ? second.getXi() : first.getXi()) + 1; i++)
					for (int j = first.getYi() < second.getYi() ? first.getYi() : second.getYi();
					     j < (first.getYi() < second.getYi() ? second.getYi() : first.getYi()) + 1; j++)
						builder.grid[builder.selectedLayer][i][j] = type;
		}
		PacketHandler.NETWORK.sendToServer(new PacketBuilderGridSaver(builder.location, builder.grid));
	}));
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:19,代码来源:OptionFill.java

示例3: StackModule

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
public StackModule(TextAdapter textAdapter, @Nullable ItemStack stack, int x, int y) {
	fr.setBidiFlag(true);
	fr.setUnicodeFlag(true);
	this.stack = stack;
	this.x = x;
	this.y = y;

	if (x + fr.getStringWidth(stack == null ? "<NULL>" : stack.getDisplayName()) > TextAdapter.wrapLength) {
		this.x = 0;
		this.y += fr.FONT_HEIGHT;
	}

	component = new ComponentText(this.x, this.y, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.MIDDLE);
	component.getUnicode().setValue(true);
	if (stack != null) {
		String displayName = " [" + TextFormatting.UNDERLINE + "" + TextFormatting.BLUE + stack.getDisplayName() + TextFormatting.RESET + "]";
		component.getText().setValue(displayName);
		this.x += fr.getStringWidth(displayName);

		List<String> tooltip = stack.getTooltip(Minecraft.getMinecraft().player, false);
		component.BUS.hook(GuiComponent.PostDrawEvent.class, postDrawEvent -> {
			if (component.getMouseOver())
				component.setTooltip(tooltip);
		});
	} else {
		component.getText().setValue("<NULL>");
		this.x += fr.getStringWidth("<NULL>");
	}
	component.setSize(new Vec2d(fr.getStringWidth(component.getText().getValue(component)), fr.FONT_HEIGHT));

	fr.setBidiFlag(false);
	fr.setUnicodeFlag(false);
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:34,代码来源:StackModule.java

示例4: getTile

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
@Nullable
public Vec2d getTile(TileType type) {
	for (int i = 0; i < grid.length; i++)
		for (int j = 0; j < grid.length; j++)
			if (grid[selectedLayer][i][j] == type) return new Vec2d(i, j);
	return null;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:8,代码来源:GuiBuilder.java

示例5: rot

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
private Vec2d rot(Vec2d vec, double deg) {
	double theta = Math.toRadians(deg);

	double cs = Math.cos(theta);
	double sn = Math.sin(theta);

	return new Vec2d(vec.getX() * cs - vec.getY() * sn, vec.getX() * sn + vec.getY() * cs);
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:9,代码来源:ScrewdriverOverlay.java

示例6: ComponentStructure

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
public ComponentStructure(BookGui bookGui, int x, int y, int width, int height, IStructure structure) {
	super(x, y, width, height);

	ComponentStructureList list = new ComponentStructureList(structure.getStructure());
	ComponentBookmarkSwitch bookmark = new ComponentBookmarkSwitch(new Vec2d(-getSize().getXi() - 35, 0), bookGui, this, list, bookGui.bookmarkIndex, "Materials", true, false, true, true);
	add(bookmark);

	BUS.hook(GuiComponentEvents.MouseWheelEvent.class, event -> {
		if (event.component.hasTag("switched") || !event.component.isVisible()) return;
		if (event.getDirection() == GuiComponentEvents.MouseWheelDirection.UP) zoom += 1;
		else zoom -= 1;
		zoom = MathHelper.clamp(zoom, 0, 20);
	});

	BUS.hook(GuiComponentEvents.MouseDragEvent.class, event -> {
		if (event.component.hasTag("switched") || !event.component.isVisible()) return;
		Vec2d untransform = event.getMousePos();
		Vec2d diff;
		if (dragging) diff = untransform.sub(prevPos).mul(1 / 5.0);
		else diff = event.getMousePos().mul(1 / 100.0);

		if (event.getButton() == EnumMouseButton.RIGHT) rotVec = rotVec.add(diff);
		else if (event.getButton() == EnumMouseButton.LEFT) panVec = panVec.add(diff.mul(2));

		prevPos = untransform;
		dragging = true;
	});

	BUS.hook(GuiComponentEvents.MouseUpEvent.class, event -> {
		if (event.component.hasTag("switched") || !event.component.isVisible()) return;
		prevPos = Vec2d.ZERO;
		dragging = false;
	});


	BUS.hook(GuiComponentEvents.PostDrawEvent.class, event -> {
		if (event.component.hasTag("switched") || !event.component.isVisible()) return;

		Vec2d root = event.component.thisPosToOtherContext(null);
		Vec2d size = event.component.getSize().mul(1 / 2.0);

		ScissorUtil.push();
		ScissorUtil.set(root.getXi(), root.getYi(), size.getXi(), size.getYi());
		ScissorUtil.enable();

		GlStateManager.pushMatrix();

		GlStateManager.enableAlpha();
		GlStateManager.enableBlend();
		GlStateManager.enableCull();
		GlStateManager.enableRescaleNormal();

		GlStateManager.translate(width / 2.0, (height / 2.0), 500);

		GlStateManager.translate(panVec.getX(), panVec.getY(), 0);
		GlStateManager.rotate((float) (35 + rotVec.getY()), -1, 0, 0);
		GlStateManager.rotate((float) ((45 + rotVec.getX())), 0, 1, 0);
		GlStateManager.scale(16 + zoom, -16 - zoom, 16 + zoom);
		GlStateManager.translate(-structure.offsetToCenter().getX(), -structure.offsetToCenter().getY(), -structure.offsetToCenter().getZ());
		GlStateManager.translate(-0.5, -0.5, -0.5);

		Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
		structure.getStructure().draw();

		GlStateManager.popMatrix();

		ScissorUtil.pop();
	});
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:70,代码来源:ComponentStructure.java

示例7: ComponentStructureList

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
public ComponentStructureList(Structure structure) {
	super(0, 0, 200, 300);
	Deque<Block> sorted = new ArrayDeque<>();
	HashMap<Block, Integer> ingredients = new HashMap<>();
	HashMap<Block, IBlockState> access = new HashMap<>();

	for (Template.BlockInfo info : structure.blockInfos()) {
		if (info.blockState.getBlock() == Blocks.AIR) continue;

		ingredients.putIfAbsent(info.blockState.getBlock(), 0);
		ingredients.put(info.blockState.getBlock(), ingredients.get(info.blockState.getBlock()) + 1);
		access.putIfAbsent(info.blockState.getBlock(), info.blockState);

		if (!sorted.contains(info.blockState.getBlock())) sorted.add(info.blockState.getBlock());
	}


	ComponentVoid recipe = new ComponentVoid(0, 0, 200, 300);
	recipe.getTransform().setScale(2);
	add(recipe);

	ComponentText text = new ComponentText(0, 3, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.TOP);
	text.setSize(new Vec2d(200, 16));
	text.getText().setValue(" " + LibrarianLib.PROXY.translate("wizardry.misc.structure_materials"));
	recipe.add(text);

	ComponentSprite lineBreak = new ComponentSprite(BookGui.LINE_BREAK, (int) (getSize().getX() / 2.0 - 177.0 / 2.0), 30, 177, 2);
	add(lineBreak);

	int i = 0;
	int row = 0;
	while (!sorted.isEmpty() && sorted.peek() != null) {

		Block nextBlock = sorted.pop();
		ItemStack stack;
		if (FluidRegistry.lookupFluidForBlock(nextBlock) != null) {
			stack = FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.lookupFluidForBlock(nextBlock), 1));
			stack = new ItemStack(stack.getItem(), ingredients.get(nextBlock), stack.getMetadata(), stack.getTagCompound());
		} else {
			NonNullList<ItemStack> itemStacks = NonNullList.create();
			nextBlock.getDrops(itemStacks, structure.getBlockAccess(), null, access.get(nextBlock), 0);
			if (itemStacks.isEmpty())
				stack = new ItemStack(nextBlock, ingredients.get(nextBlock));
			else {
				stack = itemStacks.get(0);
				stack.setCount(ingredients.get(nextBlock));
			}
		}

		ComponentStack componentStack = new ComponentStack(i * 16, 20 + row * 16);
		componentStack.getStack().setValue(stack);
		recipe.add(componentStack);

		if (i++ > 4) {
			i = 0;
			row++;
		}
	}
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:60,代码来源:ComponentStructureList.java

示例8: LeftSidebar

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
public LeftSidebar(ComponentList list, String title, Sprite icon, boolean defaultSelected, boolean selectable) {
	this.title = title;
	this.icon = icon;

	ComponentSprite background = new ComponentSprite(leftNormal, 0, 0);
	background.setMarginBottom(2);
	background.setMarginLeft(list.getMarginLeft());
	if (defaultSelected) background.addTag("selected");

	ComponentSprite iconComp = new ComponentSprite(this.icon, 5, 1, 16, 16);
	background.add(iconComp);

	ComponentText titleComp = new ComponentText(iconComp.getSize().getXi() + 10, 9, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.MIDDLE);
	titleComp.setOutOfFlow(true);
	background.add(titleComp);

	ComponentList listComp = new ComponentList(leftExtended.getWidth(), leftExtended.getHeight() + 2);
	background.add(listComp);
	this.listComp = listComp;

	new ButtonMixin<>(background, () -> {
	});

	background.BUS.hook(GuiComponent.ComponentTickEvent.class, (event) -> {
		if (background.hasTag("selected")) {
			if (listComp.getChildren().size() > 0) {
				listComp.setVisible(true);
				listComp.setEnabled(true);
			} else {
				listComp.setVisible(false);
				listComp.setEnabled(false);
			}
			background.setSprite(leftExtended);
			background.setSize(new Vec2d(leftExtended.getWidth(), leftExtended.getHeight()));
			background.setPos(new Vec2d(-leftExtended.getWidth() + (list.getChildren().contains(background) ? 0 : 5), 0));
			titleComp.getText().setValue(TextFormatting.ITALIC + title);
		} else {
			listComp.setVisible(false);
			listComp.setEnabled(false);
			background.setSprite(leftNormal);
			background.setSize(new Vec2d(leftNormal.getWidth(), leftNormal.getHeight()));
			background.setPos(new Vec2d(-leftNormal.getWidth() + (list.getChildren().contains(background) ? 5 : 0), 0));
			titleComp.getText().setValue(title);
		}
	});

	if (selectable)
		background.BUS.hook(ButtonMixin.ButtonClickEvent.class, (event -> {
			if (event.getButton() == EnumMouseButton.LEFT) {
				if (!background.hasTag("selected")) {
					background.addTag("selected");
					for (GuiComponent component : list.getChildren())
						if (component != background) component.removeTag("selected");
				}
			}
		}));
	component = background;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:59,代码来源:LeftSidebar.java

示例9: RightSidebar

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
public RightSidebar(ComponentList list, String title, Sprite icon, boolean defaultSelected, boolean selectable) {
	this.title = title;
	this.icon = icon;

	ComponentSprite background = new ComponentSprite(rightNormal, 0, 0);
	background.setMarginBottom(2);
	background.setMarginLeft(list.getMarginRight());
	if (defaultSelected) background.addTag("selected");

	ComponentSprite iconComp = new ComponentSprite(this.icon, 5, 1, 16, 16);
	background.add(iconComp);

	ComponentText titleComp = new ComponentText(iconComp.getSize().getXi() + 10, 9, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.MIDDLE);
	titleComp.setOutOfFlow(true);
	background.add(titleComp);

	ComponentList listComp = new ComponentList(rightExtended.getWidth(), rightExtended.getHeight() + 2);
	background.add(listComp);
	this.listComp = listComp;

	new ButtonMixin<>(background, () -> {
	});

	background.BUS.hook(GuiComponent.ComponentTickEvent.class, (event) -> {
		if (background.hasTag("selected")) {
			if (listComp.getChildren().size() > 0) {
				listComp.setVisible(true);
				listComp.setEnabled(true);
			} else {
				listComp.setVisible(false);
				listComp.setEnabled(false);
			}
			background.setSprite(rightExtended);
			background.setSize(new Vec2d(rightExtended.getWidth(), rightExtended.getHeight()));
			background.setPos(new Vec2d(-rightNormal.getWidth() + (list.getChildren().contains(background) ? -5 : 0), 0));
			titleComp.getText().setValue(TextFormatting.ITALIC + title);
		} else {
			listComp.setVisible(false);
			listComp.setEnabled(false);
			background.setSprite(rightNormal);
			background.setSize(new Vec2d(rightNormal.getWidth(), rightNormal.getHeight()));
			background.setPos(new Vec2d(-rightNormal.getWidth() + (list.getChildren().contains(background) ? -5 : 0), 0));
			titleComp.getText().setValue(title);
		}
	});

	if (selectable)
		background.BUS.hook(ButtonMixin.ButtonClickEvent.class, (event -> {
			if (event.getButton() == EnumMouseButton.LEFT) {
				if (!background.hasTag("selected")) {
					background.addTag("selected");
					for (GuiComponent component : list.getChildren())
						if (component != background) component.removeTag("selected");
				}
			}
		}));
	component = background;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:59,代码来源:RightSidebar.java

示例10: overlay

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
@SubscribeEvent
public void overlay(RenderGameOverlayEvent.Post event) {
	ItemStack stack = getItemInHand(ModItems.SCREW_DRIVER);
	if (stack == null)
		return;

	if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
		ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());

		double SQRT2 = Math.sqrt(0.5);

		double angle = getRotationMultiplier(stack);
		int textIndex = getRotationIndex(stack);
		double anglePer = 5.0;
		String text = I18n.format("gui.screw_driver.angle." + textIndex);


		int circleRadius = 75;
		int posX = res.getScaledWidth();
		int posY = res.getScaledHeight();

		if (angle < 5) {
			double radiusAdd = 500;
			posX += SQRT2 * radiusAdd;
			posY += SQRT2 * radiusAdd;
			circleRadius += radiusAdd;
		}

		GlStateManager.pushMatrix();
		GlStateManager.disableTexture2D();
		GlStateManager.color(0, 0, 0);
		GlStateManager.translate(posX, posY, 0);

		Vec2d vec = new Vec2d(0, -circleRadius);
		vec = rot(vec, -angle / 2 - 45);

		Tessellator tessellator = Tessellator.getInstance();
		VertexBuffer vb = tessellator.getBuffer();

		vb.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION);
		vb.pos(0, 0, 0).endVertex();

		double ang = angle;

		do {
			Vec2d v = rot(vec, ang);
			vb.pos(v.getX(), v.getY(), 0).endVertex();
			ang -= anglePer;
		} while (ang > 0);

		vb.pos(vec.getX(), vec.getY(), 0).endVertex();

		tessellator.draw();
		GlStateManager.enableTexture2D();

		int width = Minecraft.getMinecraft().fontRenderer.getStringWidth(text);
		Minecraft.getMinecraft().fontRenderer.drawString(text, -width - (int) (circleRadius * SQRT2), -9 - (int) (circleRadius * SQRT2), 0x000000, false);

		GlStateManager.color(1, 1, 1);
		GlStateManager.popMatrix();
	}

	if (event.getType() == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
		// HIGHLIGHT ANGLE
		if (highlighting != null) {
			World world = Minecraft.getMinecraft().world;
			IBlockState state = world.getBlockState(highlighting);
			if (state.getBlock() instanceof IPrecision) {
				IPrecision prec = (IPrecision) state.getBlock();
				GlStateManager.pushMatrix();
				GlStateManager.enableTexture2D();
				GlStateManager.color(1, 1, 1);
				String s = prec.getRotX(world, highlighting) + ", " + prec.getRotY(world, highlighting);
				Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(s, event.getResolution().getScaledWidth() / 2 - Minecraft.getMinecraft().fontRenderer.getStringWidth(s) / 2, event.getResolution().getScaledHeight() / 2 + 30, 0xFFFFFF);
				GlStateManager.popMatrix();
				highlighting = null;
			}
		}
	}
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:81,代码来源:ScrewdriverOverlay.java

示例11: drawComponent

import com.teamwizardry.librarianlib.features.math.Vec2d; //导入依赖的package包/类
@Override
public void drawComponent(Vec2d mousePos, float partialTicks) {

}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:5,代码来源:ComponentBookmarkSwitch.java


注:本文中的com.teamwizardry.librarianlib.features.math.Vec2d类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。