use of net.minecraft.client.util.math.Vector3f in project Biome-Makeover by Lemonszz.
the class LightningBugInnerFeatureRenderer method getColor.
public Vector3f getColor(LightningBugEntity entity, float delta) {
BlockPos pos = entity.getBlockPos();
int redHash = pos.hashCode();
int greenHash = (pos.getX() + pos.getY() * 31) * 31 + pos.getZ();
int blueHash = (pos.getZ() + pos.getX() * 31) * 31 + pos.getY();
float drawRed = 1F, drawGreen = 1F, drawBlue = 1F;
float rTarget = (redHash % 255) / 255F;
float bTarget = (greenHash % 255) / 255F;
float gTarget = (blueHash % 255) / 255F;
if (entity.prevRed == -1) {
drawRed = rTarget;
drawGreen = gTarget;
drawBlue = bTarget;
} else {
drawRed = MathUtils.approachValue(entity.prevRed, rTarget, 0.025F * delta);
drawGreen = MathUtils.approachValue(entity.prevGreen, gTarget, 0.025F * delta);
drawBlue = MathUtils.approachValue(entity.prevBlue, bTarget, 0.025F * delta);
}
entity.prevRed = drawRed;
entity.prevGreen = drawGreen;
entity.prevBlue = drawBlue;
return new Vector3f(drawRed, drawGreen, drawBlue);
}
use of net.minecraft.client.util.math.Vector3f in project Biome-Makeover by Lemonszz.
the class DecayedItemFeatureRenderer method renderShield.
private void renderShield(LivingEntity entity, ItemStack stack, ModelTransformation.Mode transformationMode, Arm arm, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
if (!stack.isEmpty()) {
matrices.push();
this.getContextModel().setArmAngle(arm, matrices);
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90.0F));
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180.0F));
boolean isLeft = arm == Arm.LEFT;
matrices.translate(2F * (isLeft ? 1F : -1F) / 16.0F, 0.3D, -0.625D);
Vector3f dirY = isLeft ? Vector3f.NEGATIVE_Y : Vector3f.POSITIVE_Y;
Vector3f dirZ = isLeft ? Vector3f.POSITIVE_Z : Vector3f.NEGATIVE_Z;
Vector3f dirX = Vector3f.NEGATIVE_X;
matrices.multiply(dirY.getDegreesQuaternion(60));
matrices.multiply(dirZ.getDegreesQuaternion(0));
matrices.multiply(dirX.getDegreesQuaternion(25));
MinecraftClient.getInstance().getHeldItemRenderer().renderItem(entity, stack, transformationMode, isLeft, matrices, vertexConsumers, light);
matrices.pop();
}
}
use of net.minecraft.client.util.math.Vector3f in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class SmoothModelPart method renderSmoothCuboids.
private void renderSmoothCuboids(MatrixStack.Entry defaultEntry, MatrixStack.Entry childEntry, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
Matrix4f defaultPosMat = defaultEntry.getModel();
Matrix3f defaultNormal = defaultEntry.getNormal();
Matrix4f childPosMat = childEntry.getModel();
Matrix3f childNormal = childEntry.getNormal();
ObjectList<Cuboid> cuboids = ((ModelPartAccessor) this).getCuboids();
for (Cuboid cuboid : cuboids) {
Quad[] quads = ((CuboidAccessor) cuboid).getQuads();
// ここで値取ってこれと一致する頂点をーの方がいいかもね
int indexQ = 0;
for (Quad quad : quads) {
Direction quadDirection = getQuadDirection(indexQ++);
Vector3f defaultNormalVec = quad.direction.copy();
defaultNormalVec.transform(defaultNormal);
Vector3f smoothNormalVec = quad.direction.copy();
smoothNormalVec.transform(childNormal);
int indexV = 0;
for (Vertex vertex : quad.vertices) {
Vector4f posVec = new Vector4f(vertex.pos.getX() / 16.0F, vertex.pos.getY() / 16.0F, vertex.pos.getZ() / 16.0F, 1.0F);
if (shouldRotate(indexV++, quadDirection, direction)) {
posVec.transform(childPosMat);
vertexConsumer.vertex(posVec.getX(), posVec.getY(), posVec.getZ(), red, green, blue, alpha, vertex.u, vertex.v, overlay, light, smoothNormalVec.getX(), smoothNormalVec.getY(), smoothNormalVec.getZ());
} else {
posVec.transform(defaultPosMat);
vertexConsumer.vertex(posVec.getX(), posVec.getY(), posVec.getZ(), red, green, blue, alpha, vertex.u, vertex.v, overlay, light, defaultNormalVec.getX(), defaultNormalVec.getY(), defaultNormalVec.getZ());
}
}
}
}
}
use of net.minecraft.client.util.math.Vector3f in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class ModelRenderer method doRender.
private void doRender(MatrixStack.Entry matrixEntryIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
Matrix4f matrix4f = matrixEntryIn.getModel();
Matrix3f matrix3f = matrixEntryIn.getNormal();
for (ModelBoxBase modelBoxBase : this.cubeList) {
for (ModelBoxBase.TexturedQuad quad : modelBoxBase.quadList) {
// 互換性のためにnormalを@Nullableにしているため、ここで計算する
if (quad.normal == null) {
Vector3f n1 = quad.vertexPositions[0].position.copy();
Vector3f n2 = quad.vertexPositions[2].position.copy();
n1.subtract(quad.vertexPositions[1].position);
n2.subtract(quad.vertexPositions[1].position);
n2.cross(n1);
n2.normalize();
quad.normal = n2;
}
Vector3f normal = quad.normal.copy();
normal.transform(matrix3f);
float normalX = normal.getX();
float normalY = normal.getY();
float normalZ = normal.getZ();
for (int i = 0; i < 4; ++i) {
ModelBoxBase.PositionTextureVertex vertex = quad.vertexPositions[i];
float f3 = vertex.position.getX() / 16.0F;
float f4 = vertex.position.getY() / 16.0F;
float f5 = vertex.position.getZ() / 16.0F;
Vector4f vector4f = new Vector4f(f3, f4, f5, 1.0F);
vector4f.transform(matrix4f);
bufferIn.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), red, green, blue, alpha, vertex.textureU, vertex.textureV, packedOverlayIn, packedLightIn, normalX, normalY, normalZ);
}
}
}
}
use of net.minecraft.client.util.math.Vector3f in project MCDungeonsWeapons by chronosacaria.
the class ProjectileEffectHelper method fireChainReactionProjectileFromVictim.
private static void fireChainReactionProjectileFromVictim(World world, LivingEntity attacker, LivingEntity victim, ItemStack projectileStack, float v1, float v2, float centerOffset, PersistentProjectileEntity originalArrow) {
if (!world.isClient) {
PersistentProjectileEntity projectile;
projectile = createChainReactionProjectile(world, attacker, projectileStack, originalArrow);
projectile.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
Vec3d upVector = victim.getOppositeRotationVector(1.0F);
Quaternion quaternion = new Quaternion(new Vector3f(upVector), centerOffset, true);
Vec3d lookVector = victim.getRotationVec(1.0F);
Vector3f vector3f = new Vector3f(lookVector);
vector3f.rotate(quaternion);
projectile.setVelocity((double) vector3f.getX(), (double) vector3f.getY(), (double) vector3f.getZ(), v1, v2);
world.spawnEntity(projectile);
}
}
Aggregations