- Added experimental bubble spawn option

This commit is contained in:
HellFirePvP committed 2016-01-11 20:41:14 +01:00
1 parent ceaf8a4a0e
commit 408440fbcd
4 files changed
+83

No files matched your search

@@ -25,6 +25,7 @@ import makeo.gadomancy.client.renderers.item.ItemRenderStoneMachine;
import makeo.gadomancy.client.renderers.item.ItemRenderTileEntity;
import makeo.gadomancy.client.renderers.item.ItemRenderTileEntityMulti;
import makeo.gadomancy.client.renderers.tile.*;
import makeo.gadomancy.client.util.MultiTickEffectDispatcher;
import makeo.gadomancy.common.CommonProxy;
import makeo.gadomancy.common.blocks.tiles.*;
import makeo.gadomancy.common.entities.EntityAuraCore;
@@ -179,6 +180,14 @@ public class ClientProxy extends CommonProxy {
return nextId;
}
@Override
public void spawnBubbles(World world, float posX, float posY, float posZ, float rangeAroundItem) {
MultiTickEffectDispatcher.BubbleFXInfo bubbles =
new MultiTickEffectDispatcher.BubbleFXInfo(Minecraft.getMinecraft().theWorld.provider.dimensionId,
posX, posY, posZ, 10, rangeAroundItem);
MultiTickEffectDispatcher.registerBubbles(bubbles);
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch (ID) {
@@ -3,6 +3,8 @@ package makeo.gadomancy.client.util;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.world.World;
import thaumcraft.client.fx.ParticleEngine;
import thaumcraft.client.fx.particles.FXBubble;
import thaumcraft.client.lib.UtilsFX;
import thaumcraft.common.Thaumcraft;
@@ -24,17 +26,45 @@ public class MultiTickEffectDispatcher {
private static ReentrantLock renderLock = new ReentrantLock();
private static List<VortexDigInfo> vortexDigInfos = new ArrayList<VortexDigInfo>();
private static List<FloatyLineInfo> floatyLineInfos = new ArrayList<FloatyLineInfo>();
private static List<BubbleFXInfo> bubbleInfos = new ArrayList<BubbleFXInfo>();
public static void notifyRenderTick(World currentRenderWorld, float partialTicks) {
renderLock.lock();
try {
handleVortexDiggingEffects(currentRenderWorld);
handleWispyLineEffects(currentRenderWorld, partialTicks);
handleBubbleSpawnings(currentRenderWorld);
} finally {
renderLock.unlock();
}
}
private static void handleBubbleSpawnings(World world) {
Iterator<BubbleFXInfo> it = bubbleInfos.iterator();
while(it.hasNext()) {
BubbleFXInfo info = it.next();
if(info.dimId != world.provider.dimensionId) {
it.remove();
continue;
}
info.renderTicks++;
if(info.renderTicks > info.overallTicks) {
it.remove();
continue;
}
if(world.rand.nextInt(3) == 0) {
float x = info.posX + (world.rand.nextBoolean() ? 1 : -1) * (world.rand.nextFloat() * info.rangeAroundItem);
float y = info.posY + (world.rand.nextBoolean() ? 1 : -1) * (world.rand.nextFloat() * info.rangeAroundItem);
float z = info.posZ + (world.rand.nextBoolean() ? 1 : -1) * (world.rand.nextFloat() * info.rangeAroundItem);
FXBubble fb = new FXBubble(world, x, y, z, 0.0D, 0.0D, 0.0D, 0);
fb.setAlphaF(0.25F);
fb.setRGB(1.0F, 1.0F, 1.0F);
ParticleEngine.instance.addEffect(world, fb);
}
}
}
private static void handleWispyLineEffects(World currentRenderWorld, float partialTicks) {
Iterator<FloatyLineInfo> it = floatyLineInfos.iterator();
while(it.hasNext()) {
@@ -76,6 +106,15 @@ public class MultiTickEffectDispatcher {
}
}
public static void registerBubbles(BubbleFXInfo info) {
renderLock.lock();
try {
bubbleInfos.add(info);
} finally {
renderLock.unlock();
}
}
public static void registerVortexDig(VortexDigInfo info) {
renderLock.lock();
try {
@@ -117,6 +156,23 @@ public class MultiTickEffectDispatcher {
}
}
public static class BubbleFXInfo {
private int dimId;
private float posX, posY, posZ;
private int renderTicks, overallTicks;
private float rangeAroundItem;
public BubbleFXInfo(int dimId, float posX, float posY, float posZ, int overallTicks, float rangeAroundItem) {
this.dimId = dimId;
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.overallTicks = overallTicks;
this.rangeAroundItem = rangeAroundItem;
}
}
public static class VortexDigInfo {
private int dimId;
@@ -15,6 +15,7 @@ import makeo.gadomancy.common.events.EventHandlerGolem;
import makeo.gadomancy.common.events.EventHandlerNetwork;
import makeo.gadomancy.common.events.EventHandlerWorld;
import makeo.gadomancy.common.network.PacketHandler;
import makeo.gadomancy.common.network.packets.PacketStartAnimation;
import makeo.gadomancy.common.registration.*;
import makeo.gadomancy.common.utils.Injector;
import makeo.gadomancy.common.utils.world.WorldProviderTCEldrich;
@@ -104,6 +105,14 @@ public class CommonProxy implements IGuiHandler {
triggers.put(modid, modTriggers);
}
public void spawnBubbles(World world, float posX, float posY, float posZ, float rangeAroundItem) {
PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_BUBBLES,
Float.floatToIntBits(posX), Float.floatToIntBits(posY), Float.floatToIntBits(posZ),
Float.floatToIntBits(rangeAroundItem));
PacketHandler.INSTANCE.sendToAllAround(pkt, new NetworkRegistry.TargetPoint(world.provider.dimensionId,
posX, posY, posZ, 32));
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch (ID) {
@@ -6,6 +6,7 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import makeo.gadomancy.client.util.MultiTickEffectDispatcher;
import makeo.gadomancy.client.util.UtilsFX;
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
import makeo.gadomancy.common.blocks.tiles.TileInfusionClaw;
@@ -32,6 +33,7 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
public static final byte ID_SPARKLE = 5;
public static final byte ID_SMOKE = 6;
public static final byte ID_SMOKE_SPREAD = 7;
public static final byte ID_BUBBLES = 8;
private byte annimationId;
private int x;
@@ -104,6 +106,13 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
case ID_SMOKE_SPREAD:
UtilsFX.doSmokeEffectsAround(Minecraft.getMinecraft().theWorld, message.x, message.y, message.z, Float.intBitsToFloat(message.additionalData));
break;
case ID_BUBBLES:
MultiTickEffectDispatcher.BubbleFXInfo bubbles =
new MultiTickEffectDispatcher.BubbleFXInfo(Minecraft.getMinecraft().theWorld.provider.dimensionId,
Float.intBitsToFloat(message.x), Float.intBitsToFloat(message.y), Float.intBitsToFloat(message.z),
10, Float.intBitsToFloat(message.additionalData));
MultiTickEffectDispatcher.registerBubbles(bubbles);
break;
}
return null;
}