16/02/2015

This commit is contained in:
brandon3055 committed 2015-02-16 00:13:33 +11:00
1 parent 8fcf9897d4
commit d088e586c2
57 files changed
+1514 -92

No files matched your search

@@ -30,7 +30,7 @@ public class DraconicEvolution { // TODO Update Licence and add change log to gi
public static final String networkChannelName = "DEvolutionNC";
public static SimpleNetworkWrapper network;
public static boolean debug = false;//todo
public static boolean debug = true;//todo
public static Enchantment reaperEnchant;
@@ -3,6 +3,7 @@ package com.brandon3055.draconicevolution.client;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
import com.brandon3055.draconicevolution.client.handler.HudHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.keybinding.KeyBindings;
import com.brandon3055.draconicevolution.client.keybinding.KeyInputHandler;
import com.brandon3055.draconicevolution.client.render.block.RenderDraconiumChest;
@@ -13,6 +14,8 @@ import com.brandon3055.draconicevolution.client.render.entity.RenderDragon;
import com.brandon3055.draconicevolution.client.render.entity.RenderDragonHeart;
import com.brandon3055.draconicevolution.client.render.item.RenderBow;
import com.brandon3055.draconicevolution.client.render.item.RenderMobSoul;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.client.render.tile.*;
import com.brandon3055.draconicevolution.common.CommonProxy;
import com.brandon3055.draconicevolution.common.ModBlocks;
@@ -21,8 +24,10 @@ import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon;
import com.brandon3055.draconicevolution.common.entity.EntityDragonHeart;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.*;
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyRelay;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyPylon;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -30,6 +35,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
@@ -131,13 +137,14 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileParticleGenerator.class, new RenderTileParticleGen());
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyInfuser.class, new RenderTileEnergyInfiser());
ClientRegistry.bindTileEntitySpecialRenderer(TileCustomSpawner.class, new RenderTileCustomSpawner());
//ClientRegistry.bindTileEntitySpecialRenderer(TileTestBlock.class, new RenderTileTestBlock());
//ClientRegistry.bindTileEntitySpecialRenderer(TileTestBlock.class, new RenderTileCrystal());
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyStorageCore.class, new RenderTileEnergyStorageCore());
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyPylon.class, new RenderTileEnergyPylon());
ClientRegistry.bindTileEntitySpecialRenderer(TilePlacedItem.class, new RenderTilePlacedItem());
ClientRegistry.bindTileEntitySpecialRenderer(TileDissEnchanter.class, new RenderTileDissEnchanter());
ClientRegistry.bindTileEntitySpecialRenderer(TileTeleporterStand.class, new RenderTileTeleporterStand());
ClientRegistry.bindTileEntitySpecialRenderer(TileDraconiumChest.class, new RenderTileDraconiumChest());
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyRelay.class, new RenderTileCrystal());
//Entitys
RenderingRegistry.registerEntityRenderingHandler(EntityCustomDragon.class, new RenderDragon());
@@ -152,4 +159,58 @@ public class ClientProxy extends CommonProxy {
public boolean isDedicatedServer() {
return false;
}
@Override
public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render) {
if (!worldObj.isRemote) return null;
ParticleEnergyBeam beam = oldBeam;
boolean inRange = ParticleHandler.isInRange(x, y, z, 50) || ParticleHandler.isInRange(tx, ty, tz, 50);
if (beam == null || beam.isDead)
{
if (inRange)
{
beam = new ParticleEnergyBeam(worldObj, x, y, z, tx, ty, tz, 8, powerFlow, advanced, 3);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam);
}
}
else if (!inRange)
{
beam.setDead();
return null;
}
else
{
beam.update(powerFlow, render);
}
return beam;
}
@Override
public ParticleEnergyRing energyRing(World worldObj, double x, double y, double z, int powerFlow, boolean advanced, ParticleEnergyRing oldBeam, boolean render) {
if (!worldObj.isRemote) return null;
ParticleEnergyRing beam = oldBeam;
boolean inRange = ParticleHandler.isInRange(x, y, z, 50);
if (beam == null || beam.isDead)
{
if (inRange)
{
beam = new ParticleEnergyRing(worldObj, x, y, z, 8, powerFlow, advanced);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam);
}
}
else if (!inRange)
{
beam.setDead();
return null;
}
else
{
beam.update(powerFlow, render);
}
return beam;
}
}
@@ -13,6 +13,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraftforge.client.event.FOVUpdateEvent;
import java.util.Random;
/**
* Created by Brandon on 28/10/2014.
*/
@@ -26,10 +28,13 @@ public class ClientEventHandler {
public static int tickSet = 0;
private static int remountTicksRemaining = 0;
private static int remountEntityID = 0;
public static float energyCrystalAlphaValue = 0f;
public static float energyCrystalAlphaTarget = 0f;
private static Random rand = new Random();
@SubscribeEvent
public void tickEnd(TickEvent event) {
if (event.phase != TickEvent.Phase.START || event.side != Side.CLIENT) return;
if (event.phase != TickEvent.Phase.START || event.type != TickEvent.Type.CLIENT || event.side != Side.CLIENT) return;
elapsedTicks++;
HudHandler.clientTick();
@@ -43,6 +48,11 @@ public class ClientEventHandler {
lastTickBowZoom = bowZoom;
if (elapsedTicks - tickSet > 10) bowZoom = false;
if (energyCrystalAlphaValue < energyCrystalAlphaTarget) energyCrystalAlphaValue += 0.01f;
if (energyCrystalAlphaValue > energyCrystalAlphaTarget) energyCrystalAlphaValue -= 0.01f;
if (Math.abs(energyCrystalAlphaTarget - energyCrystalAlphaValue) <= 0.02f) energyCrystalAlphaTarget = rand.nextFloat();
searchForPlayerMount();
}
@@ -1,4 +1,4 @@
package com.brandon3055.draconicevolution.common.handler;
package com.brandon3055.draconicevolution.client.handler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleDistortion;
import cpw.mods.fml.relauncher.Side;
@@ -48,7 +48,7 @@ public class ParticleHandler
}
public static EntityFX spawnCustomParticle(EntityFX particle){
return spawnCustomParticle(particle, 256);
return spawnCustomParticle(particle, 64);
}
public static EntityFX spawnCustomParticle(EntityFX particle, double vewRange)
@@ -60,10 +60,7 @@ public class ParticleHandler
{
var14 = 2;
}
double var15 = mc.renderViewEntity.posX - particle.posX;
double var17 = mc.renderViewEntity.posY - particle.posY;
double var19 = mc.renderViewEntity.posZ - particle.posZ;
if (var15 * var15 + var17 * var17 + var19 * var19 > vewRange * vewRange)
if (!isInRange(particle.posX, particle.posY, particle.posZ, vewRange))
{
return null;
} else if (var14 > 1)
@@ -77,4 +74,19 @@ public class ParticleHandler
}
return null;
}
public static boolean isInRange(double x, double y, double z, double vewRange)
{
if (mc == null || mc.renderViewEntity == null || mc.effectRenderer == null) return false;
double var15 = mc.renderViewEntity.posX - x;
double var17 = mc.renderViewEntity.posY - y;
double var19 = mc.renderViewEntity.posZ - z;
if (var15 * var15 + var17 * var17 + var19 * var19 > vewRange * vewRange)
{
return false;
}
return true;
}
}
@@ -0,0 +1,39 @@
package com.brandon3055.draconicevolution.client.handler;
import com.brandon3055.draconicevolution.common.lib.References;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.util.ResourceLocation;
/**
* Created by Brandon on 8/02/2015.
*/
public class ResourceHelper {
private static ResourceLocation defaultParticles;
private static ResourceLocation particles = new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png");
public static void bindTexture(ResourceLocation texture)
{
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
}
/**Binds the vanilla particle sheet*/
public static void bindDefaultParticles()
{
if (defaultParticles == null)
{
try
{
defaultParticles = (ResourceLocation) ReflectionHelper.getPrivateValue(EffectRenderer.class, null, "particleTextures", "field_110737_b");
}
catch (Exception e) {}
}
if (defaultParticles != null) bindTexture(defaultParticles);
}
public static void bindParticles()
{
bindTexture(particles);
}
}
@@ -1,6 +1,7 @@
package com.brandon3055.draconicevolution.client.render.block;
import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -35,6 +36,7 @@ public class RenderParticleGen implements IItemRenderer
if (type == IItemRenderer.ItemRenderType.ENTITY)
GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F);
RenderHelper.disableStandardItemLighting();
GL11.glPopAttrib();
GL11.glPopMatrix();
}
@@ -1,13 +1,11 @@
package com.brandon3055.draconicevolution.client.render.particle;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.brandon3055.draconicevolution.common.lib.References;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
public class ParticleCustom extends EntityFX
{
@@ -63,7 +61,7 @@ public class ParticleCustom extends EntityFX
{//Note U=X V=Y
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"));
ResourceHelper.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -94,7 +92,7 @@ public class ParticleCustom extends EntityFX
tesselator.addVertexWithUV((double)(drawX + par3 * drawScale - par6 * drawScale), (double)(drawY - par4 * drawScale), (double)(drawZ + par5 * drawScale - par7 * drawScale), (double)minU, (double)maxV);
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/particle/particles.png"));
ResourceHelper.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -1,13 +1,11 @@
package com.brandon3055.draconicevolution.client.render.particle;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.brandon3055.draconicevolution.common.lib.References;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
public class ParticleDistortion extends EntityFX {
double originalX;
@@ -62,12 +60,12 @@ public class ParticleDistortion extends EntityFX {
@Override
@SideOnly(Side.CLIENT)
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"));
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
tessellator.draw();
ResourceHelper.bindParticles();
tessellator.startDrawingQuads();
tessellator.setBrightness(200);//make sure you have this!!
float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F;
@@ -87,17 +85,17 @@ public class ParticleDistortion extends EntityFX {
float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY);
float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ);
tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha);
tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F));
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha);
tessellator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F));
tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV);
tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV);
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV);
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tessellator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV);
tessellator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV);
tessellator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV);
tessellator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/particle/particles.png"));
tesselator.startDrawingQuads();
tessellator.draw();
ResourceHelper.bindDefaultParticles();
tessellator.startDrawingQuads();
}
}
@@ -1,10 +1,8 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.common.lib.References;
import net.minecraft.client.Minecraft;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class ParticleEnergy extends EntityFX {
@@ -99,7 +97,7 @@ public class ParticleEnergy extends EntityFX {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"));
ResourceHelper.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -130,7 +128,7 @@ public class ParticleEnergy extends EntityFX {
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/particle/particles.png"));
ResourceHelper.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -0,0 +1,217 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.Utills;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
/**
* Created by Brandon on 8/02/2015.
*/
public class ParticleEnergyBeam extends EntityFX {
/**Power flow integer Ranges from 0 to 100*/
private int flow;
/**Beam Target X*/
private double tX = 0.0D;
/**Beam Target Y*/
private double tY = 0.0D;
/**Beam Target Z*/
private double tZ = 0.0D;
/**Modified Target X*/
private boolean advanced;
private boolean renderParticle = true;
private float length = 0.0F;
private float rotYaw = 0.0F;
private float rotPitch = 0.0F;
private float prevYaw = 0.0F;
private float prevPitch = 0.0F;
private EntityPlayer player;
//todo make sure not dyrectly up or down on y axis, Set dead when player goes out of range, PaRTICLE eNGINE
private static ResourceLocation beamTextureBasic = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyBeamBlue.png");
private static ResourceLocation beamTextureAdvanced = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyBeamRed.png");
/**
* @param offsetMode 0 = no offset, 1 = offset target end, 2 = offset start end, 3 offset both ends
* */
public ParticleEnergyBeam(World world, double x, double y, double z, double tX, double tY, double tZ, int maxAge, int flow, boolean advanced, int offsetMode) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.particleRed = 1F;
this.particleGreen = 1F;
this.particleBlue = 1F;
this.noClip = true;
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.particleMaxAge = maxAge;
this.flow = flow;
this.prevYaw = rotationYaw;
this.prevPitch = rotPitch;
this.setSize(0.2F, 0.2F);
this.advanced = advanced;
this.tX = tX;
this.tY = tY;
this.tZ = tZ;
if (offsetMode > 0)
{
double dist = Utills.getDistanceAtoB(x, z, tX, tZ);
if (dist == 0) dist = 0.1;
double xDist = x - tX;
double zDist = z - tZ;
double xOff = xDist / dist;
double zOff = zDist / dist;
if (xOff == 0 && zOff == 0) xOff = 1;
//LogHelper.info(xOff + " " + zOff);
double offM = 0.4D;
if (offsetMode == 2 || offsetMode == 3) setPosition(posX - xOff * offM, posY, posZ - zOff * offM);
if (offsetMode == 1 || offsetMode == 3)
{
this.tX = tX + xOff * offM;
this.tY = tY;
this.tZ = tZ + zOff * offM;
}
}
}
public void update(int flow, boolean render)
{
this.renderParticle = render;
for(this.flow = flow; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {}
}
@Override
public void onUpdate()
{
//1.570797f
// double sin = Math.sin(-1f + (float)(particleAge % 360) / 180f * 1.570797f);
// LogHelper.info(sin + " " + particleAge % 360);
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.prevYaw = this.rotYaw;
this.prevPitch = this.rotPitch;
float xd = (float)(this.posX - this.tX);
float yd = (float)(this.posY - this.tY);
float zd = (float)(this.posZ - this.tZ);
this.length = MathHelper.sqrt_float(xd * xd + yd * yd + zd * zd);
double var7 = (double)MathHelper.sqrt_double((double) (xd * xd + zd * zd));
this.rotYaw = (float)(Math.atan2((double)xd, (double)zd) * 180.0D / 3.141592653589793D);
this.rotPitch = (float)(Math.atan2((double)yd, var7) * 180.0D / 3.141592653589793D);
this.prevYaw = this.rotYaw;
this.prevPitch = this.rotPitch;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
}
private EntityPlayer getPlayer()
{
if (player == null)
{
player = Minecraft.getMinecraft().thePlayer;
}
return player;
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY)
{
if (!renderParticle) return;
tessellator.draw();
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
float var9 = 1.0F;
float slide = (float) getPlayer().ticksExisted;
float size = (float) flow / 100f * 2f; //0.7F;
if (advanced) Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureAdvanced);
else Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureBasic);
GL11.glTexParameterf(3553, 10242, 10497.0F);
GL11.glTexParameterf(3553, 10243, 10497.0F);
GL11.glDisable(2884);
float var11 = slide + partialTick;
float var12 = -var11 * 0.2F - (float) MathHelper.floor_float(-var11 * 0.1F);
GL11.glBlendFunc(770, 1);
GL11.glDepthMask(false);
float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX);
float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY);
float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ);
GL11.glTranslated((double)xx, (double)yy, (double)zz);
float ry = (float)((double)this.prevYaw + (double)(this.rotYaw - this.prevYaw) * (double)partialTick);
float rp = (float)((double)this.prevPitch + (double)(this.rotPitch - this.prevPitch) * (double)partialTick);
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(180.0F + ry, 0.0F, 0.0F, -1.0F);
GL11.glRotatef(rp, 1.0F, 0.0F, 0.0F);
double var44 = -0.15D * (double)size;
double var17 = 0.15D * (double)size;
// if (offset == -1)
// {
// offset = rp / 90F * 0.3f;
// LogHelper.info(offset);
// }
//
//
//
//// GL11.glTranslated(0, 0.4 - Math.abs(offset) / 1.8, -offset);
// GL11.glTranslated(0, 0.16 + Math.abs(offset), 0);
for(int t = 0; t < 2; ++t) {
double var29 = (double)(this.length * var9);
double var31 = 0D;
double var33 = 1D;
double var35 = (double)(-1.0F + var12 + (float)t / 3.0F);
double var37 = (double)(this.length * var9) + var35;
GL11.glRotatef(t * 90.0F, 0.0F, 1.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.setBrightness(200);
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f);
tessellator.addVertexWithUV(var44, var29, 0.0D, var33, var37);
tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35);
tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35);
tessellator.addVertexWithUV(var17, var29, 0.0D, var31, var37);
tessellator.draw();
GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F);
}
GL11.glDepthMask(true);
GL11.glBlendFunc(770, 771);
GL11.glEnable(2884);
GL11.glPopAttrib();
GL11.glPopMatrix();
//renderParticleRing(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
ResourceHelper.bindDefaultParticles();
tessellator.startDrawingQuads();
}
public int getFlow() {
return flow;
}
public void setFlow(int flow) {
this.flow = flow;
}
}
@@ -0,0 +1,116 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
/**
* Created by Brandon on 9/02/2015.
*/
public class ParticleEnergyRing extends EntityFX {
/**
* Power flow integer Ranges from 0 to 100
*/
private int flow;
private boolean advanced;
private boolean renderParticle = true;
public ParticleEnergyRing(World world, double x, double y, double z, int maxAge, int flow, boolean advanced) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.particleRed = 1F;
this.particleGreen = 1F;
this.particleBlue = 1F;
this.noClip = true;
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.particleMaxAge = maxAge;
this.flow = flow;
this.advanced = advanced;
this.setSize(1F, 1F);
}
public void update(int flow, boolean render)
{
this.renderParticle = render;
for (this.flow = 100; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {}
}
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
if (!renderParticle) return;
tessellator.draw();
GL11.glPushMatrix();
//GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
GL11.glDepthMask(false);
ResourceHelper.bindParticles();
float minU = 0.0F + 0.125F * (advanced ? 4 : 3);
float maxU = 0.0F + 0.125F * (advanced ? 5 : 4);//minU + 0.124F;
float minV = 0F;//(float)this.particleTextureIndexY / 32.0F;
float maxV = 0.1245F;//minV + 0.124F;
float drawScale = 0.2f;
if (this.particleIcon != null)
{
minU = this.particleIcon.getMinU();
maxU = this.particleIcon.getMaxU();
minV = this.particleIcon.getMinV();
maxV = this.particleIcon.getMaxV();
}
float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX);
float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY);
float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ);
tessellator.startDrawingQuads();
tessellator.setBrightness(200);
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f);
double pCount = Minecraft.getMinecraft().gameSettings.fancyGraphics ? 35 : 15;
for (int i = 0; i < pCount; i++)
{
double rot = i / pCount * (3.141 * 2D) + particleAge / 3D;//1D;//i / 10D;
double offset = 0.4;
double ox = Math.sin(rot) * offset;
double oz = Math.cos(rot) * offset;
float drawXX = drawX + (float)ox;
float drawZZ = drawZ + (float)oz;
tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV);
tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV);
tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV);
tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV);
}
tessellator.draw();
GL11.glDepthMask(true);
//GL11.glPopAttrib();
GL11.glPopMatrix();
ResourceHelper.bindDefaultParticles();
tessellator.startDrawingQuads();
}
}
@@ -1,12 +1,10 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@@ -123,7 +121,7 @@ public final class Particles {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"));
ResourceHelper.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -174,7 +172,7 @@ public final class Particles {
}
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/particle/particles.png"));
ResourceHelper.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -227,7 +225,7 @@ public final class Particles {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"));
ResourceHelper.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);//make sure you have this!!
@@ -262,7 +260,7 @@ public final class Particles {
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/particle/particles.png"));
ResourceHelper.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -423,7 +421,7 @@ public final class Particles {
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"));
ResourceHelper.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);
@@ -455,7 +453,7 @@ public final class Particles {
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/particle/particles.png"));
ResourceHelper.bindDefaultParticles();
tesselator.startDrawingQuads();
}
@@ -0,0 +1,85 @@
package com.brandon3055.draconicevolution.client.render.tile;
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyRelay;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
/**
* Created by Brandon on 31/01/2015.
*/
public class RenderTileCrystal extends TileEntitySpecialRenderer {
private static ResourceLocation texrure = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalPurpleTransparent.png");
private static ResourceLocation crystalBlue = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalBlue.png");
private static ResourceLocation crystalBlueAlpha = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalBlueAlpha.png");
private static ResourceLocation crystalPurple = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalPurple.png");
private static ResourceLocation crystalPurpleAlpha = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalPurpleAlpha.png");
private static ResourceLocation crystalRed = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalRed.png");
private static ResourceLocation crystalRedAlpha = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalRedAlpha.png");
private static ResourceLocation beamTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyBeam.png");
private IModelCustom model;
public RenderTileCrystal(){
model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/Crystal.obj"));
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) {
if (tileEntity instanceof TileEnergyRelay) renderTileEntityAt((TileEnergyRelay)tileEntity, x, y, z, partialTick);
}
public void renderTileEntityAt(TileEnergyRelay tileEntity, double x, double y, double z, float partialTick) {
//--- Pre Render ---//
tileEntity.inView = 10;
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
GL11.glScalef(0.5f, 0.5f, 0.5f);
//GL11.glDisable(GL11.GL_LIGHTING); //todo disable?
RenderHelper.disableStandardItemLighting();
GL11.glEnable(GL11.GL_BLEND);
float innerLight = 100f;
float outerLight = 140f + ClientEventHandler.energyCrystalAlphaValue * 40F;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, innerLight, innerLight);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
//--- Render Bottom Layer ---//
if (tileEntity.getType() == 0) bindTexture(crystalBlue);
else bindTexture(crystalRed);
model.renderAll();
//--- Render Alpha Overlay ---//
if (tileEntity.getType() == 0) bindTexture(crystalBlueAlpha);
else bindTexture(crystalRedAlpha);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + ClientEventHandler.energyCrystalAlphaValue * 0.5f);
model.renderAll();
GL11.glDisable(GL11.GL_ALPHA_TEST);
//--- Render Overlay ---//
bindTexture(texrure);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, outerLight, outerLight);
model.renderAll();
//--- Post Render ---//
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
}
@@ -160,6 +160,7 @@ public class RenderTileParticleGen extends TileEntitySpecialRenderer
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glScalef(1.3F, 1.3F, 1.3F);
stabilizerSphereModel.renderAll();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
@@ -311,6 +312,7 @@ public class RenderTileParticleGen extends TileEntitySpecialRenderer
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
@@ -3,6 +3,8 @@ package com.brandon3055.draconicevolution.common;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.creativetab.DETab;
import com.brandon3055.draconicevolution.client.interfaces.GuiHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.common.achievements.Achievements;
import com.brandon3055.draconicevolution.common.entity.*;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
@@ -15,6 +17,7 @@ import com.brandon3055.draconicevolution.common.magic.EnchantmentReaper;
import com.brandon3055.draconicevolution.common.magic.PotionHandler;
import com.brandon3055.draconicevolution.common.network.*;
import com.brandon3055.draconicevolution.common.tileentities.*;
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyRelay;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnderResurrection;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyPylon;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore;
@@ -31,6 +34,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.potion.Potion;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import java.lang.reflect.Field;
@@ -129,6 +133,7 @@ public abstract class CommonProxy {
GameRegistry.registerTileEntity(TileDissEnchanter.class, References.RESOURCESPREFIX + "TileDissEnchanter");
GameRegistry.registerTileEntity(TileTeleporterStand.class, References.RESOURCESPREFIX + "TileTeleporterStand");
GameRegistry.registerTileEntity(TileDraconiumChest.class, References.RESOURCESPREFIX + "TileDraconiumChest");
GameRegistry.registerTileEntity(TileEnergyRelay.class, References.RESOURCESPREFIX + "TileEnergyRelay");
if (DraconicEvolution.debug) {
GameRegistry.registerTileEntity(TileTestBlock.class, References.RESOURCESPREFIX + "TileTestBlock");
GameRegistry.registerTileEntity(TileContainerTemplate.class, References.RESOURCESPREFIX + "TileContainerTemplate");
@@ -164,4 +169,13 @@ public abstract class CommonProxy {
public MinecraftServer getMCServer(){
return FMLCommonHandler.instance().getMinecraftServerInstance();
}
public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render)
{
return null;
}
public ParticleEnergyRing energyRing(World worldObj, double x, double y, double z, int powerFlow, boolean advanced, ParticleEnergyRing oldBeam, boolean render) {
return null;
}
}
@@ -41,6 +41,7 @@ public class ModBlocks {
public static BlockDE teleporterStand;
public static BlockDE draconiumChest;
public static BlockDE draconicBlock;
public static BlockDE energyCrystal;
public static Block safetyFlame;
public static ItemStack resurrectionStone;
@@ -71,6 +72,7 @@ public class ModBlocks {
teleporterStand = new TeleporterStand();
draconiumChest = new DraconiumChest();
draconicBlock = new DraconicBlock();
energyCrystal = new EnergyCrystal();
if(ConfigHandler.disable_LRD < 2) longRangeDislocator = new LongRangeDislocator();
@@ -65,6 +65,7 @@ public class ModItems {
public static ItemDE draconicIngot;
public static ItemDE draconiumEnergyCore;
public static ItemDE draconiumFluxCapacitor;
public static ItemDE wrench;
public static ItemDE teleporterMKI;
public static ItemDE teleporterMKII;
@@ -119,6 +120,7 @@ public class ModItems {
draconicIngot = new DraconicIngot();
draconiumEnergyCore = new DraconiumEnergyCore();
draconiumFluxCapacitor = new DraconiumFluxCapacitor();
wrench = new Wrench();
//Custom ItemStacks
wyvernEnergyCore = new ItemStack(ModItems.draconiumEnergyCore, 1, 0);
@@ -4,7 +4,7 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.interfaces.GuiHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleCustom;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.lib.Strings;
import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator;
@@ -77,7 +77,6 @@ public class TestBlock extends BlockDE {
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float px, float py, float pz)
{
EntityLightningBolt bolt = new EntityLightningBolt(world, x, y, z + 5);
//System.out.println(world.getBlockMetadata(x,y,z));
world.spawnEntityInWorld(bolt);
@@ -101,9 +100,9 @@ public class TestBlock extends BlockDE {
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) {
for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i));
}
//for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, 0));
//}
}
@Override
@@ -120,7 +119,7 @@ public class TestBlock extends BlockDE {
@Override
public int getRenderType() {
return super.getRenderType();
return -1;//super.getRenderType();
}
@Override
@@ -2,7 +2,7 @@ package com.brandon3055.draconicevolution.common.blocks;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.lib.Strings;
import cpw.mods.fml.relauncher.Side;
@@ -0,0 +1,26 @@
package com.brandon3055.draconicevolution.common.blocks.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
/**
* Created by Brandon on 10/02/2015.
*/
public class EnergyCrystalItemBlock extends ItemBlock {
public EnergyCrystalItemBlock(Block block) {
super(block);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int par1) {
return par1;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + stack.getItemDamage();
}
}
@@ -0,0 +1,128 @@
package com.brandon3055.draconicevolution.common.blocks.machine;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.blocks.BlockDE;
import com.brandon3055.draconicevolution.common.blocks.itemblocks.EnergyCrystalItemBlock;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.lib.Strings;
import com.brandon3055.draconicevolution.common.tileentities.energynet.IRemoteEnergyHandler;
import com.brandon3055.draconicevolution.common.tileentities.energynet.LinkedEnergyDevice;
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyRelay;
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileRemoteEnergyBase;
import com.brandon3055.draconicevolution.common.utills.IHudDisplayBlock;
import com.brandon3055.draconicevolution.common.utills.InfoHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Brandon on 10/02/2015.
*/
public class EnergyCrystal extends BlockDE implements IHudDisplayBlock
{
public static final byte RELAY_TIER_1 = 0;
public static final byte RELAY_TIER_2 = 1;
public EnergyCrystal()
{
super(Material.glass);
this.setBlockName(Strings.energyCrystalName);
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
this.setStepSound(soundTypeGlass);
ModBlocks.register(this, EnergyCrystalItemBlock.class);
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) {
list.add(new ItemStack(item, 1, 0));
list.add(new ItemStack(item, 1, 1));
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) {
int meta = iBlockAccess.getBlockMetadata(x, y, z);
if (meta == 1 || meta == 0) setBlockBounds(0.37F, 0.135F, 0.37F, 0.63F, 0.865F, 0.63F);
}
@Override
public boolean hasTileEntity(int metadata) {
return metadata == 0 || metadata == 1;
}
@Override
public TileEntity createTileEntity(World world, int metadata) {
return metadata == 0 || metadata == 1 ? new TileEnergyRelay(metadata) : null;
}
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block_0");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xx, float yy, float zz) {
if (world.getTileEntity(x, y, z) instanceof TileRemoteEnergyBase) ((TileRemoteEnergyBase)world.getTileEntity(x, y, z)).onBlockActivated(player);
return true;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return 4;//super.getLightValue(world, x, y, z);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
}
@Override
public List<String> getDisplayData(World world, int x, int y, int z) {
List<String> list = new ArrayList<String>();
IRemoteEnergyHandler tile = world.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) world.getTileEntity(x, y, z) : null;
if (tile != null)
{
list.add(InfoHelper.HITC()+getLocalizedName());
list.add("RF: " + tile.getEnergyStored(ForgeDirection.DOWN));
list.add("Cap: " + tile.getCapacity() + "%");
if (tile instanceof TileEnergyRelay)
{
for (LinkedEnergyDevice l : ((TileEnergyRelay) tile).linkedDevices)
{
list.add(l.toString());
}
}
}
return list;
}
}
@@ -5,7 +5,7 @@ import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.blocks.DraconiumBlock;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
import com.brandon3055.draconicevolution.common.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.common.utills.Utills;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -0,0 +1,33 @@
package com.brandon3055.draconicevolution.common.items.tools;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.items.ItemDE;
import com.brandon3055.draconicevolution.common.lib.Strings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.List;
/**
* Created by Brandon on 23/08/2014.
*/
public class Wrench extends ItemDE {
public Wrench()
{
this.setUnlocalizedName(Strings.wrenchName);
this.setCreativeTab(DraconicEvolution.tabToolsWeapons);
this.setMaxStackSize(1);
ModItems.register(this);
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) {
//list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.safetyMatch.txt"));
}
}
@@ -25,15 +25,16 @@ public final class References {
//======================Data Types========================//
public static final byte BYTE_ID = 0;
public static final byte SHORT_ID = 1;
public static final byte INT_ID = 2;
public static final byte LONG_ID = 3;
public static final byte FLOAT_ID = 4;
public static final byte DOUBLE_ID = 5;
public static final byte BOOLEAN_ID = 6;
public static final byte CHAR_ID = 7;
public static final byte STRING_ID = 8;
public static final byte BYTE_ID = 0;
public static final byte SHORT_ID = 1;
public static final byte INT_ID = 2;
public static final byte LONG_ID = 3;
public static final byte FLOAT_ID = 4;
public static final byte DOUBLE_ID = 5;
public static final byte BOOLEAN_ID = 6;
public static final byte CHAR_ID = 7;
public static final byte STRING_ID = 8;
public static final byte TWO_INTS_ID = 9;
//======================Tags========================//
@@ -68,4 +68,6 @@ public class Strings {// public sta
public static final String draconicBlockName = "draconicBlock";
public static final String draconiumEnergyCoreName = "draconiumEnergyCore";
public static final String draconiumFluxCapacitorName = "draconiumFluxCapacitor";
public static final String energyCrystalName = "energyCrystal";
public static final String wrenchName = "wrench";
}
@@ -22,7 +22,6 @@ public class ButtonPacket implements IMessage
public static final byte ID_DRACONIUMCHEST1 = 3;
public static final byte ID_DRACONIUMCHEST2 = 4;
public static final byte ID_DRACONIUMCHEST3 = 5;
public static final byte ID_TOOLINVENTORY = 6;
public static final byte ID_TOOLCONFIG = 7;
byte buttonId = 0;
boolean state = false;
@@ -32,7 +32,7 @@ public class ItemConfigPacket implements IMessage
this.datatype = bytes.readByte();
this.slot = bytes.readInt();
this.name = ByteBufUtils.readUTF8String(bytes);
this.value = DataUtills.readObjectFromBytes(bytes, datatype);
this.value = DataUtills.instance.readObjectFromBytes(bytes, datatype);
}
@Override
@@ -40,7 +40,7 @@ public class ItemConfigPacket implements IMessage
bytes.writeByte(datatype);
bytes.writeInt(slot);
ByteBufUtils.writeUTF8String(bytes, name);
DataUtills.writeObjectToBytes(bytes, datatype, value);
DataUtills.instance.writeObjectToBytes(bytes, datatype, value);
}
public static class Handler implements IMessageHandler<ItemConfigPacket, IMessage> {
@@ -51,7 +51,7 @@ public class TileObjectPacket implements IMessage{
bytes.writeByte(dataType);
bytes.writeShort(index);
DataUtills.writeObjectToBytes(bytes, dataType, object);
DataUtills.instance.writeObjectToBytes(bytes, dataType, object);
}
@@ -68,7 +68,7 @@ public class TileObjectPacket implements IMessage{
dataType = bytes.readByte();
index = bytes.readShort();
object = DataUtills.readObjectFromBytes(bytes, dataType);
object = DataUtills.instance.readObjectFromBytes(bytes, dataType);
}
public static class Handler implements IMessageHandler<TileObjectPacket, IMessage> {
@@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.tileentities;
import cofh.api.energy.IEnergyContainerItem;
import cofh.api.energy.IEnergyHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergy;
import com.brandon3055.draconicevolution.common.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
import cpw.mods.fml.relauncher.Side;
@@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.tileentities;
import com.brandon3055.draconicevolution.client.render.particle.ParticleCustom;
import com.brandon3055.draconicevolution.client.render.particle.Particles;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
import com.brandon3055.draconicevolution.common.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -1,6 +1,8 @@
package com.brandon3055.draconicevolution.common.tileentities;
import cofh.api.energy.IEnergyHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.brandon3055.draconicevolution.common.utills.Utills;
@@ -22,9 +24,17 @@ public class TileTestBlock extends TileEntity implements IEnergyHandler {
public EnergyStorage energy = new EnergyStorage(100000000);
public int maxInput = 100000000;
public float modelRotation;
//Use a map for the beam to each target (Target, Beam)
private ParticleEnergyBeam beam = null;
private ParticleEnergyRing ring = null;
@Override
public void updateEntity() {
//beam = DraconicEvolution.proxy.energyBeam(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0.5, 4.5, 0.5, 100, true, beam);
//ring = DraconicEvolution.proxy.energyRing(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, ClientEventHandler.elapsedTicks % 100, true, ring);
if (worldObj.isRemote) return;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (worldObj.getTileEntity(xCoord+d.offsetX, yCoord+d.offsetY, zCoord+d.offsetZ) instanceof IEnergyHandler) ((IEnergyHandler)worldObj.getTileEntity(xCoord+d.offsetX, yCoord+d.offsetY, zCoord+d.offsetZ)).receiveEnergy(ForgeDirection.DOWN, Integer.MAX_VALUE, false);
@@ -0,0 +1,27 @@
package com.brandon3055.draconicevolution.common.tileentities.energynet;
import cofh.api.energy.IEnergyHandler;
import net.minecraft.entity.player.EntityPlayer;
/**
* Created by Brandon on 10/02/2015.
*/
public interface IRemoteEnergyHandler extends IEnergyHandler {
//todo add method for linking
/**
* @param player The player binding the tiles
* @param x the xCoord of the other tile
* @param y the yCoord of the other tile
* @param z the zCoord of the other tile
* @param callOtherEnd whether or not to call handleBinding in the other tile
* */
boolean handleBinding(EntityPlayer player, int x, int y, int z, boolean callOtherEnd);
double getCapacity();
double getBeamX();
double getBeamY();
double getBeamZ();
}
@@ -0,0 +1,68 @@
package com.brandon3055.draconicevolution.common.tileentities.energynet;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/**
* Created by Brandon on 11/02/2015.
*/
public class LinkedEnergyDevice
{
public ParticleEnergyBeam beam;
/**Energy Flow to this device (range: 0D - 100D)*/
public double energyFlow = 0;
public double lastTickEnergyFlow = 0;
public int xCoord;
public int yCoord;
public int zCoord;
public LinkedEnergyDevice() {}
public LinkedEnergyDevice(int xCoord, int yCoord, int zCoord, ParticleEnergyBeam beam)
{
this.xCoord = xCoord;
this.yCoord = yCoord;
this.zCoord = zCoord;
this.beam = beam;
}
public TileEntity getTile(World world)
{
return world.getTileEntity(xCoord, yCoord, zCoord);
}
public IRemoteEnergyHandler getEnergyTile(World world)
{
return getTile(world) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) getTile(world) : null;
}
public LinkedEnergyDevice writeToNBT(NBTTagCompound compound, String key)
{
compound.setInteger("X_" + key, xCoord);
compound.setInteger("Y_" + key, yCoord);
compound.setInteger("Z_" + key, zCoord);
if (beam != null) compound.setShort("Flow_" + key, (short)beam.getFlow());
return this;
}
public LinkedEnergyDevice readFromNBT(NBTTagCompound compound, String key)
{
xCoord = compound.getInteger("X_" + key);
yCoord = compound.getInteger("Y_" + key);
zCoord = compound.getInteger("Z_" + key);
if (beam != null) beam.setFlow(compound.getShort("Flow" + key));
return this;
}
@Override
public String toString() {
return "[x: "+xCoord + " y: " + yCoord + " z: " + zCoord + "]";
}
public boolean isValid(World world)
{
return getEnergyTile(world) != null;
}
}
@@ -0,0 +1,252 @@
package com.brandon3055.draconicevolution.common.tileentities.energynet;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.DataUtills;
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.brandon3055.draconicevolution.common.utills.Utills;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Brandon on 10/02/2015.
*/
public class TileEnergyRelay extends TileRemoteEnergyBase {
/**The tier of the relay (0-1)*/
private int type;
private int lastTickEnergy;
public byte inView = 0;
private ParticleEnergyRing ring;
public List<LinkedEnergyDevice> linkedDevices = new ArrayList<LinkedEnergyDevice>();
public TileEnergyRelay(){}
public TileEnergyRelay(int type){
this.type = type;
if (type == 0) this.setStorage(50000, 50000, 50000);
else this.setStorage(500000, 500000, 500000);
}
@Override
public void onBlockActivated(EntityPlayer player) {
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.wrench)
{
ItemStack wrench = player.getHeldItem();
NBTTagCompound linkDat = null;
if (wrench.hasTagCompound() && wrench.getTagCompound().hasKey("LinkData")) linkDat = wrench.getTagCompound().getCompoundTag("LinkData");
if (linkDat != null && linkDat.hasKey("Bound") && linkDat.getBoolean("Bound"))
{
handleBinding(player, linkDat.getInteger("XCoord"), linkDat.getInteger("YCoord"), linkDat.getInteger("ZCoord"), true);
linkDat.setBoolean("Bound", false);
}
else
{
linkDat = new NBTTagCompound();
linkDat.setInteger("XCoord", xCoord);
linkDat.setInteger("YCoord", yCoord);
linkDat.setInteger("ZCoord", zCoord);
linkDat.setBoolean("Bound", true);
ItemNBTHelper.getCompound(wrench).setTag("LinkData", linkDat);
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.posSaved"));
}
}
else {
if (!player.isSneaking())receiveEnergy(ForgeDirection.UNKNOWN, 100000, false);
else extractEnergy(ForgeDirection.UNKNOWN, 100000, false);
}
}
@Override
public boolean handleBinding(EntityPlayer player, int x, int y, int z, boolean callOther)
{
int range = (type + 1) * 10;
IRemoteEnergyHandler tile = worldObj.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) worldObj.getTileEntity(x, y, z) : null;
if (tile == null || (x == xCoord && y == yCoord && z == zCoord))
{
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.invalidTile"));
return false;
}
else if (Utills.getDistanceAtoB(xCoord, yCoord, zCoord, x, y, z) > range)
{
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.outOfRange"));
return false;
}
if (callOther && !tile.handleBinding(player, xCoord, yCoord, zCoord, false))
{
LogHelper.info("other Invalid");
return false;
}
if (callOther && worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.linked"));
for (LinkedEnergyDevice ld : linkedDevices)
{
if (ld.xCoord == x && ld.yCoord == y && ld.zCoord == z) return true;
}
linkedDevices.add(new LinkedEnergyDevice(x, y, z, null));
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return true;
}
@Override
public void updateEntity() {
updateLinkedDevices();
if (worldObj.isRemote)
{
if (inView > 0) --inView;
ring = DraconicEvolution.proxy.energyRing(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, type == 1, ring, inView > 0);
return;
}
super.updateEntity();
}
private void updateLinkedDevices()
{
//LogHelper.info(storage.getEnergyStored());
for (LinkedEnergyDevice device : linkedDevices)
{
if (!device.isValid(worldObj)) {
linkedDevices.remove(device);
updateLinkedDevices();
return;
}
if (worldObj.isRemote)
{
device.beam = DraconicEvolution.proxy.energyBeam(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, device.xCoord + 0.5, device.yCoord + 0.5, device.zCoord + 0.5, (int)device.energyFlow, getType() == 1, device.beam, true);
}
else
{
int transferCap = 10000 + type * 90000;
IRemoteEnergyHandler remoteTile = device.getEnergyTile(worldObj);
double difference = getCapacity() - remoteTile.getCapacity();
int energyToEqual = (int)(((difference / 100D) * (double)remoteTile.getMaxEnergyStored(ForgeDirection.UNKNOWN)) / 2.1D);
double maxFlow = Math.min(energyToEqual, Math.min(transferCap, remoteTile.getMaxEnergyStored(ForgeDirection.UNKNOWN) - remoteTile.getEnergyStored(ForgeDirection.UNKNOWN)));
device.energyFlow = getFlow(getCapacity(), remoteTile.getCapacity());
int flow = (int) ((device.energyFlow / 100D) * maxFlow);
int transfered = storage.extractEnergy(remoteTile.receiveEnergy(ForgeDirection.UNKNOWN, storage.extractEnergy(flow, true), false), false);
//LogHelper.info("dif:" + difference + " flow:" + getFlow(getCapacity(), remoteTile.getCapacity()) + " EtoE:" + energyToEqual + " tfrd:" + transfered + " X:" + xCoord + " lCap:" + getCapacity() + " rCap:" + remoteTile.getCapacity() + " strd:" + storage.getEnergyStored() + " T:" + type + " mxflw:" + maxFlow);
//LogHelper.info(flow + " " + transfered + " " + getEnergyStored(ForgeDirection.UNKNOWN));
//if (device.energyFlow > 0)LogHelper.info(device.energyFlow + " " + transfered);
//if (device.energyFlow == 0) LogHelper.info(device.getEnergyTile(worldObj));
detectAndSendChanges(linkedDevices.indexOf(device));
}
}
}
private void detectAndSendChanges(int index)
{
if (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow) {
sendObject(References.TWO_INTS_ID, 0, new DataUtills.TwoXInteger(index, (int)linkedDevices.get(index).energyFlow));
linkedDevices.get(index).lastTickEnergyFlow = linkedDevices.get(index).energyFlow;
}
if (getEnergyStored(ForgeDirection.UNKNOWN) != lastTickEnergy) sendObject(References.INT_ID, 1, getEnergyStored(ForgeDirection.UNKNOWN));
}
@SideOnly(Side.CLIENT)
@Override
public void receiveObject(int index, Object object) {
if (index == 0 && object instanceof DataUtills.TwoXInteger && linkedDevices.size() > ((DataUtills.TwoXInteger) object).i1)
{
linkedDevices.get(((DataUtills.TwoXInteger) object).i1).energyFlow = ((DataUtills.TwoXInteger) object).i2;
}
else if (index == 1) storage.setEnergyStored((Integer)object);
}
@Override
public void writeToNBT(NBTTagCompound compound) {
compound.setByte("Type", (byte)type);
int index = 0;
compound.setInteger("LinkCount", linkedDevices.size());
for (LinkedEnergyDevice ld : linkedDevices)
{
ld.writeToNBT(compound, "LinkedDevice_" + index);
++index;
}
super.writeToNBT(compound);
storage.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
type = compound.getByte("Type");
if (type == 0) this.setStorage(50000, 50000, 50000);
else this.setStorage(500000, 500000, 500000);
int linkCount = compound.getInteger("LinkCount");
linkedDevices = new ArrayList<LinkedEnergyDevice>();
for (int i = 0; i < linkCount; i++)
{
linkedDevices.add(new LinkedEnergyDevice().readFromNBT(compound, "LinkedDevice_" + i));
}
super.readFromNBT(compound);
storage.readFromNBT(compound);
}
public int getType() {
return type;
}
@Override
public double getCapacity() {
return ((double) getEnergyStored(ForgeDirection.UNKNOWN) / (double) getMaxEnergyStored(ForgeDirection.UNKNOWN)) * 100D;
}
/**Calculates the energy flow based on the local buffer
* and the remote buffer
*return double between 0 to 100*/
private double getFlow(double localCap, double remoteCap)
{
return Math.max(0, Math.min(100, (localCap - remoteCap) * 10D));
}
@Override
public double getBeamX() {
return 0.5D;
}
@Override
public double getBeamY() {
return 0.5D;
}
@Override
public double getBeamZ() {
return 0.5D;
}
}
@@ -0,0 +1,80 @@
package com.brandon3055.draconicevolution.common.tileentities.energynet;
import com.brandon3055.draconicevolution.common.tileentities.TileObjectSync;
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Created by Brandon on 10/02/2015.
*/
public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRemoteEnergyHandler {
protected EnergyStorage storage = new EnergyStorage(0);
public void setStorage(int cap, int extract, int receive)
{
storage.setCapacity(cap);
storage.setMaxExtract(extract);
storage.setMaxReceive(receive);
}
public void onBlockActivated(EntityPlayer player)
{
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return storage.receiveEnergy(maxReceive, simulate);
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return storage.extractEnergy(maxExtract, simulate);
}
@Override
public int getEnergyStored(ForgeDirection from) {
return storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return storage.getMaxEnergyStored();
}
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return false;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tagCompound = new NBTTagCompound();
writeToNBT(tagCompound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
}
}
@@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles;
import com.brandon3055.draconicevolution.client.render.particle.Particles.AdvancedSeekerParticle;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper;
import com.brandon3055.draconicevolution.common.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon;
import com.brandon3055.draconicevolution.common.entity.ExtendedPlayer;
@@ -4,7 +4,7 @@ import cofh.api.energy.IEnergyHandler;
import com.brandon3055.draconicevolution.client.render.particle.Particles;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
import com.brandon3055.draconicevolution.common.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.TileObjectSync;
import cpw.mods.fml.common.network.NetworkRegistry;
@@ -10,7 +10,9 @@ import net.minecraft.item.ItemStack;
*/
public class DataUtills {
public static void writeObjectToBytes(ByteBuf bytes, int dataType, Object object){
public static DataUtills instance = new DataUtills();
public void writeObjectToBytes(ByteBuf bytes, int dataType, Object object){
switch (dataType){
case References.BYTE_ID:
bytes.writeByte((Byte)object);
@@ -39,10 +41,14 @@ public class DataUtills {
case References.BOOLEAN_ID:
bytes.writeBoolean((Boolean) object);
break;
case References.TWO_INTS_ID:
bytes.writeInt(((TwoXInteger)object).i1);
bytes.writeInt(((TwoXInteger)object).i2);
break;
}
}
public static Object readObjectFromBytes(ByteBuf bytes, int dataType){
public Object readObjectFromBytes(ByteBuf bytes, int dataType){
switch (dataType){
case References.BYTE_ID:
return bytes.readByte();
@@ -62,6 +68,11 @@ public class DataUtills {
return ByteBufUtils.readUTF8String(bytes);
case References.BOOLEAN_ID:
return bytes.readBoolean();
case References.TWO_INTS_ID:
TwoXInteger tx = new TwoXInteger(0, 0);
tx.i1 = bytes.readInt();
tx.i2 = bytes.readInt();
return tx;
}
return null;
}
@@ -144,4 +155,15 @@ public class DataUtills {
return null;
}
public static class TwoXInteger
{
public int i1;
public int i2;
public TwoXInteger(int i1, int i2)
{
this.i1 = i1;
this.i2 = i2;
}
}
}
@@ -34,4 +34,18 @@ public class Utills {
double dz = z1-z2;
return Math.sqrt((dx*dx + dy*dy + dz*dz ));
}
/**
* Calculates the exact distance between two points in 2D space
* @param x1 point A x
* @param z1 point A z
* @param x2 point B x
* @param z2 point B z
* @return The distance between point A and point B
*/
public static double getDistanceAtoB(double x1, double z1, double x2, double z2){
double dx = x1-x2;
double dz = z1-z2;
return Math.sqrt((dx*dx + dz*dz ));
}
}