mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-26 06:43:01 +00:00
- EssentiaCompressor: Finshed.
- Version changed to 1.0.7
This commit is contained in:
1 parent
bfa064d8fa
commit
ea15ad5c9f
7 files changed
+151
-22
No files matched your search
@@ -2,6 +2,7 @@ package makeo.gadomancy.client.effect.fx;
|
||||
|
||||
import makeo.gadomancy.client.effect.EffectHandler;
|
||||
import makeo.gadomancy.client.events.ClientHandler;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileEssentiaCompressor;
|
||||
import makeo.gadomancy.common.utils.MiscUtils;
|
||||
import makeo.gadomancy.common.utils.Vector3;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -14,6 +15,7 @@ import thaumcraft.client.lib.QuadHelper;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* HellFirePvP@Admin
|
||||
@@ -23,9 +25,11 @@ import java.util.List;
|
||||
*/
|
||||
public class FXVortex {
|
||||
|
||||
private static final Random RAND = new Random();
|
||||
public static final ResourceLocation TC_VORTEX_TEXTURE = new ResourceLocation("thaumcraft", "textures/misc/vortex.png");
|
||||
private static final float RAD = (float) (Math.PI * 2);
|
||||
|
||||
private TileEssentiaCompressor parent = null;
|
||||
private long lastUpdateCall;
|
||||
private double x, y, z;
|
||||
public boolean registered = false;
|
||||
@@ -37,6 +41,14 @@ public class FXVortex {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public FXVortex(double x, double y, double z, TileEssentiaCompressor parent) {
|
||||
this.lastUpdateCall = System.currentTimeMillis();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
private void render(Tessellator tessellator, float pTicks) {
|
||||
float arX = ActiveRenderInfo.rotationX;
|
||||
float arXZ = ActiveRenderInfo.rotationXZ;
|
||||
@@ -45,7 +57,6 @@ public class FXVortex {
|
||||
float arXY = ActiveRenderInfo.rotationXY;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
//GL11.glDepthMask(true);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -53,11 +64,22 @@ public class FXVortex {
|
||||
float agescale = (float) (ClientHandler.ticks % 800) / 400F;
|
||||
if(agescale >= 1.0F) agescale = 2 - agescale;
|
||||
float size = 0.2F + 0.1F * agescale;
|
||||
if(parent != null) {
|
||||
size += size * (((float) parent.getSizeStage()) * 0.1F);
|
||||
}
|
||||
|
||||
float anglePerc = (float) (ClientHandler.ticks % 300) / 300F;
|
||||
float angle = RAD - RAD * anglePerc;
|
||||
|
||||
Vector3 iV = MiscUtils.interpolateEntityPosition(Minecraft.getMinecraft().renderViewEntity, pTicks);
|
||||
if(parent != null && parent.getSizeStage() > 4) {
|
||||
float mult = 0.001F * (parent.getSizeStage() - 4F);
|
||||
Vector3 shake = new Vector3(
|
||||
RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1),
|
||||
RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1),
|
||||
RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1));
|
||||
iV.add(shake);
|
||||
}
|
||||
|
||||
GL11.glTranslated(-iV.getX(), -iV.getY(), -iV.getZ());
|
||||
|
||||
@@ -89,7 +111,6 @@ public class FXVortex {
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
||||
//GL11.glDepthMask(false);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||
import makeo.gadomancy.client.ClientProxy;
|
||||
import makeo.gadomancy.client.effect.EffectHandler;
|
||||
import makeo.gadomancy.client.renderers.tile.RenderTileEssentiaCompressor;
|
||||
import makeo.gadomancy.client.util.FamiliarHandlerClient;
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -42,6 +43,7 @@ public class ClientHandler {
|
||||
@SubscribeEvent
|
||||
public void onDc(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
|
||||
EffectHandler.getInstance().clear();
|
||||
RenderTileEssentiaCompressor.ownedVortex.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+6
-5
@@ -68,7 +68,8 @@ public class RenderTileEssentiaCompressor extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
if(yOffset == 1) { //The middle one. - well. the one where the blackhole is.
|
||||
renderBlackHoleEffect(tileEntity.xCoord + 0.5, tileEntity.yCoord + 0.5, tileEntity.zCoord + 0.5);
|
||||
renderBlackHoleEffect(tileEntity.xCoord + 0.5, tileEntity.yCoord + 0.5, tileEntity.zCoord + 0.5,
|
||||
(TileEssentiaCompressor) tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord, tileEntity.yCoord - 1, tileEntity.zCoord));
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
@@ -78,7 +79,7 @@ public class RenderTileEssentiaCompressor extends TileEntitySpecialRenderer {
|
||||
if(isRenderedAsItem) {
|
||||
GL11.glTranslatef(0, -2.9F, 0);
|
||||
} else {
|
||||
GL11.glTranslatef(0, -2.877F, 0); //Magic number FeelsBadMan
|
||||
GL11.glTranslatef(0, -2.877F, 0);
|
||||
}
|
||||
bindTexture(PACKED_COMPRESSOR_TEXTURE);
|
||||
MODEL_PACKED_COMPRESSOR.render(null, 0, 0, 0, 0, 0, 0.0625f);
|
||||
@@ -87,15 +88,15 @@ public class RenderTileEssentiaCompressor extends TileEntitySpecialRenderer {
|
||||
|
||||
}
|
||||
|
||||
private Map<ChunkCoordinates, FXVortex> ownedVortex = new HashMap<ChunkCoordinates, FXVortex>();
|
||||
public static Map<ChunkCoordinates, FXVortex> ownedVortex = new HashMap<ChunkCoordinates, FXVortex>();
|
||||
|
||||
private void renderBlackHoleEffect(double x, double y, double z) {
|
||||
private void renderBlackHoleEffect(double x, double y, double z, TileEssentiaCompressor te) {
|
||||
ChunkCoordinates cc = new ChunkCoordinates((int) x, (int) y, (int) z);
|
||||
FXVortex v;
|
||||
if (ownedVortex.containsKey(cc)) {
|
||||
v = ownedVortex.get(cc);
|
||||
} else {
|
||||
v = new FXVortex(x, y, z);
|
||||
v = new FXVortex(x, y, z, te);
|
||||
ownedVortex.put(cc, v);
|
||||
v.registered = true;
|
||||
EffectHandler.getInstance().registerVortex(v);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Gadomancy {
|
||||
public static final String MODID = "gadomancy";
|
||||
public static final String NAME = "Gadomancy";
|
||||
|
||||
public static final String VERSION = "1.0.6.1";
|
||||
public static final String VERSION = "1.0.7";
|
||||
|
||||
private static final String PROXY_CLIENT = "makeo.gadomancy.client.ClientProxy";
|
||||
private static final String PROXY_SERVER = "makeo.gadomancy.common.CommonProxy";
|
||||
|
||||
@@ -3,18 +3,18 @@ package makeo.gadomancy.common.blocks.tiles;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import makeo.gadomancy.client.effect.fx.FXVortex;
|
||||
import makeo.gadomancy.client.events.ClientHandler;
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
import makeo.gadomancy.common.data.config.ModConfig;
|
||||
import makeo.gadomancy.common.network.packets.PacketTCNodeBolt;
|
||||
import makeo.gadomancy.common.network.packets.PacketAnimationAbsorb;
|
||||
import makeo.gadomancy.common.registration.RegisteredBlocks;
|
||||
import makeo.gadomancy.common.registration.RegisteredItems;
|
||||
import makeo.gadomancy.common.utils.ExplosionHelper;
|
||||
import makeo.gadomancy.common.utils.Injector;
|
||||
import makeo.gadomancy.common.utils.Vector3;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -27,22 +27,20 @@ import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.WorldCoordinates;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.aspects.IAspectContainer;
|
||||
import thaumcraft.api.aspects.IAspectSource;
|
||||
import thaumcraft.api.aspects.IEssentiaContainerItem;
|
||||
import thaumcraft.api.aspects.IEssentiaTransport;
|
||||
import thaumcraft.client.fx.ParticleEngine;
|
||||
import thaumcraft.client.fx.bolt.FXLightningBolt;
|
||||
import thaumcraft.client.fx.particles.FXEssentiaTrail;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.lib.events.EssentiaHandler;
|
||||
import thaumcraft.common.lib.network.PacketHandler;
|
||||
import thaumcraft.common.lib.network.fx.PacketFXEssentiaSource;
|
||||
import thaumcraft.common.tiles.TileJarFillable;
|
||||
import thaumcraft.common.tiles.TileMirrorEssentia;
|
||||
import thaumcraft.common.tiles.TilePedestal;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@@ -57,6 +55,9 @@ import java.util.Map;
|
||||
*/
|
||||
public class TileEssentiaCompressor extends SynchronizedTileEntity implements IAspectSource, IEssentiaTransport {
|
||||
|
||||
public static final int MAX_SIZE = 8;
|
||||
public static final int MAX_ASPECT_STORAGE = 3000, STD_ASPECT_STORAGE = 200;
|
||||
|
||||
private static Injector injEssentiaHandler = new Injector(EssentiaHandler.class);
|
||||
private static int multiblockIDCounter = 0;
|
||||
|
||||
@@ -66,6 +67,10 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
|
||||
private boolean isMultiblockPresent = false;
|
||||
|
||||
private int incSize = 0;
|
||||
private Vector3 coordPedestal = null;
|
||||
private int consumeTick = 0;
|
||||
|
||||
private AspectList al = new AspectList();
|
||||
private int ticksExisted = 0;
|
||||
private boolean prevFound = false;
|
||||
@@ -90,6 +95,10 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
prevFound = searchForEssentia(coords);
|
||||
}
|
||||
}
|
||||
|
||||
if(isMasterTile() && ((incSize < MAX_SIZE && (ticksExisted % 40) == 0) || (coordPedestal != null))) {
|
||||
consumeVoidmetal();
|
||||
}
|
||||
} else {
|
||||
if(isMasterTile() && isMultiblockFormed()) {
|
||||
playLightningEffects();
|
||||
@@ -105,6 +114,65 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
}
|
||||
}
|
||||
|
||||
private void consumeVoidmetal() {
|
||||
if(coordPedestal != null) {
|
||||
if(!checkPedestal(coordPedestal)) {
|
||||
consumeTick = 0;
|
||||
coordPedestal = null;
|
||||
return;
|
||||
}
|
||||
consumeTick++;
|
||||
if(consumeTick <= 400) {
|
||||
PacketAnimationAbsorb absorb = new PacketAnimationAbsorb(
|
||||
xCoord, yCoord + 1, zCoord,
|
||||
coordPedestal.getBlockX(), coordPedestal.getBlockY() + 1, coordPedestal.getBlockZ(),
|
||||
5, Block.getIdFromBlock(ConfigBlocks.blockCosmeticSolid), 1);
|
||||
makeo.gadomancy.common.network.PacketHandler.INSTANCE.sendToAllAround(absorb, new NetworkRegistry.TargetPoint(
|
||||
getWorldObj().provider.dimensionId,
|
||||
xCoord, yCoord, zCoord, 16));
|
||||
} else {
|
||||
TilePedestal te = (TilePedestal) worldObj.getTileEntity(
|
||||
coordPedestal.getBlockX(), coordPedestal.getBlockY(), coordPedestal.getBlockZ());
|
||||
te.setInventorySlotContents(0, null);
|
||||
te.markDirty();
|
||||
worldObj.markBlockForUpdate(
|
||||
coordPedestal.getBlockX(), coordPedestal.getBlockY(), coordPedestal.getBlockZ());
|
||||
consumeTick = 0;
|
||||
coordPedestal = null;
|
||||
incSize += 1;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
markDirty();
|
||||
}
|
||||
} else {
|
||||
for (int xx = -3; xx <= 3; xx++) {
|
||||
for (int zz = -3; zz <= 3; zz++) {
|
||||
Vector3 offset = new Vector3(xCoord + xx, yCoord, zCoord + zz);
|
||||
if(checkPedestal(offset)) {
|
||||
this.coordPedestal = offset;
|
||||
this.consumeTick = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.coordPedestal = null;
|
||||
this.consumeTick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkPedestal(Vector3 coordPedestal) {
|
||||
Block at = worldObj.getBlock(
|
||||
coordPedestal.getBlockX(), coordPedestal.getBlockY(), coordPedestal.getBlockZ());
|
||||
int md = worldObj.getBlockMetadata(
|
||||
coordPedestal.getBlockX(), coordPedestal.getBlockY(), coordPedestal.getBlockZ());
|
||||
TileEntity te = worldObj.getTileEntity(
|
||||
coordPedestal.getBlockX(), coordPedestal.getBlockY(), coordPedestal.getBlockZ());
|
||||
if(at == null || te == null || md != 1) return false;
|
||||
if(!at.equals(RegisteredBlocks.blockStoneMachine) || !(te instanceof TilePedestal)) return false;
|
||||
ItemStack st = ((TilePedestal) te).getStackInSlot(0);
|
||||
if(st == null || st.getItem() == null) return false;
|
||||
return st.getItem().equals(RegisteredItems.itemElement) && st.getItemDamage() == 0;
|
||||
}
|
||||
|
||||
//only call from master tile.
|
||||
private boolean searchForEssentia(List<WorldCoordinates> coordinates) {
|
||||
if(ticksExisted % 10 != 0) return prevFound;
|
||||
@@ -130,6 +198,7 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
IAspectSource as = (IAspectSource)sourceTile;
|
||||
AspectList contains = as.getAspects();
|
||||
if(contains.visSize() > al.visSize()) continue;
|
||||
if(!canAccept(a)) continue;
|
||||
if (as.takeFromContainer(a, 1)) {
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketFXEssentiaSource(xCoord, yCoord + 1, zCoord,
|
||||
(byte)(xCoord - coordinate.x), (byte)(yCoord - coordinate.y + 1), (byte)(zCoord - coordinate.z),
|
||||
@@ -140,6 +209,16 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canAccept(Aspect a) {
|
||||
int current = al.getAmount(a);
|
||||
int max = STD_ASPECT_STORAGE + incSize * ((MAX_ASPECT_STORAGE - STD_ASPECT_STORAGE) / MAX_SIZE);
|
||||
return current < max;
|
||||
}
|
||||
|
||||
public int getSizeStage() {
|
||||
return incSize;
|
||||
}
|
||||
|
||||
float tr = 1.0F;
|
||||
float tri = 0.0F;
|
||||
float tg = 1.0F;
|
||||
@@ -260,7 +339,7 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void playLightningEffects() {
|
||||
if(worldObj.rand.nextBoolean()) {
|
||||
if(incSize > 5 || worldObj.rand.nextBoolean()) {
|
||||
double originX = xCoord + 0.5;
|
||||
double originY = yCoord + 1.5;
|
||||
double originZ = zCoord + 0.5;
|
||||
@@ -400,6 +479,7 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
this.isMasterTile = compound.getBoolean("isMasterTile");
|
||||
this.multiblockId = compound.getInteger("multiblockId");
|
||||
this.isMultiblockPresent = compound.getBoolean("multiblockPresent");
|
||||
this.incSize = compound.getInteger("sizeInc");
|
||||
AspectList al = new AspectList();
|
||||
NBTTagCompound cmp = compound.getCompoundTag("aspects");
|
||||
for (Object tag : cmp.func_150296_c()) {
|
||||
@@ -418,6 +498,7 @@ public class TileEssentiaCompressor extends SynchronizedTileEntity implements IA
|
||||
compound.setInteger("multiblockId", this.multiblockId);
|
||||
compound.setInteger("multiblockYIndex", this.multiblockYIndex);
|
||||
compound.setBoolean("multiblockPresent", this.isMasterTile);
|
||||
compound.setInteger("sizeInc", this.incSize);
|
||||
NBTTagCompound aspects = new NBTTagCompound();
|
||||
for (Aspect a : al.aspects.keySet()) {
|
||||
aspects.setInteger(a.getTag(), al.aspects.get(a));
|
||||
|
||||
@@ -23,6 +23,7 @@ public class PacketAnimationAbsorb implements IMessage, IMessageHandler<PacketAn
|
||||
private int x, y, z;
|
||||
private int targetX, targetY, targetZ;
|
||||
private int tickCap;
|
||||
private int bid = -1, bmd = -1;
|
||||
|
||||
public PacketAnimationAbsorb() {}
|
||||
|
||||
@@ -36,6 +37,18 @@ public class PacketAnimationAbsorb implements IMessage, IMessageHandler<PacketAn
|
||||
this.tickCap = tickCap;
|
||||
}
|
||||
|
||||
public PacketAnimationAbsorb(int x, int y, int z, int targetX, int targetY, int targetZ, int tickCap, int bid, int bmd) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.targetX = targetX;
|
||||
this.targetY = targetY;
|
||||
this.targetZ = targetZ;
|
||||
this.tickCap = tickCap;
|
||||
this.bid = bid;
|
||||
this.bmd = bmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.x = buf.readInt();
|
||||
@@ -45,6 +58,8 @@ public class PacketAnimationAbsorb implements IMessage, IMessageHandler<PacketAn
|
||||
this.targetY = buf.readInt();
|
||||
this.targetZ = buf.readInt();
|
||||
this.tickCap = buf.readInt();
|
||||
this.bid = buf.readInt();
|
||||
this.bmd = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,13 +71,22 @@ public class PacketAnimationAbsorb implements IMessage, IMessageHandler<PacketAn
|
||||
buf.writeInt(targetY);
|
||||
buf.writeInt(targetZ);
|
||||
buf.writeInt(tickCap);
|
||||
buf.writeInt(bid);
|
||||
buf.writeInt(bmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(PacketAnimationAbsorb p, MessageContext ctx) {
|
||||
Block b = Minecraft.getMinecraft().theWorld.getBlock(p.targetX, p.targetY, p.targetZ);
|
||||
int md = Minecraft.getMinecraft().theWorld.getBlockMetadata(p.targetX, p.targetY, p.targetZ);
|
||||
Block b;
|
||||
int md;
|
||||
if(p.bid != -1 && p.bmd != -1) {
|
||||
b = Block.getBlockById(p.bid);
|
||||
md = p.bmd;
|
||||
} else {
|
||||
b = Minecraft.getMinecraft().theWorld.getBlock(p.targetX, p.targetY, p.targetZ);
|
||||
md = Minecraft.getMinecraft().theWorld.getBlockMetadata(p.targetX, p.targetY, p.targetZ);
|
||||
}
|
||||
MultiTickEffectDispatcher.VortexDigInfo info =
|
||||
new MultiTickEffectDispatcher.VortexDigInfo(Minecraft.getMinecraft().theWorld.provider.dimensionId, p.x, p.y, p.z, p.targetX, p.targetY, p.targetZ, b, md, p.tickCap);
|
||||
MultiTickEffectDispatcher.registerVortexDig(info);
|
||||
|
||||
Reference in new issue
Block a user