Breaking and Damaging Particles for cables now work properly.

Breaking Animation now works on Cables as expected.
Cable now has a bounding box where it touches parts.
This commit is contained in:
AlgorithmX2 2014-06-11 00:14:37 -05:00
parent d807812bc8
commit bbfa43dd92
11 changed files with 211 additions and 1 deletions

View file

@ -6,6 +6,8 @@ import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -20,6 +22,8 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.PartItemStack; import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart; import appeng.api.parts.SelectedPart;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
@ -39,6 +43,8 @@ import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus; import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR; import appeng.tile.networking.TileCableBusTESR;
import appeng.util.Platform; import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCableBus extends AEBaseBlock public class BlockCableBus extends AEBaseBlock
{ {
@ -75,6 +81,117 @@ public class BlockCableBus extends AEBaseBlock
return 0; return 0;
} }
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer)
{
Object pobj = cb( world, target.blockX, target.blockY, target.blockZ );
if ( pobj instanceof IPartHost )
{
IPartHost host = (IPartHost) pobj;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = getIcon( p );
if ( ico == null )
continue;
byte b0 = (byte) (Platform.getRandomInt() % 2 == 0 ? 1 : 0);
for (int i1 = 0; i1 < b0; ++i1)
{
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
double d0 = (double) target.blockX + ((double) i1 + 0.5D) / (double) b0;
double d1 = (double) target.blockY + ((double) j1 + 0.5D) / (double) b0;
double d2 = (double) target.blockZ + ((double) k1 + 0.5D) / (double) b0;
double dd0 = target.hitVec.xCoord;
double dd1 = target.hitVec.yCoord;
double dd2 = target.hitVec.zCoord;
EntityDiggingFX fx = (new EntityDiggingFX( world, dd0, dd1, dd2, d0 - (double) target.blockX - 0.5D, d1 - (double) target.blockY
- 0.5D, d2 - (double) target.blockZ - 0.5D, this, 0 )).applyColourMultiplier( target.blockX, target.blockY, target.blockZ );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
{
Object pobj = cb( world, x, y, z );
if ( pobj instanceof IPartHost )
{
IPartHost host = (IPartHost) pobj;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = getIcon( p );
if ( ico == null )
continue;
byte b0 = 3;
for (int i1 = 0; i1 < b0; ++i1)
{
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
double d0 = (double) x + ((double) i1 + 0.5D) / (double) b0;
double d1 = (double) y + ((double) j1 + 0.5D) / (double) b0;
double d2 = (double) z + ((double) k1 + 0.5D) / (double) b0;
EntityDiggingFX fx = (new EntityDiggingFX( world, d0, d1, d2, d0 - (double) x - 0.5D, d1 - (double) y - 0.5D, d2 - (double) z
- 0.5D, this, meta )).applyColourMultiplier( x, y, z );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
private IIcon getIcon(IPart p)
{
if ( p == null )
return null;
try
{
IIcon ico = p.getBreakingTexture();
if ( ico != null )
return ico;
}
catch (Throwable t)
{
// nothing.
}
ItemStack is = p.getItemStack( PartItemStack.Network );
if ( is == null || is.getItem() == null )
return null;
return is.getItem().getIcon( is, 0 );
}
@Override @Override
public boolean canRenderInPass(int pass) public boolean canRenderInPass(int pass)
{ {

View file

@ -29,6 +29,9 @@ public class CableRenderHelper
TileEntity te = cableBusContainer.getTile(); TileEntity te = cableBusContainer.getTile();
RenderBlocksWorkaround renderer = BusRenderer.instance.renderer; RenderBlocksWorkaround renderer = BusRenderer.instance.renderer;
if ( renderer.overrideBlockTexture != null )
BusRenderHelper.instance.setPass( 0 );
if ( renderer.blockAccess == null ) if ( renderer.blockAccess == null )
renderer.blockAccess = Minecraft.getMinecraft().theWorld; renderer.blockAccess = Minecraft.getMinecraft().theWorld;

View file

@ -16,6 +16,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -500,4 +501,10 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
return is.hasDisplayName(); return is.hasDisplayName();
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getBreakingTexture()
{
return null;
}
} }

View file

@ -434,7 +434,6 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 ); bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 );
else else
part.getBoxes( bch ); part.getBoxes( bch );
} }
if ( includeFacades && s != null && s != ForgeDirection.UNKNOWN ) if ( includeFacades && s != null && s != ForgeDirection.UNKNOWN )

View file

@ -7,6 +7,7 @@ import java.io.IOException;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.IPowerChannelState; import appeng.api.implementations.IPowerChannelState;
import appeng.api.networking.GridFlags; import appeng.api.networking.GridFlags;
@ -129,4 +130,10 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState
return (clientFlags & CHANNEL_FLAG) == CHANNEL_FLAG; return (clientFlags & CHANNEL_FLAG) == CHANNEL_FLAG;
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getBreakingTexture()
{
return CableBusTextures.PartTransitionPlaneBack.getIcon();
}
} }

View file

@ -531,6 +531,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer ); // super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
} }
@Override
public IIcon getBreakingTexture()
{
return is.getIconIndex();
}
@Override @Override
public void getBoxes(IPartCollsionHelper bch) public void getBoxes(IPartCollsionHelper bch)
{ {

View file

@ -230,4 +230,10 @@ public class PartCableAnchor implements IPart
{ {
return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE; return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE;
} }
@Override
public IIcon getBreakingTexture()
{
return null;
}
} }

View file

@ -9,6 +9,7 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.tiles.ISegmentedInventory; import appeng.api.implementations.tiles.ISegmentedInventory;
@ -127,6 +128,12 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
renderLights( x, y, z, rh, renderer ); renderLights( x, y, z, rh, renderer );
} }
@Override
public IIcon getBreakingTexture()
{
return is.getIconIndex();
}
@Override @Override
public void getBoxes(IPartCollsionHelper bch) public void getBoxes(IPartCollsionHelper bch)
{ {

View file

@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -186,6 +187,12 @@ public class PartToggleBus extends PartBasicState
renderLights( x, y, z, rh, renderer ); renderLights( x, y, z, rh, renderer );
} }
@Override
public IIcon getBreakingTexture()
{
return is.getIconIndex();
}
@Override @Override
public void getBoxes(IPartCollsionHelper bch) public void getBoxes(IPartCollsionHelper bch)
{ {

View file

@ -330,6 +330,43 @@ public class PartCable extends AEBasePart implements IPartCable
connections.clear(); connections.clear();
} }
IPartHost ph = getHost();
if ( ph != null )
{
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
IPart p = ph.getPart( dir );
if ( p instanceof IGridHost )
{
double dist = p.cableConnectionRenderTo();
switch (dir)
{
case DOWN:
bch.addBox( 6.0, dist, 6.0, 10.0, 6.0, 10.0 );
break;
case EAST:
bch.addBox( 10.0, 6.0, 6.0, 16.0 - dist, 10.0, 10.0 );
break;
case NORTH:
bch.addBox( 6.0, 6.0, dist, 10.0, 10.0, 6.0 );
break;
case SOUTH:
bch.addBox( 6.0, 6.0, 10.0, 10.0, 10.0, 16.0 - dist );
break;
case UP:
bch.addBox( 6.0, 10.0, 6.0, 10.0, 16.0 - dist, 10.0 );
break;
case WEST:
bch.addBox( dist, 6.0, 6.0, 6.0, 10.0, 10.0 );
break;
default:
continue;
}
}
}
}
for (ForgeDirection of : connections) for (ForgeDirection of : connections)
{ {
switch (of) switch (of)
@ -370,6 +407,13 @@ public class PartCable extends AEBasePart implements IPartCable
rh.setTexture( null ); rh.setTexture( null );
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getBreakingTexture()
{
return getTexture( getCableColor() );
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void rendereGlassConection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, ForgeDirection of) public void rendereGlassConection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, ForgeDirection of)
{ {

View file

@ -331,6 +331,13 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
renderLights( x, y, z, rh, renderer ); renderLights( x, y, z, rh, renderer );
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getBreakingTexture()
{
return CableBusTextures.BlockP2PTunnel2.getIcon();
}
protected void QueueTunnelDrain(PowerUnits unit, double f) protected void QueueTunnelDrain(PowerUnits unit, double f)
{ {
double ae_to_tax = unit.convertTo( PowerUnits.AE, f * AEConfig.TunnelPowerLoss ); double ae_to_tax = unit.convertTo( PowerUnits.AE, f * AEConfig.TunnelPowerLoss );