diff --git a/block/networking/BlockCableBus.java b/block/networking/BlockCableBus.java index 886e2d18..ee97652e 100644 --- a/block/networking/BlockCableBus.java +++ b/block/networking/BlockCableBus.java @@ -6,6 +6,8 @@ import java.util.Random; import net.minecraft.block.Block; 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.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -20,6 +22,8 @@ import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; 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.SelectedPart; import appeng.block.AEBaseBlock; @@ -39,6 +43,8 @@ import appeng.tile.AEBaseTile; import appeng.tile.networking.TileCableBus; import appeng.tile.networking.TileCableBusTESR; import appeng.util.Platform; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockCableBus extends AEBaseBlock { @@ -75,6 +81,117 @@ public class BlockCableBus extends AEBaseBlock 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 public boolean canRenderInPass(int pass) { diff --git a/client/render/CableRenderHelper.java b/client/render/CableRenderHelper.java index 02caf226..6211f4a7 100644 --- a/client/render/CableRenderHelper.java +++ b/client/render/CableRenderHelper.java @@ -29,6 +29,9 @@ public class CableRenderHelper TileEntity te = cableBusContainer.getTile(); RenderBlocksWorkaround renderer = BusRenderer.instance.renderer; + if ( renderer.overrideBlockTexture != null ) + BusRenderHelper.instance.setPass( 0 ); + if ( renderer.blockAccess == null ) renderer.blockAccess = Minecraft.getMinecraft().theWorld; diff --git a/parts/AEBasePart.java b/parts/AEBasePart.java index 4e1b4265..1b668af5 100644 --- a/parts/AEBasePart.java +++ b/parts/AEBasePart.java @@ -16,6 +16,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -500,4 +501,10 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea return is.hasDisplayName(); } + @Override + @SideOnly(Side.CLIENT) + public IIcon getBreakingTexture() + { + return null; + } } \ No newline at end of file diff --git a/parts/CableBusContainer.java b/parts/CableBusContainer.java index e60d1108..2e434771 100644 --- a/parts/CableBusContainer.java +++ b/parts/CableBusContainer.java @@ -434,7 +434,6 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 ); else part.getBoxes( bch ); - } if ( includeFacades && s != null && s != ForgeDirection.UNKNOWN ) diff --git a/parts/PartBasicState.java b/parts/PartBasicState.java index c0fc15e2..6fedb290 100644 --- a/parts/PartBasicState.java +++ b/parts/PartBasicState.java @@ -7,6 +7,7 @@ import java.io.IOException; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.implementations.IPowerChannelState; import appeng.api.networking.GridFlags; @@ -129,4 +130,10 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState return (clientFlags & CHANNEL_FLAG) == CHANNEL_FLAG; } + @Override + @SideOnly(Side.CLIENT) + public IIcon getBreakingTexture() + { + return CableBusTextures.PartTransitionPlaneBack.getIcon(); + } } diff --git a/parts/automation/PartLevelEmitter.java b/parts/automation/PartLevelEmitter.java index 4711d8e3..bfba6970 100644 --- a/parts/automation/PartLevelEmitter.java +++ b/parts/automation/PartLevelEmitter.java @@ -531,6 +531,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH // super.renderWorldBlock( world, x, y, z, block, modelId, renderer ); } + @Override + public IIcon getBreakingTexture() + { + return is.getIconIndex(); + } + @Override public void getBoxes(IPartCollsionHelper bch) { diff --git a/parts/misc/PartCableAnchor.java b/parts/misc/PartCableAnchor.java index 036262ff..f60e13b6 100644 --- a/parts/misc/PartCableAnchor.java +++ b/parts/misc/PartCableAnchor.java @@ -230,4 +230,10 @@ public class PartCableAnchor implements IPart { return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE; } + + @Override + public IIcon getBreakingTexture() + { + return null; + } } diff --git a/parts/misc/PartInterface.java b/parts/misc/PartInterface.java index 3fc20e63..60841e1c 100644 --- a/parts/misc/PartInterface.java +++ b/parts/misc/PartInterface.java @@ -9,6 +9,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.implementations.tiles.ISegmentedInventory; @@ -127,6 +128,12 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg renderLights( x, y, z, rh, renderer ); } + @Override + public IIcon getBreakingTexture() + { + return is.getIconIndex(); + } + @Override public void getBoxes(IPartCollsionHelper bch) { diff --git a/parts/misc/PartToggleBus.java b/parts/misc/PartToggleBus.java index fc71b343..d9ca8a11 100644 --- a/parts/misc/PartToggleBus.java +++ b/parts/misc/PartToggleBus.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -186,6 +187,12 @@ public class PartToggleBus extends PartBasicState renderLights( x, y, z, rh, renderer ); } + @Override + public IIcon getBreakingTexture() + { + return is.getIconIndex(); + } + @Override public void getBoxes(IPartCollsionHelper bch) { diff --git a/parts/networking/PartCable.java b/parts/networking/PartCable.java index 1c63e96c..309ac247 100644 --- a/parts/networking/PartCable.java +++ b/parts/networking/PartCable.java @@ -330,6 +330,43 @@ public class PartCable extends AEBasePart implements IPartCable 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) { switch (of) @@ -370,6 +407,13 @@ public class PartCable extends AEBasePart implements IPartCable rh.setTexture( null ); } + @Override + @SideOnly(Side.CLIENT) + public IIcon getBreakingTexture() + { + return getTexture( getCableColor() ); + } + @SideOnly(Side.CLIENT) public void rendereGlassConection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, ForgeDirection of) { diff --git a/parts/p2p/PartP2PTunnel.java b/parts/p2p/PartP2PTunnel.java index fad47038..bf61d8cc 100644 --- a/parts/p2p/PartP2PTunnel.java +++ b/parts/p2p/PartP2PTunnel.java @@ -331,6 +331,13 @@ public class PartP2PTunnel extends PartBasicState renderLights( x, y, z, rh, renderer ); } + @Override + @SideOnly(Side.CLIENT) + public IIcon getBreakingTexture() + { + return CableBusTextures.BlockP2PTunnel2.getIcon(); + } + protected void QueueTunnelDrain(PowerUnits unit, double f) { double ae_to_tax = unit.convertTo( PowerUnits.AE, f * AEConfig.TunnelPowerLoss );