use of hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle in project Fracture by HellFirePvP.
the class EffectHandler method tick.
public void tick() {
if (cleanRequested) {
for (Integer layer : complexEffects.keySet()) {
List<EntityFX> effects = complexEffects.get(layer);
effects.forEach(EntityFX::flagAsRemoved);
effects.clear();
}
fastRenderParticles.clear();
fastRenderLightnings.clear();
toAddBuffer.clear();
cleanRequested = false;
}
if (Minecraft.getMinecraft().player == null) {
return;
}
acceptsNewParticles = false;
for (Integer layer : complexEffects.keySet()) {
Iterator<EntityFX> iterator = complexEffects.get(layer).iterator();
while (iterator.hasNext()) {
EntityFX effect = iterator.next();
effect.tick();
if (effect.needsRemoval()) {
effect.flagAsRemoved();
iterator.remove();
}
}
}
Vector3 playerPos = Vector3.atEntityCenter(Minecraft.getMinecraft().player);
for (EntityFXFacingParticle effect : new ArrayList<>(fastRenderParticles)) {
if (effect == null) {
fastRenderParticles.remove(null);
continue;
}
effect.tick();
if (effect.needsRemoval() || effect.getPosition().distanceSquared(playerPos) >= Config.maxEffectRenderDistanceSq) {
effect.flagAsRemoved();
fastRenderParticles.remove(effect);
}
}
for (EffectLightning effect : new ArrayList<>(fastRenderLightnings)) {
if (effect == null) {
fastRenderLightnings.remove(null);
continue;
}
effect.tick();
if (effect.needsRemoval()) {
effect.flagAsRemoved();
fastRenderLightnings.remove(effect);
}
}
acceptsNewParticles = true;
List<EntityFX> effects = new LinkedList<>(toAddBuffer);
toAddBuffer.clear();
for (EntityFX eff : effects) {
registerUnsafe(eff);
}
}
use of hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle in project SomeModjam5Mod by HellFirePvP.
the class TileFissureDevice method playEffects.
@SideOnly(Side.CLIENT)
private void playEffects() {
int depth = getStructureDepth();
if (depth > 0) {
if (headFloatingCube1 == null || ((EntityFXFloatingCube) headFloatingCube1).isRemoved()) {
headFloatingCube1 = setupCube(0.35F, 0.3F);
}
if (headFloatingCube2 == null || ((EntityFXFloatingCube) headFloatingCube2).isRemoved()) {
headFloatingCube2 = setupCube(0.3F, 0.2F);
}
if (headFloatingCube3 == null || ((EntityFXFloatingCube) headFloatingCube3).isRemoved()) {
headFloatingCube3 = setupCube(0.25F, 0.04F);
}
handleAnimations(headFloatingCube1);
handleAnimations(headFloatingCube2);
handleAnimations(headFloatingCube3);
if (this.percActive >= 1F && rand.nextFloat() >= 0.8F) {
EffectLightning lightning = EffectHandler.getInstance().lightning(new Vector3(0.4 + rand.nextFloat() * 0.2, 0.1 - depth, 0.4 + rand.nextFloat() * 0.2).add(getPos()), new Vector3(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).add(getPos()));
lightning.setOverlayColor(new Color(0x2DE400));
}
if (this.percActive > 0) {
for (int i = 0; i < depth * 6; i++) {
if (rand.nextFloat() <= this.percActive) {
EntityFXFacingParticle p = new EntityFXFacingParticle(30);
p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
p.setColor(new Color(0x2DE400));
p.setPosition(new Vector3(getPos()).add(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).addY(-rand.nextFloat() * (0.3 + depth)));
p.setScale(0.05F + rand.nextFloat() * 0.05F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.006F));
EffectHandler.getInstance().registerFX(p);
}
}
}
FissureData otherData = FissureDataController.getFissureData(this.getLinkedDimension(), this.getLinkedPos());
playOuterCube(otherData);
if (this.percDrawFissure > 0 && otherData != null) {
if (percDrawFissure < 1F) {
float chance = 1F - Math.abs((percDrawFissure - 0.5F) * 1.6F);
for (int i = 0; i < 19; i++) {
if (rand.nextFloat() < chance) {
Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(Vector3.random().multiply(2.5)).addY(1.3);
Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-15);
EntityFXFacingParticle p = new EntityFXFacingParticle(30);
p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
p.setColor(new Color(0x2DE400));
p.setPosition(particlePos);
p.setScale(0.03F + rand.nextFloat() * 0.03F);
p.setAlphaMultiplier(0.85F);
p.setMotion(dir);
EffectHandler.getInstance().registerFX(p);
}
}
} else {
Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
Vector3 randPos = new Vector3(otherData.getMin());
randPos.addX(vecSub.getX() * rand.nextFloat());
randPos.addY(vecSub.getY() * rand.nextFloat());
randPos.addZ(vecSub.getZ() * rand.nextFloat());
randPos.add(getPos());
EntityFXFacingParticle p = new EntityFXFacingParticle(60);
p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
p.setColor(new Color(0x2DE400));
p.setPosition(randPos);
p.setScale(0.02F + rand.nextFloat() * 0.03F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.01F));
EffectHandler.getInstance().registerFX(p);
for (int i = 0; i < 4; i++) {
p = new EntityFXFacingParticle(40);
p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
p.setColor(new Color(0x2DE400));
p.setPosition(new Vector3(getPos()).add(0.5, 1.3, 0.5));
p.setScale(0.015F + rand.nextFloat() * 0.02F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.015F));
EffectHandler.getInstance().registerFX(p);
}
if (rand.nextInt(6) == 0) {
Vector3 randFrom = new Vector3(otherData.getMin());
randFrom.addX(vecSub.getX() * rand.nextFloat());
randFrom.addY(vecSub.getY() * rand.nextFloat());
randFrom.addZ(vecSub.getZ() * rand.nextFloat());
randFrom.add(getPos());
Vector3 randTo = new Vector3(otherData.getMin());
randTo.addX(vecSub.getX() * rand.nextFloat());
randTo.addY(vecSub.getY() * rand.nextFloat());
randTo.addZ(vecSub.getZ() * rand.nextFloat());
randTo.add(getPos());
Vector3 dst = randTo.clone().subtract(randFrom);
if (dst.length() > 6) {
dst.normalize().multiply(6);
}
EffectLightning eff = EffectHandler.getInstance().lightning(randFrom, randFrom.clone().add(dst));
eff.setOverlayColor(new Color(0x2DE400));
}
}
}
}
}
use of hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle in project SomeModjam5Mod by HellFirePvP.
the class EffectHandler method tick.
public void tick() {
if (cleanRequested) {
for (Integer layer : complexEffects.keySet()) {
List<EntityFX> effects = complexEffects.get(layer);
effects.forEach(EntityFX::flagAsRemoved);
effects.clear();
}
fastRenderParticles.clear();
fastRenderLightnings.clear();
toAddBuffer.clear();
cleanRequested = false;
}
if (Minecraft.getMinecraft().player == null) {
return;
}
acceptsNewParticles = false;
for (Integer layer : complexEffects.keySet()) {
Iterator<EntityFX> iterator = complexEffects.get(layer).iterator();
while (iterator.hasNext()) {
EntityFX effect = iterator.next();
effect.tick();
if (effect.needsRemoval()) {
effect.flagAsRemoved();
iterator.remove();
}
}
}
Vector3 playerPos = Vector3.atEntityCenter(Minecraft.getMinecraft().player);
for (EntityFXFacingParticle effect : new ArrayList<>(fastRenderParticles)) {
if (effect == null) {
fastRenderParticles.remove(null);
continue;
}
effect.tick();
if (effect.needsRemoval() || effect.getPosition().distanceSquared(playerPos) >= Config.maxEffectRenderDistanceSq) {
effect.flagAsRemoved();
fastRenderParticles.remove(effect);
}
}
for (EffectLightning effect : new ArrayList<>(fastRenderLightnings)) {
if (effect == null) {
fastRenderLightnings.remove(null);
continue;
}
effect.tick();
if (effect.needsRemoval()) {
effect.flagAsRemoved();
fastRenderLightnings.remove(effect);
}
}
acceptsNewParticles = true;
List<EntityFX> effects = new LinkedList<>(toAddBuffer);
toAddBuffer.clear();
for (EntityFX eff : effects) {
registerUnsafe(eff);
}
}
use of hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle in project Fracture by HellFirePvP.
the class TileFissureDevice method playEffects.
@SideOnly(Side.CLIENT)
private void playEffects() {
int depth = getStructureDepth();
if (depth > 0) {
if (headFloatingCube1 == null || ((EntityFXFloatingCube) headFloatingCube1).isRemoved()) {
headFloatingCube1 = setupCube(0.35F, 0.3F);
}
if (headFloatingCube2 == null || ((EntityFXFloatingCube) headFloatingCube2).isRemoved()) {
headFloatingCube2 = setupCube(0.3F, 0.2F);
}
if (headFloatingCube3 == null || ((EntityFXFloatingCube) headFloatingCube3).isRemoved()) {
headFloatingCube3 = setupCube(0.25F, 0.04F);
}
handleAnimations(headFloatingCube1);
handleAnimations(headFloatingCube2);
handleAnimations(headFloatingCube3);
if (this.percActive >= 1F && rand.nextFloat() >= 0.8F) {
EffectLightning lightning = EffectHandler.getInstance().lightning(new Vector3(0.4 + rand.nextFloat() * 0.2, 0.1 - depth, 0.4 + rand.nextFloat() * 0.2).add(getPos()), new Vector3(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).add(getPos()));
lightning.setOverlayColor(new Color(0x2DE400));
}
if (this.percActive > 0) {
for (int i = 0; i < depth * 6; i++) {
if (rand.nextFloat() <= this.percActive) {
EntityFXFacingParticle p = new EntityFXFacingParticle(30);
p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
p.setColor(new Color(0x2DE400));
p.setPosition(new Vector3(getPos()).add(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).addY(-rand.nextFloat() * (0.3 + depth)));
p.setScale(0.05F + rand.nextFloat() * 0.05F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.006F));
EffectHandler.getInstance().registerFX(p);
}
}
}
FissureData otherData = FissureDataController.getFissureData(this.getLinkedDimension(), this.getLinkedPos());
if (this.swapPerc > 0F) {
for (int i = 0; i < 40; i++) {
if (rand.nextFloat() < this.swapPerc) {
Vector3 offset = Vector3.random().multiply(2.5);
if (rand.nextBoolean()) {
offset = Vector3.random();
}
Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(offset).addY(1.3);
Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-20);
EntityFXFacingParticle p = new EntityFXFacingParticle(30);
p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
p.setColor(new Color(0x2DE400));
p.setPosition(particlePos);
p.setScale(0.03F + rand.nextFloat() * 0.03F);
p.setAlphaMultiplier(0.85F);
p.setMotion(dir);
EffectHandler.getInstance().registerFX(p);
}
}
for (int i = 0; i < 2; i++) {
if (rand.nextFloat() < this.swapPerc && otherData != null) {
Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
Vector3 randFrom = new Vector3(otherData.getMin());
randFrom.addX(vecSub.getX() * rand.nextFloat());
randFrom.addY(vecSub.getY() * rand.nextFloat());
randFrom.addZ(vecSub.getZ() * rand.nextFloat());
randFrom.add(getPos());
Vector3 randTo = new Vector3(otherData.getMin());
randTo.addX(vecSub.getX() * rand.nextFloat());
randTo.addY(vecSub.getY() * rand.nextFloat());
randTo.addZ(vecSub.getZ() * rand.nextFloat());
randTo.add(getPos());
Vector3 dst = randTo.clone().subtract(randFrom);
if (dst.length() > 6) {
dst.normalize().multiply(6);
}
EffectLightning eff = EffectHandler.getInstance().lightning(randFrom, randFrom.clone().add(dst));
eff.setOverlayColor(new Color(0x2DE400));
}
}
}
playOuterCube(otherData);
if (this.percDrawFissure > 0 && otherData != null) {
if (percDrawFissure < 1F) {
float chance = 1F - Math.abs((percDrawFissure - 0.5F) * 1.6F);
for (int i = 0; i < 19; i++) {
if (rand.nextFloat() < chance) {
Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(Vector3.random().multiply(2.5)).addY(1.3);
Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-20);
EntityFXFacingParticle p = new EntityFXFacingParticle(30);
p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
p.setColor(new Color(0x2DE400));
p.setPosition(particlePos);
p.setScale(0.03F + rand.nextFloat() * 0.03F);
p.setAlphaMultiplier(0.85F);
p.setMotion(dir);
EffectHandler.getInstance().registerFX(p);
}
}
} else {
Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
Vector3 randPos = new Vector3(otherData.getMin());
randPos.addX(vecSub.getX() * rand.nextFloat());
randPos.addY(vecSub.getY() * rand.nextFloat());
randPos.addZ(vecSub.getZ() * rand.nextFloat());
randPos.add(getPos());
EntityFXFacingParticle p = new EntityFXFacingParticle(60);
p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
p.setColor(new Color(0x2DE400));
p.setPosition(randPos);
p.setScale(0.02F + rand.nextFloat() * 0.03F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.01F));
EffectHandler.getInstance().registerFX(p);
for (int i = 0; i < 4; i++) {
p = new EntityFXFacingParticle(40);
p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
p.setColor(new Color(0x2DE400));
p.setPosition(new Vector3(getPos()).add(0.5, 1.3, 0.5));
p.setScale(0.015F + rand.nextFloat() * 0.02F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.015F));
EffectHandler.getInstance().registerFX(p);
}
if (rand.nextInt(6) == 0) {
Vector3 randFrom = new Vector3(otherData.getMin());
randFrom.addX(vecSub.getX() * rand.nextFloat());
randFrom.addY(vecSub.getY() * rand.nextFloat());
randFrom.addZ(vecSub.getZ() * rand.nextFloat());
randFrom.add(getPos());
Vector3 randTo = new Vector3(otherData.getMin());
randTo.addX(vecSub.getX() * rand.nextFloat());
randTo.addY(vecSub.getY() * rand.nextFloat());
randTo.addZ(vecSub.getZ() * rand.nextFloat());
randTo.add(getPos());
Vector3 dst = randTo.clone().subtract(randFrom);
if (dst.length() > 6) {
dst.normalize().multiply(6);
}
EffectLightning eff = EffectHandler.getInstance().lightning(randFrom, randFrom.clone().add(dst));
eff.setOverlayColor(new Color(0x2DE400));
}
}
}
}
}
Aggregations