- Added some effect stuff

This commit is contained in:
HellFirePvP committed 2015-11-17 18:45:20 +01:00
1 parent cbcf92016d
commit 3d494de9bc
9 files changed
+1330

No files matched your search

@@ -5,6 +5,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import makeo.gadomancy.client.effect.EffectHandler;
import makeo.gadomancy.client.events.ClientTickHandler;
import makeo.gadomancy.client.events.RenderEventHandler;
import makeo.gadomancy.client.events.ResourceReloadListener;
@@ -155,6 +156,7 @@ public class ClientProxy extends CommonProxy {
rm.registerReloadListener(new ResourceReloadListener());
}
MinecraftForge.EVENT_BUS.register(EffectHandler.getInstance());
MinecraftForge.EVENT_BUS.register(new RenderEventHandler());
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
@@ -0,0 +1,103 @@
package makeo.gadomancy.client.effect;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import makeo.gadomancy.client.effect.fx.EntityFXFlow;
import makeo.gadomancy.client.effect.fx.Orbital;
import makeo.gadomancy.common.utils.Vector3;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* This class is part of the Gadomancy Mod
* Gadomancy is Open Source and distributed under the
* GNU LESSER GENERAL PUBLIC LICENSE
* for more read the LICENSE file
*
* Created by HellFirePvP @ 17.11.2015 18:39
*/
public class EffectHandler {
public static final EffectHandler instance = new EffectHandler();
public static List<Orbital> orbitals = new ArrayList<Orbital>();
public static Lock orbitalsRWLock = new NonReentrantReentrantLock();
public static EffectHandler getInstance() {
return instance;
}
@SubscribeEvent
public void onRender(RenderWorldLastEvent event) {
Tessellator tessellator = Tessellator.instance;
EntityFXFlow.FXFlowBase.sheduleRender(tessellator);
Orbital.sheduleRenders(orbitals, event.partialTicks);
}
public EntityFXFlow effectFlow(World world, Vector3 origin, EntityFXFlow.EntityFlowProperties properties) {
EntityFXFlow flow = new EntityFXFlow(world);
flow.applyProperties(properties);
flow.setPosition(origin.getX(), origin.getY(), origin.getZ());
world.spawnEntityInWorld(flow);
return flow;
}
public void registerOrbital(final Orbital orbital) {
new Thread(new Runnable() {
@Override
public void run() {
orbitalsRWLock.lock();
try {
orbitals.add(orbital);
} finally {
orbitalsRWLock.unlock();
}
}
}).start();
}
public void unregisterOrbital(final Orbital orbital) {
new Thread(new Runnable() {
@Override
public void run() {
orbitalsRWLock.lock();
try {
orbitals.remove(orbital);
} finally {
orbitalsRWLock.unlock();
}
}
}).start();
}
public void tick() {
Orbital.tickOrbitals(orbitals);
}
public static class NonReentrantReentrantLock extends ReentrantLock {
@Override
public boolean isHeldByCurrentThread() {
return false;
}
@Override
public void lock() {
super.lock();
}
@Override
public void unlock() {
super.unlock();
}
}
}
@@ -0,0 +1,414 @@
package makeo.gadomancy.client.effect.fx;
import makeo.gadomancy.common.data.ModConfig;
import makeo.gadomancy.common.utils.MiscUtils;
import makeo.gadomancy.common.utils.SimpleResourceLocation;
import makeo.gadomancy.common.utils.Vector3;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.*;
/**
* HellFirePvP@Admin
* Date: 01.07.2015 / 09:22
* on SoulSorcery
* EntityFXFlow
*/
public class EntityFXFlow extends EntityThrowable {
private Color color;
private Color fadingColor;
private int policyCounter = 0;
private EntityFXFlowPolicy policy;
private Vector3 target = null;
private int livingTicks = -1;
private double motionBufferX, motionBufferY, motionBufferZ;
private float motionMultiplier = 1;
private float mainParticleSize = 0.2F;
private float surroundingParticleSize = 0.1F;
private float surroundingDistance = 0.8F;
private double unmodMotionBufX, unmodMotionBufY, unmodMotionBufZ;
public EntityFXFlow(World world) {
super(world);
setSize(0.0F, 0.0F); //Not visible
this.policy = EntityFXFlowPolicy.Policies.DEFAULT.getPolicy();
}
public EntityFXFlow applyTarget(Vector3 target) {
this.target = target;
return this;
}
public EntityFXFlow setSurroundingDistance(float surroundingDistance) {
this.surroundingDistance = (1 / surroundingDistance);
return this;
}
public EntityFXFlow setMainParticleSize(float newSize) {
this.mainParticleSize = newSize;
return this;
}
public EntityFXFlow setSurroundingParticleSize(float newSize) {
this.surroundingParticleSize = newSize;
return this;
}
public EntityFXFlow setLivingTicks(int livingTicks) {
this.livingTicks = livingTicks;
return this;
}
public EntityFXFlow setColor(Color newColor) {
this.fadingColor = this.color;
this.color = newColor;
return this;
}
public void setMotionMultiplier(float motionMultiplier) {
this.motionMultiplier = motionMultiplier;
}
public EntityFXFlow setMotion(double motionX, double motionY, double motionZ) {
this.unmodMotionBufX = motionX;
this.unmodMotionBufY = motionY;
this.unmodMotionBufZ = motionZ;
motionX *= motionMultiplier;
motionY *= motionMultiplier;
motionZ *= motionMultiplier;
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.motionBufferX = motionX;
this.motionBufferY = motionY;
this.motionBufferZ = motionZ;
return this;
}
@Override
public void onUpdate() {
this.calculateVelocity();
setVelocity(motionBufferX, motionBufferY, motionBufferZ);
if(target == null) {
livingTicks--;
if (livingTicks <= 0) setDead();
} else {
if(target.distanceSquared(getPositionVector()) < 1) {
setDead();
}
}
super.onUpdate();
this.inGround = false;
if (!isDead && worldObj.isRemote) {
policyCounter += 1;
doParticles();
}
}
private void calculateVelocity() {
if(target == null) return;
Vector3 pos = getPositionVector();
double motDirX = target.getX() - pos.getX();
double motDirY = target.getY() - pos.getY();
double motDirZ = target.getZ() - pos.getZ();
Vector3 mot = new Vector3(motDirX, motDirY, motDirZ).normalize().divide(4);
setMotion(mot.getX(), mot.getY(), mot.getZ());
}
private Vector3 getPositionVector() {
return new Vector3(posX, posY, posZ);
}
public void setPolicy(EntityFXFlowPolicy policy) {
this.policy = policy;
}
public void setPolicy(EntityFXFlowPolicy.Policies policy) {
this.policy = policy.getPolicy();
}
private void doParticles() {
FXFlowBase flow = new FXFlowBase(worldObj, posX, posY, posZ, color, mainParticleSize, 9, 240);
Minecraft.getMinecraft().effectRenderer.addEffect(flow); //Initial position.
double lastPosX = posX - (posX - lastTickPosX) / 2.0D;
double lastPosY = posY - (posY - lastTickPosY) / 2.0D;
double lastPosZ = posZ - (posZ - lastTickPosZ) / 2.0D;
FXFlowBase flow2 = new FXFlowBase(worldObj, lastPosX, lastPosY, lastPosZ, color, (float) (mainParticleSize * 0.8), 8, 240);
Minecraft.getMinecraft().effectRenderer.addEffect(flow2); //Consistency to last position
if(policy != null)
policy.doSubParticles(this, policyCounter, posX, posY, posZ, lastPosX, lastPosY, lastPosZ);
}
@Override
public float getGravityVelocity() {
return 0.0F;
}
public Color getColor() {
return color;
}
public Color getFadingColor() {
return fadingColor;
}
public float getSurroundingDistance() {
return surroundingDistance;
}
public float getSurroundingParticleSize() {
return surroundingParticleSize;
}
public float getMainParticleSize() {
return mainParticleSize;
}
public float getMotionMultiplier() {
return motionMultiplier;
}
public Random getRand() {
return rand;
}
public boolean isMovementVectorNullLength() {
return new Vector3(motionBufferX, motionBufferY, motionBufferZ).lengthSquared() == 0;
}
public Vector3 getTarget() {
return target;
}
public Vector3 getMovementVector() {
Vector3 motion = new Vector3(motionBufferX, motionBufferY, motionBufferZ);
if(motion.lengthSquared() == 0) return new Vector3(unmodMotionBufX, unmodMotionBufY, unmodMotionBufZ);
return motion;
}
@Override
public void onImpact(MovingObjectPosition obj) {}
public void applyProperties(EntityFlowProperties properties) {
if(properties != null) {
if(properties.hasTarget) {
applyTarget(properties.target);
}
if(properties.color != null) {
if(properties.fading != null) {
setColor(properties.fading);
setColor(properties.color);
} else {
setColor(properties.color);
}
} else {
if(properties.fading != null) {
setColor(properties.fading);
}
}
if(properties.livingTicks != -1)
setLivingTicks(properties.livingTicks);
if(properties.mainParticleSize != -1)
setMainParticleSize(properties.mainParticleSize);
if(properties.surroundingDistance != -1)
setSurroundingDistance(properties.surroundingDistance);
if(properties.surroundingParticleSize != -1)
setSurroundingParticleSize(properties.surroundingParticleSize);
if(properties.motionMultiplier != Float.MAX_VALUE) {
setMotionMultiplier(properties.motionMultiplier);
}
if(properties.policy != null) {
setPolicy(properties.policy);
}
}
}
public static class EntityFlowProperties {
protected boolean hasTarget;
protected Vector3 target;
protected Color color, fading;
protected EntityFXFlowPolicy policy;
protected float mainParticleSize = -1, surroundingParticleSize = -1, surroundingDistance = -1;
protected int livingTicks = -1;
protected float motionMultiplier = Float.MAX_VALUE;
public EntityFlowProperties() {}
public EntityFlowProperties setTarget(Vector3 target) {
this.hasTarget = target != null;
this.target = target;
return this;
}
public EntityFlowProperties setPolicy(EntityFXFlowPolicy policy) {
this.policy = policy;
return this;
}
public EntityFlowProperties setPolicy(EntityFXFlowPolicy.Policies policy) {
this.policy = policy.getPolicy();
return this;
}
public EntityFlowProperties setColor(Color color) {
this.color = color;
return this;
}
public EntityFlowProperties setMotionMultiplier(float motionMultiplier) {
this.motionMultiplier = motionMultiplier;
return this;
}
public EntityFlowProperties setFading(Color fading) {
this.fading = fading;
return this;
}
public EntityFlowProperties setMainParticleSize(float mainParticleSize) {
this.mainParticleSize = mainParticleSize;
return this;
}
public EntityFlowProperties setSurroundingParticleSize(float surroundingParticleSize) {
this.surroundingParticleSize = surroundingParticleSize;
return this;
}
public EntityFlowProperties setSurroundingDistance(float surroundingDistance) {
this.surroundingDistance = surroundingDistance;
return this;
}
public EntityFlowProperties setLivingTicks(int livingTicks) {
this.livingTicks = livingTicks;
return this;
}
}
public static class FXFlowBase extends EntityFX {
private static Queue<FXFlowBase> fxQueue = new ArrayDeque<FXFlowBase>();
private int partBlue, partGreen, partRed, partAlpha;
//Queue variables
private float partialTicks;
private float rendArg1, rendArg2, rendArg3, rendArg4, rendArg5;
private int rendBrightness;
private ResourceLocation texture = new SimpleResourceLocation("effect/flow_large.png");
private float buffQuadLife, buffParticleScale;
public FXFlowBase(World world, double x, double y, double z, Color color, float size, int multiplier, int brightness) {
super(world, x, y, z);
if(color != null) {
this.partBlue = color.getBlue();
this.partGreen = color.getGreen();
this.partRed = color.getRed();
this.partAlpha = color.getAlpha();
}
this.motionX = this.motionY = this.motionZ = 0;
this.particleScale *= size;
this.particleMaxAge = 3 * multiplier;
this.noClip = false;
this.setSize(0.01F, 0.01F);
this.particleAge = 0;
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.particleTextureIndexX = 0;
this.particleTextureIndexY = 0;
this.buffQuadLife = (this.particleMaxAge / 2);
this.buffParticleScale = this.particleScale;
this.rendBrightness = brightness;
this.noClip = true;
}
public static void sheduleRender(Tessellator tessellator) {
boolean isLightingEnabled = GL11.glGetBoolean(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
if(isLightingEnabled)
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
for(FXFlowBase fx : fxQueue) {
tessellator.startDrawingQuads();
fx.renderEssenceBase(tessellator);
tessellator.draw();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
if(isLightingEnabled)
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
fxQueue.clear();
}
private void renderEssenceBase(Tessellator tessellator) {
tessellator.setBrightness(rendBrightness);
GL11.glColor4f(partRed, partGreen, partBlue, partAlpha);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
if(particleAge >= particleMaxAge) return;
float agescale = (float) particleAge / buffQuadLife;
if(agescale >= 1.0F) agescale = 4 - agescale;
particleScale = buffParticleScale * agescale;
float f10 = 0.5F * particleScale;
float f11 = (float)(prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
float f12 = (float)(prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
float f13 = (float)(prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);
tessellator.addVertexWithUV(f11 - rendArg1 * f10 - rendArg4 * f10, f12 - rendArg2 * f10, f13 - rendArg3 * f10 - rendArg5 * f10, 0, 1);
tessellator.addVertexWithUV(f11 - rendArg1 * f10 + rendArg4 * f10, f12 + rendArg2 * f10, f13 - rendArg3 * f10 + rendArg5 * f10, 1, 1);
tessellator.addVertexWithUV(f11 + rendArg1 * f10 + rendArg4 * f10, f12 + rendArg2 * f10, f13 + rendArg3 * f10 + rendArg5 * f10, 1, 0);
tessellator.addVertexWithUV(f11 + rendArg1 * f10 - rendArg4 * f10, f12 - rendArg2 * f10, f13 + rendArg3 * f10 - rendArg5 * f10, 0, 0);
}
@Override
public void renderParticle(Tessellator tessellator, float partialTicks, float par3, float par4, float par5, float par6, float par7) {
if(MiscUtils.getPositionVector(Minecraft.getMinecraft().renderViewEntity).distance(new Vector3(posX, posY, posZ)) > ModConfig.renderParticleDistance) return;
this.partialTicks = partialTicks;
this.rendArg1 = par3;
this.rendArg2 = par4;
this.rendArg3 = par5;
this.rendArg4 = par6;
this.rendArg5 = par7;
fxQueue.add(this);
}
}
}
@@ -0,0 +1,100 @@
package makeo.gadomancy.client.effect.fx;
import makeo.gadomancy.common.utils.Vector3;
import net.minecraft.client.Minecraft;
import java.awt.*;
import java.util.Random;
/**
* HellFirePvP@Admin
* Date: 01.07.2015 / 18:27
* on SoulSorcery
* EntityFXFlowPolicy
*/
public abstract class EntityFXFlowPolicy {
public abstract void doSubParticles(EntityFXFlow fxFlow, int policyCounter, double posX, double posY, double posZ, double lastPosX, double lastPosY, double lastPosZ);
public enum Policies {
NO_OP(null),
CIRCLE_MIX(new CircularMixPolicy()),
CIRCLE(new CircularPolicy()),
DEFAULT(new DefaultPolicy());
private EntityFXFlowPolicy policy;
private Policies(EntityFXFlowPolicy policy) {
this.policy = policy;
}
public EntityFXFlowPolicy getPolicy() {
return policy;
}
}
static class DefaultPolicy extends EntityFXFlowPolicy {
@Override
public void doSubParticles(EntityFXFlow fxFlow, int policyCounter, double posX, double posY, double posZ, double lastPosX, double lastPosY, double lastPosZ) {
doParticles(fxFlow, policyCounter, posX, posY, posZ, fxFlow.getRand().nextInt(3) + 1);
}
public void doParticles(EntityFXFlow fxFlow, int policyCounter, double posX, double posY, double posZ, int count) {
Random rand = fxFlow.getRand();
for (int i = 0; i < count; i++) {
Vector3 subOffset = genSubOffset(rand, fxFlow.getSurroundingDistance());
Color c = (fxFlow.getFadingColor() != null && rand.nextBoolean()) ? fxFlow.getFadingColor() : fxFlow.getColor();
EntityFXFlow.FXFlowBase flow = new EntityFXFlow.FXFlowBase(fxFlow.worldObj, posX + subOffset.getX(), posY + subOffset.getY(), posZ + subOffset.getZ(), c, rand.nextInt(1) + fxFlow.getSurroundingParticleSize(), 6, 240);
Minecraft.getMinecraft().effectRenderer.addEffect(flow);
}
}
private Vector3 genSubOffset(Random rand, float surroundingDistance) {
float x = ((rand.nextFloat() / 4F) * surroundingDistance) * (rand.nextBoolean() ? 1 : -1);
float y = ((rand.nextFloat() / 4F) * surroundingDistance) * (rand.nextBoolean() ? 1 : -1);
float z = ((rand.nextFloat() / 4F) * surroundingDistance) * (rand.nextBoolean() ? 1 : -1);
return new Vector3(x, y, z);
}
}
static class CircularPolicy extends EntityFXFlowPolicy {
public static final int TICKS_PER_FULL_TURN = 40;
@Override
public void doSubParticles(EntityFXFlow fxFlow, int policyCounter, double posX, double posY, double posZ, double lastPosX, double lastPosY, double lastPosZ) {
Vector3 rotationAxis = fxFlow.getMovementVector();
Vector3 perpendicular = rotationAxis.clone().perpendicular().normalize().multiply(fxFlow.getSurroundingDistance());
Vector3 counterSide = perpendicular.clone().rotate(Math.toRadians(180), rotationAxis);
int currentDividedPolicyTick = policyCounter % TICKS_PER_FULL_TURN;
float currentDegree = 360F * (((float) currentDividedPolicyTick) / ((float) TICKS_PER_FULL_TURN));
double currentRad = Math.toRadians(currentDegree);
perpendicular = perpendicular.rotate(currentRad, rotationAxis);
counterSide = counterSide.rotate(currentRad, rotationAxis);
Color c = (fxFlow.getFadingColor() != null) ? fxFlow.getFadingColor() : fxFlow.getColor();
EntityFXFlow.FXFlowBase flow = new EntityFXFlow.FXFlowBase(fxFlow.worldObj, posX + perpendicular.getX(), posY + perpendicular.getY(), posZ + perpendicular.getZ(), c, fxFlow.getSurroundingParticleSize(), 6, 240);
Minecraft.getMinecraft().effectRenderer.addEffect(flow);
EntityFXFlow.FXFlowBase flow2 = new EntityFXFlow.FXFlowBase(fxFlow.worldObj, posX + counterSide.getX(), posY + counterSide.getY(), posZ + counterSide.getZ(), c, fxFlow.getSurroundingParticleSize(), 6, 240);
Minecraft.getMinecraft().effectRenderer.addEffect(flow2);
}
}
static class CircularMixPolicy extends CircularPolicy {
@Override
public void doSubParticles(EntityFXFlow fxFlow, int policyCounter, double posX, double posY, double posZ, double lastPosX, double lastPosY, double lastPosZ) {
super.doSubParticles(fxFlow, policyCounter, posX, posY, posZ, lastPosX, lastPosY, lastPosZ);
((DefaultPolicy) Policies.DEFAULT.getPolicy()).doParticles(fxFlow, policyCounter, posX, posY, posZ, fxFlow.getRand().nextInt(2));
}
}
}
@@ -0,0 +1,204 @@
package makeo.gadomancy.client.effect.fx;
import makeo.gadomancy.client.effect.EffectHandler;
import makeo.gadomancy.common.data.ModConfig;
import makeo.gadomancy.common.utils.MiscUtils;
import makeo.gadomancy.common.utils.Vector3;
import net.minecraft.client.Minecraft;
import net.minecraft.world.World;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/**
* HellFirePvP@Admin
* Date: 01.07.2015 / 19:28
* on SoulSorcery
* Orbital
*/
public final class Orbital {
private Vector3 center;
private final World world;
private int orbitalCounter = 0;
private List<OrbitalRenderProperties> orbitals = new ArrayList<OrbitalRenderProperties>();
public Orbital(Vector3 center, World world) {
this.center = center;
this.world = world;
}
public void updateCenter(Vector3 center) {
this.center = center;
}
public void addOrbitalPoint(OrbitalRenderProperties properties) {
if(!orbitals.contains(properties)) {
orbitals.add(properties);
}
}
public void doRender(float partialTicks) {
if(MiscUtils.getPositionVector(Minecraft.getMinecraft().renderViewEntity).distance(center) > ModConfig.renderParticleDistance) return;
for(OrbitalRenderProperties orbitalNode : orbitals) {
Axis axis = orbitalNode.getAxis();
int counterOffset = orbitalNode.getOffsetTicks() % orbitalNode.getTicksForFullCircle();
int currentDividedPolicyTick = (orbitalCounter + counterOffset) % orbitalNode.getTicksForFullCircle();
float currentDegree = 360F * (((float) currentDividedPolicyTick) / ((float) orbitalNode.getTicksForFullCircle()));
double currentRad = Math.toRadians(currentDegree);
Vector3 point = axis.getAxis().clone().perpendicular().normalize().multiply(orbitalNode.getOffset()).rotate(currentRad, axis.getAxis()).add(center);
if(orbitalNode.getRunnable() != null) {
orbitalNode.getRunnable().onRender(point, orbitalNode, partialTicks);
}
EntityFXFlow.FXFlowBase flow = new EntityFXFlow.FXFlowBase(world, point.getX(), point.getY(), point.getZ(),
orbitalNode.getColor(), orbitalNode.getParticleSize(), orbitalNode.getMultiplier(), orbitalNode.getBrightness());
Minecraft.getMinecraft().effectRenderer.addEffect(flow);
}
}
public static void sheduleRenders(List<Orbital> orbitals, float partialTicks) {
EffectHandler.orbitalsRWLock.lock();
try {
for(Orbital orbital : orbitals) {
orbital.doRender(partialTicks);
}
} finally {
EffectHandler.orbitalsRWLock.unlock();
}
}
public static void tickOrbitals(List<Orbital> orbitals) {
EffectHandler.orbitalsRWLock.lock();
try {
for(Orbital orbital : orbitals) orbital.orbitalCounter++;
} finally {
EffectHandler.orbitalsRWLock.unlock();
}
}
public static class OrbitalRenderProperties {
private Axis axis;
private double offset;
private Color color = Color.WHITE;
private int ticksForFullCircle = 40;
private OrbitalRenderRunnable runnable = null;
private int multiplier = 8;
private int brightness = 240;
private float particleSize = 0.2F;
private int offsetTicks = 0;
public OrbitalRenderProperties(Axis axis, double offsetLength) {
this.offset = offsetLength;
this.axis = axis;
}
public OrbitalRenderProperties setColor(Color color) {
this.color = color;
return this;
}
public OrbitalRenderProperties setTicksForFullCircle(int ticks) {
this.ticksForFullCircle = ticks;
return this;
}
public OrbitalRenderProperties setRenderRunnable(OrbitalRenderRunnable runnable) {
this.runnable = runnable;
return this;
}
public OrbitalRenderProperties setBrightness(int brightness) {
this.brightness = brightness;
return this;
}
public OrbitalRenderProperties setMultiplier(int multiplier) {
this.multiplier = multiplier;
return this;
}
public OrbitalRenderProperties setOffsetTicks(int offsetTicks) {
this.offsetTicks = offsetTicks;
return this;
}
public OrbitalRenderProperties setParticleSize(float particleSize) {
this.particleSize = particleSize;
return this;
}
public float getParticleSize() {
return particleSize;
}
public Color getColor() {
return color;
}
public Axis getAxis() {
return axis;
}
public double getOffset() {
return offset;
}
public int getTicksForFullCircle() {
return ticksForFullCircle;
}
public OrbitalRenderRunnable getRunnable() {
return runnable;
}
public int getMultiplier() {
return multiplier;
}
public int getBrightness() {
return brightness;
}
public int getOffsetTicks() {
return offsetTicks;
}
}
public static abstract class OrbitalRenderRunnable {
public abstract void onRender(Vector3 selectedPosition, OrbitalRenderProperties properties, float partialTicks);
}
public static class Axis {
public static final Axis X_AXIS = new Axis(new Vector3(1, 0, 0));
public static final Axis Y_AXIS = new Axis(new Vector3(0, 1, 0));
public static final Axis Z_AXIS = new Axis(new Vector3(0, 0, 1));
private Vector3 axis;
public Axis(Vector3 axis) {
this.axis = axis;
}
public static Axis persisentRandomAxis() {
//Actually quite important to use only Y-positive here since if we
//would use negative y, the axis may turn counter-
//clockwise, what's intended to be set in another variable, which
//may cause bugs if we want to use only clockwise axis'.
return new Axis(Vector3.positiveYRandom());
}
public Vector3 getAxis() {
return axis.clone();
}
}
}
@@ -2,6 +2,7 @@ package makeo.gadomancy.client.events;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import makeo.gadomancy.client.effect.EffectHandler;
import makeo.gadomancy.client.util.FamiliarHandlerClient;
/**
@@ -21,6 +22,8 @@ public class ClientTickHandler {
if(event.phase.equals(TickEvent.Phase.END)) {
FamiliarHandlerClient.playerTickEvent();
ticks++;
EffectHandler.getInstance().tick();
}
}
@@ -31,6 +31,7 @@ public class ModConfig {
public static int dimOuterId = -73;
public static boolean doLightCalculations = true;
public static int maxMazeCount = -1;
public static int renderParticleDistance = 100;
//Skyblock stuff
@Sync
@@ -55,10 +56,13 @@ public class ModConfig {
entityNoClipItemDatawatcherFixedZId = config.getInt("itemNoClipDatawatchetFixZId", "entities", 22, 0, 31, "Do not edit unless you know what are you doing! - Datawatcher ID of the Z-Coordinates for EntityNoClipItem");
golemDatawatcherId = config.getInt("datawatcherId", "golem", 29, 0, 31, "Do not edit unless you know what are you doing!");
dimOuterId = config.getInt("dimOuterId", "dimension", -73, Integer.MIN_VALUE, Integer.MAX_VALUE, "Dimension Id for the eldrich mazes accessed via Node Manipulator");
doLightCalculations = config.getBoolean("calculateEldritchLight", "dimension", true, "TRUE = Calculating Light values for the Gadomancy-Eldritch Mazes; FALSE = No calculation, but some Light Bugs - Calculating the Light takes ~2 seconds -> Can be measured when trying to enter the eldritch mazed via Gadomancy Eldritch portal.");
maxMazeCount = config.getInt("maxMazeCount", "dimension", -1, -1, Integer.MAX_VALUE, "Defines how many Eldritch mazes may exist at the same time using the Gadomancy Eldritch ritual. (-1 = infinite) Note that 1 maze = 1 player; Once the player finishes the maze, the maze closes itself and teleports the player out.");
ancientStoneRecipes = config.getBoolean("ancientStoneRecipes", "skyblock", false, "TRUE = Adds recipes for Ancient Stone and Ancient Stone Pedestal (This may be usefull for severs and skyblock packs to craft the Node Manipulator and get more primodial pearls)");
renderParticleDistance = config.getInt("particleRenderDistance", "general", 100, 5, 1000, "Defines, how close a player has to be towards the particle origin to see the particles created by it.");
}
}
@@ -0,0 +1,61 @@
package makeo.gadomancy.common.utils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.util.FakePlayer;
import java.util.List;
import java.util.UUID;
/**
* HellFirePvP@Admin
* Date: 17.06.2015 / 13:59
* on SoulSorcery
* MiscUtils
*/
public final class MiscUtils {
private MiscUtils() {}
public static String getNumberSuffix(int number) {
int digit = number % 10;
switch (digit) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
}
return "th";
}
public static EntityPlayer getOnlinePlayerByUUID(UUID playerUUID) {
List<EntityPlayerMP> players = Minecraft.getMinecraft().getIntegratedServer().getConfigurationManager().playerEntityList;
for(EntityPlayerMP player : players) {
if(player.getGameProfile().getId().equals(playerUUID)) {
return player;
}
}
return null;
}
public static boolean isPlayerFakeMP(EntityPlayerMP player) {
if(player instanceof FakePlayer) return true;
if(player.getClass() != EntityPlayerMP.class) return true;
if(player.playerNetServerHandler == null) return true;
try {
player.getPlayerIP().length();
player.playerNetServerHandler.netManager.getSocketAddress().toString();
} catch (Exception exc) {
return true;
}
if(MinecraftServer.getServer().getConfigurationManager().playerEntityList == null) return true;
return !MinecraftServer.getServer().getConfigurationManager().playerEntityList.contains(player);
}
public static Vector3 getPositionVector(Entity e) {
return new Vector3(e.posX, e.posY, e.posZ);
}
}
@@ -0,0 +1,439 @@
package makeo.gadomancy.common.utils;
import java.util.Formatter;
import java.util.Locale;
import java.util.Random;
/**
* HellFirePvP@Admin
* Date: 25.06.2015 / 19:15
* on SoulSorcery
* Vector3
*/
public class Vector3 {
private static final Random RAND = new Random();
protected double x;
protected double y;
protected double z;
public Vector3() {
this.x = 0.0D;
this.y = 0.0D;
this.z = 0.0D;
}
public Vector3(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vector3(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vector3(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vector3 add(Vector3 vec) {
this.x += vec.x;
this.y += vec.y;
this.z += vec.z;
return this;
}
public Vector3 subtract(Vector3 vec) {
this.x -= vec.x;
this.y -= vec.y;
this.z -= vec.z;
return this;
}
public Vector3 multiply(Vector3 vec) {
this.x *= vec.x;
this.y *= vec.y;
this.z *= vec.z;
return this;
}
public Vector3 divide(Vector3 vec) {
this.x /= vec.x;
this.y /= vec.y;
this.z /= vec.z;
return this;
}
public Vector3 divide(double divisor) {
this.x /= divisor;
this.y /= divisor;
this.z /= divisor;
return this;
}
public Vector3 copy(Vector3 vec) {
this.x = vec.x;
this.y = vec.y;
this.z = vec.z;
return this;
}
public double length() {
return Math.sqrt(lengthSquared());
}
public double lengthSquared() {
return x * x + y * y + z * z;
}
public double distance(Vector3 o) {
return Math.sqrt(distanceSquared(o));
}
public double distanceSquared(Vector3 o) {
double difX = x - o.x;
double difY = y - o.y;
double difZ = z - o.z;
return difX * difX + difY * difY + difZ * difZ;
}
public float angle(Vector3 other) {
double dot = dot(other) / (length() * other.length());
return (float) Math.acos(dot);
}
public Vector3 midpoint(Vector3 other) {
this.x = ((this.x + other.x) / 2.0D);
this.y = ((this.y + other.y) / 2.0D);
this.z = ((this.z + other.z) / 2.0D);
return this;
}
public Vector3 getMidpoint(Vector3 other) {
double x = (this.x + other.x) / 2.0D;
double y = (this.y + other.y) / 2.0D;
double z = (this.z + other.z) / 2.0D;
return new Vector3(x, y, z);
}
public Vector3 multiply(int m) {
this.x *= m;
this.y *= m;
this.z *= m;
return this;
}
public Vector3 multiply(double m) {
this.x *= m;
this.y *= m;
this.z *= m;
return this;
}
public Vector3 multiply(float m) {
this.x *= m;
this.y *= m;
this.z *= m;
return this;
}
public double dot(Vector3 other) {
return this.x * other.x + this.y * other.y + this.z * other.z;
}
public Vector3 crossProduct(Vector3 o) {
double newX = this.y * o.z - o.y * this.z;
double newY = this.z * o.x - o.z * this.x;
double newZ = this.x * o.y - o.x * this.y;
this.x = newX;
this.y = newY;
this.z = newZ;
return this;
}
public Vector3 perpendicular() {
if (this.z == 0.0D) {
return zCrossProduct();
}
return xCrossProduct();
}
public Vector3 xCrossProduct() {
double d = this.z;
double d1 = -this.y;
this.x = 0.0D;
this.y = d;
this.z = d1;
return this;
}
public Vector3 zCrossProduct() {
double d = this.y;
double d1 = -this.x;
this.x = d;
this.y = d1;
this.z = 0.0D;
return this;
}
public Vector3 yCrossProduct() {
double d = -this.z;
double d1 = this.x;
this.x = d;
this.y = 0.0D;
this.z = d1;
return this;
}
public Vector3 rotate(double angle, Vector3 axis) {
Quat.aroundAxis(axis.clone().normalize(), angle).rotate(this);
return this;
}
public Vector3 normalize() {
double length = length();
this.x /= length;
this.y /= length;
this.z /= length;
return this;
}
public Vector3 zero() {
this.x = 0.0D;
this.y = 0.0D;
this.z = 0.0D;
return this;
}
public static Vector3 random() {
return new Vector3(RAND.nextDouble() * (RAND.nextBoolean() ? 1 : -1), RAND.nextDouble() * (RAND.nextBoolean() ? 1 : -1), RAND.nextDouble() * (RAND.nextBoolean() ? 1 : -1));
}
public static Vector3 positiveYRandom() {
return random().setY(Math.abs(random().getY()));
}
public boolean isInAABB(Vector3 min, Vector3 max) {
return (this.x >= min.x) && (this.x <= max.x) && (this.y >= min.y) && (this.y <= max.y) && (this.z >= min.z) && (this.z <= max.z);
}
public boolean isInSphere(Vector3 origin, double radius) {
double difX = origin.x - this.x;
double difY = origin.y - this.y;
double difZ = origin.z - this.z;
return (difX * difX + difY * difY + difZ * difZ) <= (radius * radius);
}
public Vector3 vectorFromHereTo(Vector3 target) {
return new Vector3(target.x - x, target.y - y, target.z - z);
}
public double getX() {
return this.x;
}
public int getBlockX() {
return (int) Math.floor(this.x);
}
public double getY() {
return this.y;
}
public int getBlockY() {
return (int) Math.floor(this.y);
}
public double getZ() {
return this.z;
}
public int getBlockZ() {
return (int) Math.floor(this.z);
}
public Vector3 setX(int x) {
this.x = x;
return this;
}
public Vector3 setX(double x) {
this.x = x;
return this;
}
public Vector3 setX(float x) {
this.x = x;
return this;
}
public Vector3 setY(int y) {
this.y = y;
return this;
}
public Vector3 setY(double y) {
this.y = y;
return this;
}
public Vector3 setY(float y) {
this.y = y;
return this;
}
public Vector3 setZ(int z) {
this.z = z;
return this;
}
public Vector3 setZ(double z) {
this.z = z;
return this;
}
public Vector3 setZ(float z) {
this.z = z;
return this;
}
public boolean equals(Object obj) {
if (!(obj instanceof Vector3)) {
return false;
}
Vector3 other = (Vector3) obj;
return (Math.abs(this.x - other.x) < 1.0E-006D) && (Math.abs(this.y - other.y) < 1.0E-006D) && (Math.abs(this.z - other.z) < 1.0E-006D) && (getClass().equals(obj.getClass()));
}
public int hashCode() {
int hash = 7;
hash = 79 * hash + (int) (Double.doubleToLongBits(this.x) ^ Double.doubleToLongBits(this.x) >>> 32);
hash = 79 * hash + (int) (Double.doubleToLongBits(this.y) ^ Double.doubleToLongBits(this.y) >>> 32);
hash = 79 * hash + (int) (Double.doubleToLongBits(this.z) ^ Double.doubleToLongBits(this.z) >>> 32);
return hash;
}
public Vector3 clone() {
return new Vector3(x, y, z);
}
public String toString() {
return this.x + "," + this.y + "," + this.z;
}
public static class Quat {
public double x;
public double y;
public double z;
public double s;
public Quat() {
this.s = 1.0D;
this.x = 0.0D;
this.y = 0.0D;
this.z = 0.0D;
}
public Quat(Quat quat) {
this.x = quat.x;
this.y = quat.y;
this.z = quat.z;
this.s = quat.s;
}
public Quat(double d, double d1, double d2, double d3) {
this.x = d1;
this.y = d2;
this.z = d3;
this.s = d;
}
public void set(Quat quat) {
this.x = quat.x;
this.y = quat.y;
this.z = quat.z;
this.s = quat.s;
}
public static Quat aroundAxis(double ax, double ay, double az, double angle) {
angle *= 0.5D;
double d4 = Math.sin(angle);
return new Quat(Math.cos(angle), ax * d4, ay * d4, az * d4);
}
public void multiply(Quat quat) {
double d = this.s * quat.s - this.x * quat.x - this.y * quat.y - this.z * quat.z;
double d1 = this.s * quat.x + this.x * quat.s - this.y * quat.z + this.z * quat.y;
double d2 = this.s * quat.y + this.x * quat.z + this.y * quat.s - this.z * quat.x;
double d3 = this.s * quat.z - this.x * quat.y + this.y * quat.x + this.z * quat.s;
this.s = d;
this.x = d1;
this.y = d2;
this.z = d3;
}
public void rightMultiply(Quat quat) {
double d = this.s * quat.s - this.x * quat.x - this.y * quat.y - this.z * quat.z;
double d1 = this.s * quat.x + this.x * quat.s + this.y * quat.z - this.z * quat.y;
double d2 = this.s * quat.y - this.x * quat.z + this.y * quat.s + this.z * quat.x;
double d3 = this.s * quat.z + this.x * quat.y - this.y * quat.x + this.z * quat.s;
this.s = d;
this.x = d1;
this.y = d2;
this.z = d3;
}
public double mag() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.s * this.s);
}
public void normalize() {
double d = mag();
if (d == 0.0D) {
return;
}
d = 1.0D / d;
this.x *= d;
this.y *= d;
this.z *= d;
this.s *= d;
}
public void rotate(Vector3 vec) {
double d = -this.x * vec.x - this.y * vec.y - this.z * vec.z;
double d1 = this.s * vec.x + this.y * vec.z - this.z * vec.y;
double d2 = this.s * vec.y - this.x * vec.z + this.z * vec.x;
double d3 = this.s * vec.z + this.x * vec.y - this.y * vec.x;
vec.x = (d1 * this.s - d * this.x - d2 * this.z + d3 * this.y);
vec.y = (d2 * this.s - d * this.y + d1 * this.z - d3 * this.x);
vec.z = (d3 * this.s - d * this.z - d1 * this.y + d2 * this.x);
}
public String toString() {
StringBuilder stringbuilder = new StringBuilder();
Formatter formatter = new Formatter(stringbuilder, Locale.US);
formatter.format("Quaternion:\n");
formatter.format(" < %f %f %f %f >\n", this.s, this.x, this.y, this.z);
formatter.close();
return stringbuilder.toString();
}
public static Quat aroundAxis(Vector3 axis, double angle) {
return aroundAxis(axis.x, axis.y, axis.z, angle);
}
}
}