Fixed wire render having alpha of "1"

This commit is contained in:
Calclavia 2013-12-22 12:06:29 +08:00
parent 66792b6696
commit a53a40470c
7 changed files with 64 additions and 66 deletions

View file

@ -2,7 +2,7 @@ package resonantinduction;
import resonantinduction.wire.IAdvancedConductor; import resonantinduction.wire.IAdvancedConductor;
import resonantinduction.wire.IBlockableConnection; import resonantinduction.wire.IBlockableConnection;
import resonantinduction.wire.part.PartFlatWire; import resonantinduction.wire.part.FlatWire;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
import codechicken.multipart.MultiPartRegistry; import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartFactory; import codechicken.multipart.MultiPartRegistry.IPartFactory;
@ -27,7 +27,7 @@ public class MultipartRI implements IPartFactory
{ {
if (name.equals("resonant_induction_flat_wire")) if (name.equals("resonant_induction_flat_wire"))
{ {
return new PartFlatWire(); return new FlatWire();
} }
return null; return null;

View file

@ -34,7 +34,7 @@ public enum EnumWireMaterial
resistance = resist; resistance = resist;
damage = electrocution; damage = electrocution;
maxAmps = max; maxAmps = max;
color = new ColourRGBA(r, g, b, 1); color = new ColourRGBA(r, g, b, 255);
} }
public String getName() public String getName()

View file

@ -13,7 +13,7 @@ import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.TabRI; import resonantinduction.TabRI;
import resonantinduction.Utility; import resonantinduction.Utility;
import resonantinduction.wire.part.PartFlatWire; import resonantinduction.wire.part.FlatWire;
import resonantinduction.wire.render.RenderPartWire; import resonantinduction.wire.render.RenderPartWire;
import universalelectricity.api.energy.UnitDisplay; import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit; import universalelectricity.api.energy.UnitDisplay.Unit;
@ -48,7 +48,7 @@ public class ItemPartWire extends JItemMultiPart
return null; return null;
} }
PartFlatWire wire = (PartFlatWire) MultiPartRegistry.createPart("resonant_induction_flat_wire", false); FlatWire wire = (FlatWire) MultiPartRegistry.createPart("resonant_induction_flat_wire", false);
if (wire != null) if (wire != null)
{ {

View file

@ -14,8 +14,9 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.Utility; import resonantinduction.Utility;
import resonantinduction.wire.EnumWireMaterial; import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.IAdvancedConductor; import resonantinduction.wire.IAdvancedConductor;
import resonantinduction.wire.render.RenderLainWire; import resonantinduction.wire.render.RenderFlatWire;
import resonantinduction.wire.render.RenderPartWire; import resonantinduction.wire.render.RenderPartWire;
import codechicken.lib.colour.Colour;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput; import codechicken.lib.data.MCDataOutput;
import codechicken.lib.lighting.LazyLightMatrix; import codechicken.lib.lighting.LazyLightMatrix;
@ -44,7 +45,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author Modified by Calclavia, MrTJP * @author Modified by Calclavia, MrTJP
* *
*/ */
public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOcclusion public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusion
{ {
public static Cuboid6[][] selectionBounds = new Cuboid6[3][6]; public static Cuboid6[][] selectionBounds = new Cuboid6[3][6];
public static Cuboid6[][] occlusionBounds = new Cuboid6[3][6]; public static Cuboid6[][] occlusionBounds = new Cuboid6[3][6];
@ -82,17 +83,17 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
*/ */
public int connMap; public int connMap;
public PartFlatWire() public FlatWire()
{ {
super(); super();
} }
public PartFlatWire(int typeID) public FlatWire(int typeID)
{ {
this(EnumWireMaterial.values()[typeID]); this(EnumWireMaterial.values()[typeID]);
} }
public PartFlatWire(EnumWireMaterial type) public FlatWire(EnumWireMaterial type)
{ {
super(); super();
material = type; material = type;
@ -314,7 +315,7 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
{ {
int absDir = Rotation.rotateSide(side, r); int absDir = Rotation.rotateSide(side, r);
TMultiPart facePart = tile().partMap(absDir); TMultiPart facePart = tile().partMap(absDir);
if (facePart != null && (!(facePart instanceof PartFlatWire) || !canConnectToType((PartFlatWire) facePart))) if (facePart != null && (!(facePart instanceof FlatWire) || !canConnectToType((FlatWire) facePart)))
return false; return false;
if (tile().partMap(PartMap.edgeBetween(side, absDir)) != null) if (tile().partMap(PartMap.edgeBetween(side, absDir)) != null)
@ -346,11 +347,11 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
TMultiPart tp = t.partMap(absDir ^ 1); TMultiPart tp = t.partMap(absDir ^ 1);
if (tp instanceof IAdvancedConductor) if (tp instanceof IAdvancedConductor)
{ {
boolean b = ((PartFlatWire) tp).connectCorner(this, Rotation.rotationTo(absDir ^ 1, side ^ 1)); boolean b = ((FlatWire) tp).connectCorner(this, Rotation.rotationTo(absDir ^ 1, side ^ 1));
if (b) if (b)
{ {
// let them connect to us // let them connect to us
if (tp instanceof PartFlatWire && !renderThisCorner((PartFlatWire) tp)) if (tp instanceof FlatWire && !renderThisCorner((FlatWire) tp))
return 1; return 1;
return 2; return 2;
@ -381,8 +382,8 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
if (t != null) if (t != null)
{ {
TMultiPart tp = t.partMap(side); TMultiPart tp = t.partMap(side);
if (tp instanceof PartFlatWire) if (tp instanceof FlatWire)
return ((PartFlatWire) tp).connectStraight(this, (r + 2) % 4); return ((FlatWire) tp).connectStraight(this, (r + 2) % 4);
} }
return connectStraightOverride(absDir); return connectStraightOverride(absDir);
@ -401,8 +402,8 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
return false; return false;
TMultiPart tp = tile().partMap(absDir); TMultiPart tp = tile().partMap(absDir);
if (tp instanceof PartFlatWire) if (tp instanceof FlatWire)
return ((PartFlatWire) tp).connectInternal(this, Rotation.rotationTo(absDir, side)); return ((FlatWire) tp).connectInternal(this, Rotation.rotationTo(absDir, side));
return connectInternalOverride(tp, r); return connectInternalOverride(tp, r);
} }
@ -415,18 +416,18 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
public boolean connectCenter() public boolean connectCenter()
{ {
TMultiPart t = tile().partMap(6); TMultiPart t = tile().partMap(6);
if (t instanceof PartFlatWire) if (t instanceof FlatWire)
return ((PartFlatWire) t).connectInternal(this, side); return ((FlatWire) t).connectInternal(this, side);
return false; return false;
} }
public boolean renderThisCorner(IAdvancedConductor part) public boolean renderThisCorner(IAdvancedConductor part)
{ {
if (!(part instanceof PartFlatWire)) if (!(part instanceof FlatWire))
return false; return false;
PartFlatWire wire = (PartFlatWire) part; FlatWire wire = (FlatWire) part;
if (wire.getThickness() == getThickness()) if (wire.getThickness() == getThickness())
return side < wire.side; return side < wire.side;
@ -575,14 +576,14 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
return RenderPartWire.lainWireIcon; return RenderPartWire.lainWireIcon;
} }
public int getColour() public Colour getColour()
{ {
return this.getMaterial().color.pack(); return this.getMaterial().color;
} }
public boolean useStaticRenderer() public boolean useStaticRenderer()
{ {
return true; return false;
} }
@Override @Override
@ -592,7 +593,7 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
if (pass == 0 && useStaticRenderer()) if (pass == 0 && useStaticRenderer())
{ {
CCRenderState.setBrightness(world(), x(), y(), z()); CCRenderState.setBrightness(world(), x(), y(), z());
RenderLainWire.render(this, pos); RenderFlatWire.render(this, pos);
CCRenderState.setColour(-1); CCRenderState.setColour(-1);
} }
} }
@ -607,7 +608,7 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
TextureUtils.bindAtlas(0); TextureUtils.bindAtlas(0);
CCRenderState.useModelColours(true); CCRenderState.useModelColours(true);
CCRenderState.startDrawing(7); CCRenderState.startDrawing(7);
RenderLainWire.render(this, pos); RenderFlatWire.render(this, pos);
CCRenderState.draw(); CCRenderState.draw();
CCRenderState.setColour(-1); CCRenderState.setColour(-1);
GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHTING);
@ -619,7 +620,7 @@ public class PartFlatWire extends PartWireBase implements TFacePart, JNormalOccl
public void drawBreaking(RenderBlocks renderBlocks) public void drawBreaking(RenderBlocks renderBlocks)
{ {
CCRenderState.reset(); CCRenderState.reset();
RenderLainWire.renderBreakingOverlay(renderBlocks.overrideBlockTexture, this); RenderFlatWire.renderBreakingOverlay(renderBlocks.overrideBlockTexture, this);
} }
} }

View file

@ -17,7 +17,6 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
{ {
private IEnergyNetwork network; private IEnergyNetwork network;
public TileEntity[] cachedConnections = null;
public byte currentWireConnections = 0x00; public byte currentWireConnections = 0x00;
public byte currentAcceptorConnections = 0x00; public byte currentAcceptorConnections = 0x00;
@ -64,12 +63,6 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
return ((connections & tester) > 0); return ((connections & tester) > 0);
} }
@Override
public void onMoved()
{
this.refresh();
}
@Override @Override
public void bind(TileMultipart t) public void bind(TileMultipart t)
{ {
@ -164,19 +157,18 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
{ {
if (!world().isRemote) if (!world().isRemote)
{ {
this.cachedConnections = null;
byte possibleWireConnections = getPossibleWireConnections(); byte possibleWireConnections = getPossibleWireConnections();
byte possibleAcceptorConnections = getPossibleAcceptorConnections(); byte possibleAcceptorConnections = getPossibleAcceptorConnections();
if (possibleWireConnections != this.currentWireConnections) if (possibleWireConnections != this.currentWireConnections)
{ {
byte or = (byte) (possibleWireConnections | currentWireConnections); byte or = (byte) (possibleWireConnections | this.currentWireConnections);
if (or != possibleWireConnections) // Connections have been removed // Connections have been removed
if (or != possibleWireConnections)
{ {
getNetwork().split((IConductor) tile()); this.getNetwork().split((IConductor) tile());
setNetwork(null); this.setNetwork(null);
} }
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
@ -187,7 +179,7 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
if (tileEntity instanceof IConductor) if (tileEntity instanceof IConductor)
{ {
getNetwork().merge(((IConductor) tileEntity).getNetwork()); this.getNetwork().merge(((IConductor) tileEntity).getNetwork());
} }
} }
} }
@ -196,7 +188,8 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
} }
this.currentAcceptorConnections = possibleAcceptorConnections; this.currentAcceptorConnections = possibleAcceptorConnections;
//this.sendDescUpdate(); this.getNetwork().reconstruct();
// this.sendDescUpdate();
} }
tile().markRender(); tile().markRender();
@ -209,22 +202,20 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
@Override @Override
public TileEntity[] getConnections() public TileEntity[] getConnections()
{ {
if (this.cachedConnections == null) TileEntity[] cachedConnections = new TileEntity[6];
for (byte i = 0; i < 6; i++)
{ {
this.cachedConnections = new TileEntity[6]; ForgeDirection side = ForgeDirection.getOrientation(i);
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
for (byte i = 0; i < 6; i++) if (isCurrentlyConnected(side))
{ {
ForgeDirection side = ForgeDirection.getOrientation(i); cachedConnections[i] = tileEntity;
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
if (isCurrentlyConnected(side))
{
this.cachedConnections[i] = tileEntity;
}
} }
} }
return this.cachedConnections;
return cachedConnections;
} }
public boolean isCurrentlyConnected(ForgeDirection side) public boolean isCurrentlyConnected(ForgeDirection side)
@ -250,6 +241,12 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
refresh(); refresh();
} }
@Override
public void onMoved()
{
this.refresh();
}
@Override @Override
public void onChunkLoad() public void onChunkLoad()
{ {
@ -263,5 +260,4 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
super.onNeighborChanged(); super.onNeighborChanged();
refresh(); refresh();
} }
} }

View file

@ -170,6 +170,10 @@ public abstract class PartWireBase extends PartConductor implements IBlockableCo
return true; return true;
} }
} }
if (!world().isRemote)
System.out.println(this.getNetwork());
return false; return false;
} }

View file

@ -4,7 +4,7 @@ import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import resonantinduction.wire.part.PartFlatWire; import resonantinduction.wire.part.FlatWire;
import codechicken.lib.lighting.LightModel; import codechicken.lib.lighting.LightModel;
import codechicken.lib.math.MathHelper; import codechicken.lib.math.MathHelper;
import codechicken.lib.render.CCModel; import codechicken.lib.render.CCModel;
@ -24,12 +24,7 @@ import codechicken.lib.vec.Transformation;
import codechicken.lib.vec.Translation; import codechicken.lib.vec.Translation;
import codechicken.lib.vec.Vector3; import codechicken.lib.vec.Vector3;
/** public class RenderFlatWire
*
* @author MrTJP, ChickenBones
*
*/
public class RenderLainWire
{ {
public static class UVT implements IUVTransformation public static class UVT implements IUVTransformation
{ {
@ -58,6 +53,7 @@ public class RenderLainWire
* 2 = side 2 = -Z = NORTH * 2 = side 2 = -Z = NORTH
* 3 = side 5 = +X = EAST * 3 = side 5 = +X = EAST
*/ */
private static class WireModelGenerator private static class WireModelGenerator
{ {
int side; int side;
@ -399,7 +395,7 @@ public class RenderLainWire
return key; return key;
} }
public static int modelKey(PartFlatWire w) public static int modelKey(FlatWire w)
{ {
return modelKey(w.side, w.getThickness(), w.connMap); return modelKey(w.side, w.getThickness(), w.connMap);
} }
@ -412,10 +408,11 @@ public class RenderLainWire
return m; return m;
} }
public static void render(PartFlatWire w, Vector3 pos) public static void render(FlatWire w, Vector3 pos)
{ {
IVertexModifier m = w.getColour() == -1 ? ColourModifier.instance : new ColourMultiplier(w.getColour()); IVertexModifier m = w.getColour().pack() == -1 ? ColourModifier.instance : new ColourMultiplier(w.getColour());
getOrGenerateModel(modelKey(w)).render(new Translation(pos), new IconTransformation(w.getIcon()), m); CCModel model = getOrGenerateModel(modelKey(w));
model.render(new Translation(pos), new IconTransformation(w.getIcon()), m);
} }
public static void renderInv(int thickness, Transformation t, Icon icon) public static void renderInv(int thickness, Transformation t, Icon icon)
@ -427,7 +424,7 @@ public class RenderLainWire
m.render(t, new IconTransformation(icon)); m.render(t, new IconTransformation(icon));
} }
public static void renderBreakingOverlay(Icon icon, PartFlatWire wire) public static void renderBreakingOverlay(Icon icon, FlatWire wire)
{ {
int key = modelKey(wire); int key = modelKey(wire);
int side = (key >> 8) % 6; int side = (key >> 8) % 6;