Added Animation for MAssembler

This commit is contained in:
AlgorithmX2 2014-07-06 21:04:58 -05:00
parent 70ef70a42e
commit f3344f28c0
24 changed files with 637 additions and 262 deletions

View file

@ -17,7 +17,7 @@ import appeng.api.AEApi;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCharger;
import appeng.client.render.effects.LightningEffect;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
@ -88,7 +88,7 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
{
LightningEffect fx = new LightningEffect( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}

View file

@ -14,7 +14,7 @@ import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockQuartzAccelerator;
import appeng.client.render.effects.LightningEffect;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
@ -112,7 +112,7 @@ public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrient
ry += dz * forward.offsetY;
rz += dz * forward.offsetZ;
LightningEffect fx = new LightningEffect( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}

View file

@ -19,7 +19,7 @@ import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzTorch;
import appeng.client.render.effects.LightningEffect;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
@ -124,7 +124,7 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
{
LightningEffect fx = new LightningEffect( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}

View file

@ -6,7 +6,7 @@ import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
import appeng.client.render.effects.VibrantEffect;
import appeng.client.render.effects.VibrantFX;
import appeng.core.CommonHelper;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
@ -36,7 +36,7 @@ public class BlockQuartzLamp extends BlockQuartzGlass
double d1 = (double) (r.nextFloat() - 0.5F) * 0.96D;
double d2 = (double) (r.nextFloat() - 0.5F) * 0.96D;
VibrantEffect fx = new VibrantEffect( w, 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
VibrantFX fx = new VibrantFX( w, 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}

View file

@ -7,7 +7,7 @@ import net.minecraft.client.particle.EntityFX;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.client.render.effects.ChargedOreEffect;
import appeng.client.render.effects.ChargedOreFX;
import appeng.core.CommonHelper;
import appeng.core.AEConfig;
import cpw.mods.fml.relauncher.Side;
@ -66,7 +66,7 @@ public class OreQuartzCharged extends OreQuartz
if ( CommonHelper.proxy.shouldAddParticles( r ) )
{
ChargedOreEffect fx = new ChargedOreEffect( w, x + xOff, y + yOff, z + zOff, 0.0f, 0.0f, 0.0f );
ChargedOreFX fx = new ChargedOreFX( w, x + xOff, y + yOff, z + zOff, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}

View file

@ -20,7 +20,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
@ -36,9 +35,10 @@ import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.TESRWrapper;
import appeng.client.render.WorldRender;
import appeng.client.render.effects.CraftingFx;
import appeng.client.render.effects.EnergyFx;
import appeng.client.render.effects.LightningEffect;
import appeng.client.render.effects.VibrantEffect;
import appeng.client.render.effects.LightningFX;
import appeng.client.render.effects.VibrantFX;
import appeng.client.texture.CableBusTextures;
import appeng.client.texture.ExtraBlockTextures;
import appeng.client.texture.ExtraItemTextures;
@ -47,7 +47,9 @@ import appeng.core.AELog;
import appeng.core.CommonHelper;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
import appeng.entity.RenderTinyTNTPrimed;
import appeng.helpers.IMouseWheelItem;
import appeng.server.ServerHelper;
@ -63,11 +65,11 @@ public class ClientHelper extends ServerHelper
private static RenderBlocks blockRenderer = new RenderBlocks();
@Override
public void doRenderItem(ItemStack itemstack, TileEntity par1EntityItemFrame)
public void doRenderItem(ItemStack itemstack, World w)
{
if ( itemstack != null )
{
EntityItem entityitem = new EntityItem( par1EntityItemFrame.getWorldObj(), 0.0D, 0.0D, 0.0D, itemstack );
EntityItem entityitem = new EntityItem( w, 0.0D, 0.0D, 0.0D, itemstack );
entityitem.getEntityItem().stackSize = 1;
// set all this stuff and then do shit? meh?
@ -153,6 +155,7 @@ public class ClientHelper extends ServerHelper
{
RenderingRegistry.registerBlockHandler( WorldRender.instance );
RenderManager.instance.entityRenderMap.put( EntityTinyTNTPrimed.class, new RenderTinyTNTPrimed() );
RenderManager.instance.entityRenderMap.put( EntityFloatingItem.class, new RenderFloatingItem() );
}
@SubscribeEvent
@ -238,6 +241,9 @@ public class ClientHelper extends ServerHelper
case Vibrant:
spawnVibrant( worldObj, posX, posY, posZ );
return;
case Crafting:
spawnCrafting( worldObj, posX, posY, posZ );
return;
case Energy:
spawnEnergy( worldObj, posX, posY, posZ );
return;
@ -256,14 +262,14 @@ public class ClientHelper extends ServerHelper
double d1 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
double d2 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
VibrantEffect fx = new VibrantEffect( w, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D );
VibrantFX fx = new VibrantFX( w, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
private void spawnLightning(World worldObj, double posX, double posY, double posZ)
{
LightningEffect fx = new LightningEffect( worldObj, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
LightningFX fx = new LightningFX( worldObj, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
@ -282,6 +288,21 @@ public class ClientHelper extends ServerHelper
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
private void spawnCrafting(World w, double posX, double posY, double posZ)
{
float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
CraftingFx fx = new CraftingFx( w, posX + x, posY + y, posZ + z, Items.diamond );
fx.motionX = -x * 0.2;
fx.motionY = -y * 0.2;
fx.motionZ = -z * 0.2;
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
@Override
public boolean shouldAddParticles(Random r)
{

View file

@ -2,5 +2,5 @@ package appeng.client;
public enum EffectType
{
Energy, Lightning, Vibrant
Energy, Lightning, Vibrant, Crafting
}

View file

@ -0,0 +1,65 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.EffectType;
import appeng.core.CommonHelper;
import appeng.entity.EntityFloatingItem;
public class AssemblerFX extends EntityFX
{
IAEItemStack item;
EntityFloatingItem fi;
float time = 0;
float speed;
public AssemblerFX(World w, double x, double y, double z, double r, double g, double b, float speed, IAEItemStack is) {
super( w, x, y, z, r, g, b );
motionX = 0;
motionY = 0;
motionZ = 0;
item = is;
this.speed = speed;
fi = new EntityFloatingItem( this, w, x, y, z, is.getItemStack() );
w.spawnEntityInWorld( fi );
particleMaxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
}
@Override
public int getBrightnessForRender(float par1)
{
int j1 = 13;
return j1 << 20 | j1 << 4;
}
@Override
public void onUpdate()
{
super.onUpdate();
if ( isDead )
fi.setDead();
else
{
float lifeSpan = (float) this.particleAge / (float) this.particleMaxAge;
fi.setProgress( lifeSpan );
}
}
@Override
public void renderParticle(Tessellator tess, float l, float rX, float rY, float rZ, float rYZ, float rXY)
{
time += l;
if ( time > 4.0 )
{
time -= 4.0;
// if ( CommonHelper.proxy.shouldAddParticles( r ) )
for (int x = 0; x < (int) Math.ceil( speed / 5 ); x++)
CommonHelper.proxy.spawnEffect( EffectType.Crafting, worldObj, posX, posY, posZ );
}
}
}

View file

@ -3,10 +3,10 @@ package appeng.client.render.effects;
import net.minecraft.client.particle.EntityReddustFX;
import net.minecraft.world.World;
public class ChargedOreEffect extends EntityReddustFX
public class ChargedOreFX extends EntityReddustFX
{
public ChargedOreEffect(World w, double x, double y, double z, float r, float g, float b) {
public ChargedOreFX(World w, double x, double y, double z, float r, float g, float b) {
super( w, x, y, z, 0.21f, 0.61f, 1.0f );
}

View file

@ -0,0 +1,103 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.EntityBreakingFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.client.texture.ExtraBlockTextures;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class CraftingFx extends EntityBreakingFX
{
private IIcon particleTextureIndex;
private int startBlkX;
private int startBlkY;
private int startBlkZ;
public int getFXLayer()
{
return 1;
}
public CraftingFx(World par1World, double par2, double par4, double par6, Item par8Item) {
super( par1World, par2, par4, par6, par8Item );
particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 0.9f;
this.particleRed = 1;
this.particleAlpha = 1.3f;
this.particleScale = 1.5f;
this.particleTextureIndex = ExtraBlockTextures.BlockEnergyParticle.getIcon();
particleMaxAge /= 1.2;
startBlkX = MathHelper.floor_double( posX );
startBlkY = MathHelper.floor_double( posY );
startBlkZ = MathHelper.floor_double( posZ );
}
public void fromItem(ForgeDirection d)
{
this.posX += 0.2 * d.offsetX;
this.posY += 0.2 * d.offsetY;
this.posZ += 0.2 * d.offsetZ;
this.particleScale *= 0.8f;
}
public void onUpdate()
{
super.onUpdate();
this.particleScale *= 0.51f;
this.particleAlpha *= 0.51f;
}
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
/*
* Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.locationBlocksTexture );
*
* GL11.glPushMatrix(); GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
*
* GL11.glDepthMask( false ); GL11.glEnable( GL11.GL_BLEND ); GL11.glBlendFunc( GL11.GL_SRC_ALPHA,
* GL11.GL_ONE_MINUS_SRC_ALPHA ); GL11.glAlphaFunc( GL11.GL_GREATER, 0.003921569F );
*/
float f6 = this.particleTextureIndex.getMinU();
float f7 = this.particleTextureIndex.getMaxU();
float f8 = this.particleTextureIndex.getMinV();
float f9 = this.particleTextureIndex.getMaxV();
float f10 = 0.1F * this.particleScale;
float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX);
float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY);
float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ);
float f14 = 1.0F;
int blkX = MathHelper.floor_double( posX );
int blkY = MathHelper.floor_double( posY );
int blkZ = MathHelper.floor_double( posZ );
if ( blkX == startBlkX && blkY == startBlkY && blkZ == startBlkZ )
{
par1Tessellator.setColorRGBA_F( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha );
par1Tessellator.addVertexWithUV( (double) (f11 - par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 - par5 * f10 - par7 * f10),
(double) f7, (double) f9 );
par1Tessellator.addVertexWithUV( (double) (f11 - par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 - par5 * f10 + par7 * f10),
(double) f7, (double) f8 );
par1Tessellator.addVertexWithUV( (double) (f11 + par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 + par5 * f10 + par7 * f10),
(double) f6, (double) f8 );
par1Tessellator.addVertexWithUV( (double) (f11 + par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 + par5 * f10 - par7 * f10),
(double) f6, (double) f9 );
}
// GL11.glPopAttrib();
// GL11.glPopMatrix();
}
}

View file

@ -11,14 +11,14 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class LightningEffect extends EntityFX
public class LightningFX extends EntityFX
{
final int steps = 5;
static Random rng = new Random();
double[][] Steps;
public LightningEffect(World w, double x, double y, double z, double r, double g, double b) {
public LightningFX(World w, double x, double y, double z, double r, double g, double b) {
super( w, x, y, z, r, g, b );
Steps = new double[steps][3];
motionX = 0;

View file

@ -10,12 +10,12 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.client.texture.ExtraBlockTextures;
public class MatterCannonEffect extends EntityBreakingFX
public class MatterCannonFX extends EntityBreakingFX
{
private IIcon particleTextureIndex;
public MatterCannonEffect(World par1World, double par2, double par4, double par6, Item par8Item) {
public MatterCannonFX(World par1World, double par2, double par4, double par6, Item par8Item) {
super( par1World, par2, par4, par6, par8Item );
particleGravity = 0;
this.particleBlue = 255;

View file

@ -6,10 +6,10 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class VibrantEffect extends EntityFX
public class VibrantFX extends EntityFX
{
public VibrantEffect(World par1World, double x, double y, double z, double par8, double par10, double par12) {
public VibrantFX(World par1World, double x, double y, double z, double par8, double par10, double par12) {
super( par1World, x, y, z, par8, par10, par12 );
float f = this.rand.nextFloat() * 0.1F + 0.8F;
this.particleRed = f * 0.7f;

View file

@ -5,7 +5,6 @@ import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
@ -35,8 +34,13 @@ public abstract class CommonHelper
public abstract MovingObjectPosition getMOP();
public abstract void doRenderItem(ItemStack sis, TileEntity tile);
public abstract void doRenderItem(ItemStack itemstack, World w);
public abstract void postinit();
{
// TODO Auto-generated method stub
}
}

View file

@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketClick;
import appeng.core.sync.packets.PacketCompassRequest;
import appeng.core.sync.packets.PacketCompassResponse;
@ -76,7 +77,9 @@ public class AppEngPacketHandlerBase
PACKET_PARTIAL_ITEM(PacketPartialItem.class),
PAKCET_CRAFTING_REQUEST(PacketCraftRequest.class);
PACKET_CRAFTING_REQUEST(PacketCraftRequest.class),
PAKCET_ASSEMBLER_ANIMATION(PacketAssemblerAnimation.class);
final public Class pc;
final public Constructor con;

View file

@ -0,0 +1,59 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.render.effects.AssemblerFX;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEItemStack;
public class PacketAssemblerAnimation extends AppEngPacket
{
int x, y, z;
byte rate;
IAEItemStack is;
// automatic.
public PacketAssemblerAnimation(ByteBuf stream) throws IOException {
x = stream.readInt();
y = stream.readInt();
z = stream.readInt();
rate = stream.readByte();
is = AEItemStack.loadItemStackFromPacket( stream );
}
@Override
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
{
double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
AssemblerFX fx = new AssemblerFX( Minecraft.getMinecraft().theWorld, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D, rate, is );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
// api
public PacketAssemblerAnimation(int x, int y, int z, byte rate, IAEItemStack is) throws IOException {
ByteBuf data = Unpooled.buffer();
data.writeInt( getPacketID() );
data.writeInt( this.x = x );
data.writeInt( this.y = y );
data.writeInt( this.z = z );
data.writeByte( this.rate = rate );
is.writeToPacket( data );
this.is = is;
configureWrite( data );
}
}

View file

@ -9,7 +9,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.player.EntityPlayer;
import appeng.client.ClientHelper;
import appeng.client.render.effects.LightningEffect;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
@ -39,7 +39,7 @@ public class PacketLightning extends AppEngPacket
{
if ( Platform.isClient() && AEConfig.instance.enableEffects )
{
LightningEffect fx = new LightningEffect( ClientHelper.proxy.getWorld(), x, y, z, 0.0f, 0.0f, 0.0f );
LightningFX fx = new LightningFX( ClientHelper.proxy.getWorld(), x, y, z, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}

View file

@ -10,7 +10,7 @@ import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.world.World;
import appeng.client.render.effects.MatterCannonEffect;
import appeng.client.render.effects.MatterCannonFX;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import cpw.mods.fml.client.FMLClientHandler;
@ -49,7 +49,7 @@ public class PacketMatterCannon extends AppEngPacket
World world = FMLClientHandler.instance().getClient().theWorld;
for (int a = 1; a < len; a++)
{
MatterCannonEffect fx = new MatterCannonEffect( world, x + dx * a, y + dy * a, z + dz * a, Items.diamond );
MatterCannonFX fx = new MatterCannonFX( world, x + dx * a, y + dy * a, z + dz * a, Items.diamond );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}

View file

@ -0,0 +1,45 @@
package appeng.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
final public class EntityFloatingItem extends EntityItem
{
public static int ageStatic = 0;
int superDeath = 0;
private Entity parent;
float progress = 0;
public EntityFloatingItem(Entity parent, World p_i1710_1_, double p_i1710_2_, double p_i1710_4_, double p_i1710_6_, ItemStack p_i1710_8_) {
super( p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_, p_i1710_8_ );
motionX = motionY = motionZ = 0.0d;
this.hoverStart = 0.5f;
this.rotationYaw = 0;
this.parent = parent;
}
// public boolean isEntityAlive()
public void onUpdate()
{
if ( !isDead && parent.isDead )
this.setDead();
if ( superDeath++ > 100 )
setDead();
this.age = ageStatic;
}
public void setProgress(float progress)
{
this.progress = progress;
if ( this.progress > 0.99 )
this.setDead();
}
}

View file

@ -0,0 +1,52 @@
package appeng.entity;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderFloatingItem extends RenderItem
{
public static DoubleBuffer buffer = ByteBuffer.allocateDirect( 8 * 4 ).asDoubleBuffer();
public RenderFloatingItem() {
this.shadowOpaque = 0.0F;
this.renderManager = RenderManager.instance;
}
@Override
public boolean shouldBob()
{
return false;
}
@Override
public void doRender(EntityItem p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
if ( p_76986_1_ instanceof EntityFloatingItem )
{
EntityFloatingItem efi = (EntityFloatingItem) p_76986_1_;
if ( efi.progress > 0.0 )
{
GL11.glPushMatrix();
if ( !(efi.getEntityItem().getItem() instanceof ItemBlock) )
GL11.glTranslatef( 0, -0.15f, 0 );
super.doRender( efi, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_ );
GL11.glPopMatrix();
}
}
}
}

View file

@ -12,6 +12,7 @@ import net.minecraftforge.event.world.WorldEvent;
import appeng.api.networking.IGridNode;
import appeng.core.AELog;
import appeng.crafting.CraftingJob;
import appeng.entity.EntityFloatingItem;
import appeng.me.Grid;
import appeng.me.NetworkList;
import appeng.tile.AEBaseTile;
@ -127,6 +128,12 @@ public class TickHandler
@SubscribeEvent
public void onTick(TickEvent ev)
{
if ( ev.type == Type.CLIENT && ev.phase == Phase.START )
{
EntityFloatingItem.ageStatic = (EntityFloatingItem.ageStatic + 1) % 60000;
}
// rwar!
if ( ev.type == Type.WORLD && ev.phase == Phase.END )
{

View file

@ -281,7 +281,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
// RenderHelper.enableGUIStandardItemLighting();
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
ClientHelper.proxy.doRenderItem( sis, this.tile );
ClientHelper.proxy.doRenderItem( sis, this.tile.getWorldObj() );
}
catch (Exception e)

View file

@ -8,7 +8,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
@ -23,7 +22,7 @@ public class ServerHelper extends CommonHelper
{
@Override
public void doRenderItem(ItemStack sis, TileEntity tile)
public void doRenderItem(ItemStack sis, World tile)
{
}

View file

@ -31,10 +31,13 @@ import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.ISimplifiedBundle;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.container.ContainerNull;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.items.misc.ItemEncodedPattern;
import appeng.me.GridAccessException;
import appeng.parts.automation.UpgradeInventory;
@ -48,7 +51,9 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEngInventory, ISidedInventory, IUpgradeableHost, IConfigManagerHost,
IGridTickable, ICraftingMachine, IPowerChannelState
@ -388,25 +393,26 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
TicksSinceLastCall = 1;
reboot = false;
int speed = 10;
switch (upgrades.getInstalledUpgrades( Upgrades.SPEED ))
{
case 0:
progress += userPower( TicksSinceLastCall, 10, 1.0 );
progress += userPower( TicksSinceLastCall, speed = 10, 1.0 );
break;
case 1:
progress += userPower( TicksSinceLastCall, 13, 1.3 );
progress += userPower( TicksSinceLastCall, speed = 13, 1.3 );
break;
case 2:
progress += userPower( TicksSinceLastCall, 17, 1.7 );
progress += userPower( TicksSinceLastCall, speed = 17, 1.7 );
break;
case 3:
progress += userPower( TicksSinceLastCall, 20, 2.0 );
progress += userPower( TicksSinceLastCall, speed = 20, 2.0 );
break;
case 4:
progress += userPower( TicksSinceLastCall, 25, 2.5 );
progress += userPower( TicksSinceLastCall, speed = 25, 2.5 );
break;
case 5:
progress += userPower( TicksSinceLastCall, 50, 5.0 );
progress += userPower( TicksSinceLastCall, speed = 50, 5.0 );
break;
}
@ -433,6 +439,17 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
}
ejectHeldItems();
try
{
TargetPoint where = new TargetPoint( worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 32 );
IAEItemStack item = AEItemStack.create( output );
NetworkHandler.instance.sendToAllAround( new PacketAssemblerAnimation( xCoord, yCoord, zCoord, (byte) speed, item ), where );
}
catch (IOException e)
{
// ;P
}
updateSleepyness();
return isAwake ? TickRateModulation.SLEEP : TickRateModulation.IDLE;
}