mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-27 15:23:22 +00:00
- Added some effect stuff
This commit is contained in:
1 parent
cbcf92016d
commit
3d494de9bc
9 files changed
+1330
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user