- Orbitals: More dynamic hype

- AuraCore: OnFinish effects
This commit is contained in:
HellFirePvP committed 2015-12-06 21:16:40 +01:00
1 parent e18f26f483
commit 313c253ad1
8 files changed
+152 -24

No files matched your search

@@ -68,7 +68,7 @@ public final class Orbital {
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);
orbitalNode.getRunnable().onRender(point, orbitalNode, orbitalCounter, partialTicks);
}
FXFlow.FXFlowBase flow = new FXFlow.FXFlowBase(world, point.getX(), point.getY(), point.getZ(),
@@ -79,7 +79,7 @@ public final class Orbital {
Color c = (world.rand.nextBoolean()) ? orbitalNode.getSubParticleColor() : orbitalNode.getColor();
FXFlow.FXFlowBase flow2 = new FXFlow.FXFlowBase(world,
point.getX() + subOffset.getX(), point.getY() + subOffset.getY(), point.getZ() + subOffset.getZ(),
c, 0.05F + (world.rand.nextBoolean() ? 0.0F : 0.025F), 6, 240);
c, orbitalNode.getSubSizeRunnable().getSubParticleSize(world.rand, orbitalCounter), 6, 240);
Minecraft.getMinecraft().effectRenderer.addEffect(flow2);
}
@@ -151,6 +151,13 @@ public final class Orbital {
public static class OrbitalRenderProperties {
private static final OrbitalSubSizeRunnable subSizeRunnableStatic = new OrbitalSubSizeRunnable() {
@Override
public float getSubParticleSize(Random rand, int orbitalExisted) {
return 0.1F + (rand.nextBoolean() ? 0.0F : 0.1F);
}
};
private Axis axis;
private double originalOffset, offset;
private Color color = Color.WHITE;
@@ -162,10 +169,12 @@ public final class Orbital {
private int offsetTicks = 0;
private Color subParticleColor = null;
private OrbitalSubSizeRunnable subSizeRunnable;
public OrbitalRenderProperties(Axis axis, double offsetLength) {
this.offset = this.originalOffset = offsetLength;
this.axis = axis;
this.subSizeRunnable = subSizeRunnableStatic;
}
public OrbitalRenderProperties setColor(Color color) {
@@ -173,6 +182,12 @@ public final class Orbital {
return this;
}
public OrbitalRenderProperties setSubSizeRunnable(OrbitalSubSizeRunnable subSizeRunnable) {
if(subSizeRunnable == null) return this;
this.subSizeRunnable = subSizeRunnable;
return this;
}
public OrbitalRenderProperties setTicksForFullCircle(int ticks) {
this.ticksForFullCircle = ticks;
return this;
@@ -241,6 +256,10 @@ public final class Orbital {
return runnable;
}
public OrbitalSubSizeRunnable getSubSizeRunnable() {
return subSizeRunnable;
}
public int getMultiplier() {
return multiplier;
}
@@ -254,8 +273,12 @@ public final class Orbital {
}
}
public static abstract class OrbitalSubSizeRunnable {
public abstract float getSubParticleSize(Random rand, int orbitalExisted);
}
public static abstract class OrbitalRenderRunnable {
public abstract void onRender(Vector3 selectedPosition, OrbitalRenderProperties properties, float partialTicks);
public abstract void onRender(Vector3 selectedPosition, OrbitalRenderProperties properties, int orbitalExisted, float partialTicks);
}
public static class Axis {
@@ -125,6 +125,8 @@ public class RenderTileAuraPylon extends TileEntitySpecialRenderer {
private void addNewOrbitalPoint(Orbital orbital, Random rand, Color color) {
Orbital.OrbitalRenderProperties properties = new Orbital.OrbitalRenderProperties(Orbital.Axis.persisentRandomAxis(), rand.nextDouble() + 2D);
properties.setColor(color).setTicksForFullCircle(60 + rand.nextInt(40)).setOffsetTicks(rand.nextInt(80));
color.brighter().brighter();
properties.setSubParticleColor(color);
orbital.addOrbitalPoint(properties);
}
@@ -1,5 +1,10 @@
package makeo.gadomancy.client.util;
import makeo.gadomancy.common.utils.MiscUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.particle.EntitySmokeFX;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import thaumcraft.common.Thaumcraft;
@@ -19,7 +24,7 @@ public class UtilsFX {
private static final Color[] RUNE_COLORS_GREEN = new Color[] { new Color(0x015629), new Color(0x0E9C00), new Color(0x010000), new Color(0x01FF00), new Color(0x014C3E)};
private static final Color[] RUNE_COLORS_BLUE = new Color[] { new Color(0x060956), new Color(0x012578), new Color(0x0C1556), new Color(0x0100FF), new Color(0x01018C)};
public static void doRuneEffects(World world, int x, int y, int z, byte colorFlag) {
public static void doRuneEffects(World world, int x, int y, int z, int colorFlag) {
if(world.isRemote) {
int cnt = 20;
while(cnt > 0) {
@@ -31,7 +36,7 @@ public class UtilsFX {
}
}
private static Color evaluateRandomColor(Random rand, byte colorFlag) {
private static Color evaluateRandomColor(Random rand, int colorFlag) {
Color[] possibleColors;
if(colorFlag == 1) {
possibleColors = RUNE_COLORS_BLUE;
@@ -46,16 +51,31 @@ public class UtilsFX {
}
public static void doSparkleEffectsAround(World world, int x, int y, int z) {
doSparkleEffects(world, x, y, z);
doSparkleEffects(world, x + 1, y, z);
doSparkleEffects(world, x, y, z + 1);
doSparkleEffects(world, x - 1, y, z);
doSparkleEffects(world, x, y, z - 1);
doSparkleEffects(world, x, y - 1, z);
doSparkleEffects(world, x, y + 1, z);
for(ChunkCoordinates cc : MiscUtils.getCoordinatesAround(new ChunkCoordinates(x, y, z))) {
doSparkleEffects(world, cc.posX, cc.posY, cc.posZ);
}
}
public static void doSparkleEffects(World world, int x, int y, int z) {
Thaumcraft.proxy.blockSparkle(world, x, y, z, -9999, 10);
}
public static void doSmokeEffects(World world, int x, int y, int z, float size) {
int count = world.rand.nextInt(6) + 2;
for (int i = 0; i < count; i++) {
Minecraft.getMinecraft().effectRenderer.addEffect(
new EntitySmokeFX(world, x + 0.5 + randEffectOffset(world.rand), y + 0.5 + randEffectOffset(world.rand), z + 0.5 + randEffectOffset(world.rand),
randEffectOffset(world.rand) * 0.01F, randEffectOffset(world.rand) * 0.1F, randEffectOffset(world.rand) * 0.01F, size));
}
}
public static void doSmokeEffectsAround(World world, int x, int y, int z, float size) {
for(ChunkCoordinates cc : MiscUtils.getCoordinatesAround(new ChunkCoordinates(x, y, z))) {
doSmokeEffects(world, cc.posX, cc.posY, cc.posZ, size);
}
}
private static double randEffectOffset(Random rand) {
return rand.nextDouble() * (rand.nextBoolean() ? -1 : 1);
}
}
@@ -26,6 +26,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import thaumcraft.api.ThaumcraftApiHelper;
import thaumcraft.common.items.wands.ItemWandCasting;
import thaumcraft.common.lib.research.ResearchManager;
import java.util.List;
@@ -101,10 +102,13 @@ public class BlockAuraPylon extends BlockContainer implements IBlockTransparent
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
if(world.getBlockMetadata(x, y, z) != 1) return false;
if(world.getBlockMetadata(x, y, z) != 1) {
Block up = world.getBlock(x, y + 1, z);
return up instanceof BlockAuraPylon && up.onBlockActivated(world, x, y, z, player, side, par7, par8, par9);
}
ItemStack heldItem = player.getHeldItem();
if(!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting) {
//TODO check for research!
if(!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting &&
ResearchManager.isResearchComplete(player.getCommandSenderName(), Gadomancy.MODID.toUpperCase() + ".AURA_PYLON")) {
if(MultiblockHelper.isMultiblockPresent(world, x, y, z, RegisteredMultiblocks.auraPylonPattern) &&
ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsAuraPylonMultiblock, true)) {
PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, x, y, z);
@@ -8,6 +8,8 @@ import makeo.gadomancy.client.effect.fx.FXFlow;
import makeo.gadomancy.client.effect.fx.Orbital;
import makeo.gadomancy.common.data.ModConfig;
import makeo.gadomancy.common.items.ItemAuraCore;
import makeo.gadomancy.common.network.PacketHandler;
import makeo.gadomancy.common.network.packets.PacketStartAnimation;
import makeo.gadomancy.common.registration.RegisteredItems;
import makeo.gadomancy.common.utils.MiscUtils;
import makeo.gadomancy.common.utils.PrimalAspectList;
@@ -15,16 +17,21 @@ import makeo.gadomancy.common.utils.Vector3;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ScanResult;
import thaumcraft.common.lib.research.ScanManager;
import thaumcraft.common.lib.utils.BlockUtils;
import java.awt.Color;
import java.util.*;
@@ -134,6 +141,12 @@ public class EntityAuraCore extends EntityItem implements IEntityAdditionalSpawn
Color c = getSubParticleColor(effectAspects[i]);
node.setSubParticleColor(c);
node.setParticleSize(0.1f);
node.setSubSizeRunnable(new Orbital.OrbitalSubSizeRunnable() {
@Override
public float getSubParticleSize(Random rand, int orbitalExisted) {
return 0.05F + (rand.nextBoolean() ? 0.0F : 0.025F);
}
});
//node.setMultiplier()
effectProperties[i] = node;
}
@@ -181,6 +194,7 @@ public class EntityAuraCore extends EntityItem implements IEntityAdditionalSpawn
private void finishCore() {
ItemStack auraCore = new ItemStack(RegisteredItems.itemAuraCore, 1, 0);
boolean success = false;
if(blockCount >= REQUIRED_BLOCKS) {
double avg = ((double) this.internalAuraList.visSize()) / ((double) this.internalAuraList.size());
Aspect[] sortedHtL = this.internalAuraList.getAspectsSortedAmount();
@@ -203,12 +217,19 @@ public class EntityAuraCore extends EntityItem implements IEntityAdditionalSpawn
for(ItemAuraCore.AuraCoreType type : ItemAuraCore.AuraCoreType.values()) {
if(type.isAspect() && type.getAspect().equals(aura)) {
RegisteredItems.itemAuraCore.setCoreType(auraCore, type);
success = true;
}
}
} else {
//TODO: Failure animation
}
PacketStartAnimation animationPacket;
if(!success) {
animationPacket = new PacketStartAnimation(PacketStartAnimation.ID_SMOKE_SPREAD, (int) posX, (int) posY, (int) posZ, Float.floatToIntBits(2F));
} else {
animationPacket = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, (int) posX, (int) posY, (int) posZ, (byte) 0);
}
PacketHandler.INSTANCE.sendToAllAround(animationPacket, MiscUtils.getTargetPoint(worldObj, this, 32));
EntityItem ei = new EntityItem(worldObj, posX, posY, posZ, auraCore);
ei.motionX = 0;
ei.motionY = 0;
@@ -250,7 +271,28 @@ public class EntityAuraCore extends EntityItem implements IEntityAdditionalSpawn
Block block = worldObj.getBlock(x, y, z);
if(block != Blocks.air) {
int meta = worldObj.getBlockMetadata(x, y, z);
AspectList aspects = ScanManager.getScanAspects(new ScanResult((byte)1, Block.getIdFromBlock(block), meta, null, null), worldObj);
ScanResult result = null;
MovingObjectPosition pos = new MovingObjectPosition(x, y, z, ForgeDirection.UP.ordinal(),
Vec3.createVectorHelper(0, 0, 0), true);
ItemStack is = block.getPickBlock(pos, worldObj, x, y, z);
try {
if(is == null) {
is = BlockUtils.createStackedBlock(block, meta);
}
}
catch (Exception e) {}
try {
if (is == null) {
result = new ScanResult((byte)1, Block.getIdFromBlock(block), meta, null, "");
} else {
result = new ScanResult((byte)1, Item.getIdFromItem(is.getItem()), is.getItemDamage(), null, "");
}
}
catch (Exception e) {}
if(result == null) continue; //We can't scan it BibleThump
AspectList aspects = ScanManager.getScanAspects(result, worldObj);
if(aspects.size() > 0) {
internalAuraList.add(aspects);
blockCount++;
@@ -30,18 +30,20 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
public static final byte ID_RUNES = 3;
public static final byte ID_SPARKLE_SPREAD = 4;
public static final byte ID_SPARKLE = 5;
public static final byte ID_SMOKE = 6;
public static final byte ID_SMOKE_SPREAD = 7;
private byte annimationId;
private int x;
private int y;
private int z;
private byte additionalData;
private int additionalData;
public PacketStartAnimation(byte annimationId, int x, int y, int z) {
this(annimationId, x, y, z, (byte) 0);
}
public PacketStartAnimation(byte annimationId, int x, int y, int z, byte additionalData) {
public PacketStartAnimation(byte annimationId, int x, int y, int z, int additionalData) {
this.annimationId = annimationId;
this.x = x;
this.y = y;
@@ -57,7 +59,7 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.additionalData = buf.readByte();
this.additionalData = buf.readInt();
}
@Override
@@ -66,7 +68,7 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeByte(additionalData);
buf.writeInt(additionalData);
}
@Override
@@ -96,6 +98,12 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
case ID_SPARKLE:
UtilsFX.doSparkleEffects(Minecraft.getMinecraft().theWorld, message.x, message.y, message.z);
break;
case ID_SMOKE:
UtilsFX.doSmokeEffects(Minecraft.getMinecraft().theWorld, message.x, message.y, message.z, Float.intBitsToFloat(message.additionalData));
break;
case ID_SMOKE_SPREAD:
UtilsFX.doSmokeEffectsAround(Minecraft.getMinecraft().theWorld, message.x, message.y, message.z, Float.intBitsToFloat(message.additionalData));
break;
}
return null;
}
@@ -1,13 +1,18 @@
package makeo.gadomancy.common.utils;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -33,6 +38,30 @@ public final class MiscUtils {
return "th";
}
public static List<ChunkCoordinates> getCoordinatesAround(ChunkCoordinates center) {
List<ChunkCoordinates> coords = new ArrayList<ChunkCoordinates>();
coords.add(new ChunkCoordinates(center.posX, center.posY, center.posZ));
coords.add(new ChunkCoordinates(center.posX + 1, center.posY, center.posZ));
coords.add(new ChunkCoordinates(center.posX, center.posY, center.posZ + 1));
coords.add(new ChunkCoordinates(center.posX - 1, center.posY, center.posZ));
coords.add(new ChunkCoordinates(center.posX, center.posY, center.posZ - 1));
coords.add(new ChunkCoordinates(center.posX, center.posY - 1, center.posZ));
coords.add(new ChunkCoordinates(center.posX, center.posY + 1, center.posZ));
return coords;
}
public static NetworkRegistry.TargetPoint getTargetPoint(World world, Entity entity, double range) {
return getTargetPoint(world, range, getPositionVector(entity));
}
public static NetworkRegistry.TargetPoint getTargetPoint(World world, TileEntity tileEntity, double range) {
return getTargetPoint(world, range, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
}
public static NetworkRegistry.TargetPoint getTargetPoint(World world, double range, Vector3 target) {
return new NetworkRegistry.TargetPoint(world.provider.dimensionId, target.getX(), target.getY(), target.getZ(), range);
}
public static EntityPlayer getOnlinePlayerByUUIDClient(UUID playerUUID) {
List<EntityPlayerMP> players = Minecraft.getMinecraft().getIntegratedServer().getConfigurationManager().playerEntityList;
for(EntityPlayerMP player : players) {
@@ -1,6 +1,7 @@
package makeo.gadomancy.common.utils;
import cpw.mods.fml.common.network.NetworkRegistry;
import makeo.gadomancy.common.Gadomancy;
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar;
import makeo.gadomancy.common.entities.EntityAuraCore;
@@ -62,8 +63,7 @@ public class WandHandler {
tryAutomagyJarNodeCreation(i, entityPlayer, world, x, y, z);
}
} else if(target.equals(ConfigBlocks.blockCrystal)) {
//TODO 1 line down from here :3
//if (ResearchManager.isResearchComplete(entityPlayer.getCommandSenderName(), "INSERT_STH_HERE"))
if (ResearchManager.isResearchComplete(entityPlayer.getCommandSenderName(), Gadomancy.MODID.toUpperCase() + ".AURA_CORE"))
tryAuraCoreCreation(i, entityPlayer, world, x, y, z);
}
}