@Override public ItemTransformVec3f deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = p_deserialize_1_.getAsJsonObject(); Vector3f vector3f = this.parseVector3f(jsonobject, "rotation", ROTATION_DEFAULT); Vector3f vector3f1 = this.parseVector3f(jsonobject, "translation", TRANSLATION_DEFAULT); vector3f1.scale(0.0625F); vector3f1.x = MathHelper.clamp(vector3f1.x, -5.0F, 5.0F); vector3f1.y = MathHelper.clamp(vector3f1.y, -5.0F, 5.0F); vector3f1.z = MathHelper.clamp(vector3f1.z, -5.0F, 5.0F); Vector3f vector3f2 = this.parseVector3f(jsonobject, "scale", SCALE_DEFAULT); vector3f2.x = MathHelper.clamp(vector3f2.x, -4.0F, 4.0F); vector3f2.y = MathHelper.clamp(vector3f2.y, -4.0F, 4.0F); vector3f2.z = MathHelper.clamp(vector3f2.z, -4.0F, 4.0F); return new ItemTransformVec3f(vector3f, vector3f1, vector3f2); }
/** * Called to update the entity's position/logic. */ public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if (this.particleAge++ >= this.particleMaxAge) { this.setExpired(); } float percent = (float) this.particleAge / (float) this.particleMaxAge; Vector3f dir = Vector3f.sub(to, from, null); Vector3f spiralDir = Vector3f.cross(dir.normalise(null), up, null); spiralDir.scale((float) Math.sin((particleAge + startTime) * 0.5) * orbitRadius); Vector3f up = new Vector3f(this.up); up.scale((float) Math.cos((particleAge + startTime) * 0.5) * orbitRadius); Vector3f.add(spiralDir, up, spiralDir); dir.scale(percent); Vector3f posOnPath = Vector3f.add(from, dir, null); setPosition(posOnPath.x + spiralDir.x, posOnPath.y + spiralDir.y, posOnPath.z + spiralDir.z); } }
@SideOnly(Side.CLIENT) public void SpawnReplicateParticles(Entity entity, Vector3f p) { double entityRadius = entity.width; double entityArea = Math.max(entityRadius * entity.height, 0.3); double radiusX = entityRadius + random.nextDouble() * 0.2f; double radiusZ = entityRadius + random.nextDouble() * 0.2f; double time = Math.min((double) (transportTimer) / (double) (getTransportDelay()), 1); double gravity = 0.015f; int age = (int) Math.round(MOMathHelper.easeIn(time, 5, 15, 1)); int count = (int) Math.round(MOMathHelper.easeIn(time, 2, entityArea * 15, 1)); for (int i = 0; i < count; i++) { float speed = random.nextFloat() * 0.05f + 0.15f; float height = p.y + 1 + random.nextFloat() * entity.height; Vector3f origin = new Vector3f(p.x, height, p.z); Vector3f pos = MOMathHelper.randomSpherePoint(origin.x, origin.y, origin.z, new Vec3d(radiusX, 0, radiusZ), random); Vector3f dir = Vector3f.cross(Vector3f.sub(origin, pos, null), new Vector3f(0, 1, 0), null); dir.scale(speed); ReplicatorParticle replicatorParticle = new ReplicatorParticle(this.world, pos.x, pos.y, pos.z, dir.x, dir.y, dir.z); replicatorParticle.setCenter(origin.x, origin.y, origin.z); replicatorParticle.setParticleAge(age); replicatorParticle.setPointGravityScale(gravity); Minecraft.getMinecraft().effectRenderer.addEffect(replicatorParticle); } }
@Override public ItemTransformVec3f deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject object = element.getAsJsonObject(); Vector3f rotation = this.parseVector3f(object, "rotation", ROTATION_DEFAULT); Vector3f translation = this.parseVector3f(object, "translation", TRANSLATION_DEFAULT); translation.scale(0.0625F); translation.x = MathHelper.clamp(translation.x, -5.0F, 5.0F); translation.y = MathHelper.clamp(translation.y, -5.0F, 5.0F); translation.z = MathHelper.clamp(translation.z, -5.0F, 5.0F); Vector3f scale = this.parseVector3f(object, "scale", SCALE_DEFAULT); scale.x = MathHelper.clamp(scale.x, -4.0F, 4.0F); scale.y = MathHelper.clamp(scale.y, -4.0F, 4.0F); scale.z = MathHelper.clamp(scale.z, -4.0F, 4.0F); return new ItemTransformVec3f(rotation, translation, scale); }
@SideOnly(Side.CLIENT) public void SpawnReplicateParticles(int startTime) { double time = (double) (startTime) / (double) (REPLICATION_ANIMATION_TIME); double gravity = MOMathHelper.easeIn(time, 0.02, 0.2, 1); int age = (int) Math.round(MOMathHelper.easeIn(time, 2, 10, 1)); int count = (int) Math.round(MOMathHelper.easeIn(time, 1, 20, 1)); for (int i = 0; i < count; i++) { float speed = 0.05f; Vector3f pos = MOMathHelper.randomSpherePoint(this.getPos().getX() + 0.5D, this.getPos().getY() + 0.5D, this.getPos().getZ() + 0.5D, new Vec3d(0.5, 0.5, 0.5), this.world.rand); Vector3f dir = new Vector3f(random.nextFloat() * 2 - 1, (random.nextFloat() * 2 - 1) * 0.05f, random.nextFloat() * 2 - 1); dir.scale(speed); ReplicatorParticle replicatorParticle = new ReplicatorParticle(this.world, pos.getX(), pos.getY(), pos.getZ(), dir.getX(), dir.getY(), dir.getZ()); replicatorParticle.setCenter(this.getPos().getX() + 0.5D, this.getPos().getY() + 0.5D, this.getPos().getZ() + 0.5D); replicatorParticle.setParticleAge(age); replicatorParticle.setPointGravityScale(gravity); Minecraft.getMinecraft().effectRenderer.addEffect(replicatorParticle); } }
circle.scale(0.4f); Vector4f circleTransformed = new Vector4f(circle.x, circle.y, circle.z, 1); Matrix4f.transform(rotation, circleTransformed, circleTransformed);