本文整理汇总了Java中net.minecraft.util.math.Vec2f类的典型用法代码示例。如果您正苦于以下问题:Java Vec2f类的具体用法?Java Vec2f怎么用?Java Vec2f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vec2f类属于net.minecraft.util.math包,在下文中一共展示了Vec2f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderIngredients
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
private void renderIngredients(TileEntityInfusionRepair te, double x, double y, double z, float partialTicks)
{
GlStateManager.pushMatrix();
IItemHandler itemHandler = CapUtils.getItemHandler(te);
for(int slot = 0; slot < 8; slot++)
{
ItemStack stack = itemHandler.getStackInSlot(TileEntityInfusionRepair.SLOT_ENCH_ITEM + 1 + slot);
Vec2f ingredientPos = ingredientPositions[slot];
if(Prep1_11.isEmpty(stack)) continue;
GlStateManager.pushMatrix();
GlStateManager.translate(ingredientPos.x * PIXEL_SIZE, -0.15F, ingredientPos.y * PIXEL_SIZE);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotate(((mc.player.ticksExisted + partialTicks) * 60.0f) / 10.0F, 0.0F, 1.0F, 0.0F);
mc.getRenderItem().renderItem(stack, TransformType.GROUND);
GlStateManager.scale(1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
GlStateManager.popMatrix();
}
示例2: onBlockPlacedBy
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
EnumFacing facing = EnumFacing.UP;
Vec2f rot = placer.getPitchYaw();
//System.out.println("Placer x: "+rot.x+" y:"+rot.y+" yaw:"+placer.getRotationYawHead());
if (rot.x > 45) {
facing = EnumFacing.DOWN;
} else if (rot.x > -45) {
facing = placer.getAdjustedHorizontalFacing();
}
world.setBlockState(pos,
this.getStateFromMeta(stack.getMetadata())
.withProperty(FACING, facing));
}
示例3: getTypeHoveredOver
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
public TotemType getTypeHoveredOver(float centerX, float centerY, int mouseX, int mouseY) {
TotemType typeHoveredOver = TotemType.NONE;
for (TotemType type : TotemType.values()) {
float baseAngle = (360 / TotemType.values().length);
double angle = (baseAngle * type.getMeta()) - ANGLE_OFFSET;
double mouseAngle = getMouseAngle(new Vec2f(centerX, centerY), new Vec2f(mouseX, mouseY));
double minToCheck = sanitizeDegree(angle - (baseAngle / 2));
double maxToCheck = sanitizeDegree(angle + (baseAngle / 2));
if (minToCheck > maxToCheck) {
minToCheck -= 360;
}
if (mouseAngle > minToCheck
&& mouseAngle < maxToCheck) {
typeHoveredOver = type;
}
}
return typeHoveredOver;
}
示例4: pickPolar
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
private static Vec2f pickPolar(float rmin, float rmax) {
float yaw = rnd.nextFloat()*TAU;
float dist = rnd.nextFloat()*(rmax-rmin) + rmin;
float x = MathHelper.cos(yaw)*dist;
float z = MathHelper.sin(yaw)*dist;
return new Vec2f(x,z);
}
示例5: pickRing
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
private static void pickRing(float r, float angularDensity) {
for(float theta = 0; theta<TAU; theta+=angularDensity) {
float x = MathHelper.cos(theta)*r;
float z = MathHelper.sin(theta)*r;
locationBuffer.add(new Vec2f(x,z));
}
}
示例6: update
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
@Override
public void update(World world) {
if (ticks%3==0) {
locationBuffer.clear();
pickRing(0.5f, SEGMENTS);
for(Vec2f vec : locationBuffer) {
Particle particle = new ParticleVelocity(world,
x+vec.x, y+0.5f, z+vec.y,
0f, -0.3f, 0f
);
particle.setParticleTextureIndex(5); //Midway through redstone
particle.setRBGColorF(0.7f, 0.2f, 0.7f);
Minecraft.getMinecraft().effectRenderer.addEffect(particle);
}
}
float sx = (rnd.nextFloat()*2) - 1;
float sz = (rnd.nextFloat()*2) - 1;
if (rnd.nextBoolean()) {
Particle star = new ParticleVelocity(world,
x+sx, y-0.5f, z+sz,
0f, 0.35f, 0f
);
star.setParticleTextureIndex(65); //Crit stars
Minecraft.getMinecraft().effectRenderer.addEffect(star);
}
//star.setRBGColorF(0.7f, 0.2f, 0.7f);
if (ticks>9) die();
}
示例7: getPitchYaw
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
/**
* returns the Entity's pitch and yaw as a Vec2f
*/
@SideOnly(Side.CLIENT)
public Vec2f getPitchYaw()
{
Vec2f vec2f = new Vec2f(this.rotationPitch, this.rotationYaw);
return vec2f;
}
示例8: getCurrentRenderOffset
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
public Vec2f getCurrentRenderOffset(float x, float z) {
Minecraft mc = Minecraft.getMinecraft();
double sc = new ScaledResolution(mc).getScaleFactor();
double oX = x + 16D / sc;
double oZ = z + 16D / sc;
Vec3d tr = getCurrentMachineTranslate();
return new Vec2f((float) (oX + tr.x), (float) (oZ + tr.z));
}
示例9: rotate
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
public static Vec2f rotate(@Nonnull final Vec2f coord, final float radians) {
final float f = cos(radians);
final float f1 = sin(radians);
final float d0 = coord.x * f + coord.y * f1;
final float d1 = coord.y * f - coord.x * f1;
return new Vec2f(d0, d1);
}
示例10: intersect
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
public Vec2f intersect(Vec3d r1, Vec3d r2) {
// System.out.println("Plane[" + v(s1) + " | " + v(s2) + " | " + v(s3) + " | " + v(s4) + "]");
// System.out.println(" Ray[" + v(r1) + " | " + v(r2) + "]");
Vec3d dS21 = s2.subtract(s1);
Vec3d dS31 = s3.subtract(s1);
Vec3d n = dS21.crossProduct(dS31);
// 2.
Vec3d dR = r1.subtract(r2);
double ndotdR = n.dotProduct(dR);
if (Math.abs(ndotdR) < 1e-6f) { // Choose your tolerance
return null;
}
double t = -n.dotProduct(r1.subtract(s1)) / ndotdR;
Vec3d M = r1.add(dR.scale(t));
// 3.
Vec3d dMS1 = M.subtract(s1);
double u = dMS1.dotProduct(dS21);
double v = dMS1.dotProduct(dS31);
// System.out.println(" u = " + u + "," + v);
// System.out.println(" M = " + v(M));
// 4.
if (u >= 0.0 && u <= dS21.dotProduct(dS21) &&
v >= 0.0 && v <= dS31.dotProduct(dS31)) {
return new Vec2f((float)u, (float)v);
} else {
return null;
}
}
示例11: getPitchYaw
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
@Override
public Vec2f getPitchYaw() {
return super.getPitchYaw();
}
示例12: getPitchYaw
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
/**
* returns the Entity's pitch and yaw as a Vec2f
*/
public Vec2f getPitchYaw()
{
Vec2f vec2f = new Vec2f(this.rotationPitch, this.rotationYaw);
return vec2f;
}
示例13: getMoveVector
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
public Vec2f getMoveVector()
{
return new Vec2f(this.moveStrafe, this.moveForward);
}
示例14: set
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
public void set(final String name, final Vec2f vector) throws ShaderException {
this.set(name, vector.x, vector.y);
}
示例15: getMouseAngle
import net.minecraft.util.math.Vec2f; //导入依赖的package包/类
public double getMouseAngle(Vec2f referencePoint, Vec2f mousePos) {
Vec2f relativePos = new Vec2f(mousePos.x - referencePoint.x, mousePos.y - referencePoint.y);
double degrees = Math.toDegrees(Math.atan2(relativePos.y, relativePos.x));
return sanitizeDegree(degrees);
}