Side-specific changeable models. They don't behave differently yet but that should be possible now without too much trouble.

This commit is contained in:
Ben Spiers 2013-12-17 19:39:38 +00:00
parent 4a7b862fb7
commit 8199408e75
7 changed files with 1050 additions and 210 deletions

View file

@ -36,7 +36,7 @@ public class RenderPartTransmitter implements IIconRegister
public static Map<String, CCModel> small_models;
public static Map<String, CCModel> large_models;
public static Map<String, CCModel> cableContentsModels;
public static Map<String, CCModel> contents_models;
private static final int stages = 40;
private static final double height = 0.45;
@ -72,9 +72,9 @@ public class RenderPartTransmitter implements IIconRegister
c.shrinkUVs(0.0005);
}
cableContentsModels = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null);
contents_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null);
for(CCModel c : cableContentsModels.values())
for(CCModel c : contents_models.values())
{
c.apply(new Translation(.5, .5, .5));
c.computeLighting(LightModel.standardLightModel);
@ -348,26 +348,20 @@ public class RenderPartTransmitter implements IIconRegister
public void renderSide(ForgeDirection side, PartSidedPipe transmitter)
{
boolean connected = PartTransmitter.connectionMapContainsSide(transmitter.getAllCurrentConnections(), side);
String name = side.name().toLowerCase();
name += connected ? "Normal" : "None";
Icon renderIcon = connected ? transmitter.getSideIcon() : transmitter.getCenterIcon();
renderPart(renderIcon, getModelForPart(transmitter.getTransmitterSize(), name), transmitter.x(), transmitter.y(), transmitter.z());
Icon renderIcon = transmitter.getIconForSide(side);
renderPart(renderIcon, transmitter.getModelForSide(side, false), transmitter.x(), transmitter.y(), transmitter.z());
}
public void renderEnergySide(ForgeDirection side, PartUniversalCable cable)
{
boolean connected = PartTransmitter.connectionMapContainsSide(cable.getAllCurrentConnections(), side);
String name = side.name().toLowerCase();
name += connected ? "Out" : "In";
renderTransparency(MekanismRenderer.energyIcon, cableContentsModels.get(name), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower));
renderTransparency(MekanismRenderer.energyIcon, cable.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower));
}
public void renderGasSide(ForgeDirection side, PartPressurizedTube tube)
{
boolean connected = PartTransmitter.connectionMapContainsSide(tube.getAllCurrentConnections(), side);
String name = side.name().toLowerCase();
name += connected ? "Out" : "In";
renderTransparency(tube.getTransmitterNetwork().refGas.getIcon(), cableContentsModels.get(name), new ColourRGBA(1.0, 1.0, 1.0, tube.getTransmitterNetwork().gasScale));
renderTransparency(tube.getTransmitterNetwork().refGas.getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.getTransmitterNetwork().gasScale));
}
public void renderPart(Icon icon, CCModel cc, double x, double y, double z)
@ -380,16 +374,6 @@ public class RenderPartTransmitter implements IIconRegister
cc.render(0, cc.verts.length, new Translation(0, 0, 0), new IconTransformation(icon), new ColourMultiplier(colour));
}
public CCModel getModelForPart(Size size, String name)
{
switch(size)
{
case SMALL: return small_models.get(name);
case LARGE: return large_models.get(name);
default: return small_models.get(name);
}
}
@Override
public void registerIcons(IconRegister register)
{

View file

@ -4,7 +4,10 @@ import buildcraft.api.tools.IToolWrench;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.lighting.LazyLightMatrix;
import codechicken.lib.raytracer.ExtendedMOP;
import codechicken.lib.raytracer.IndexedCuboid6;
import codechicken.lib.raytracer.RayTracer;
import codechicken.lib.render.CCModel;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.IHollowConnect;
@ -18,7 +21,6 @@ import mekanism.client.render.RenderPartTransmitter;
import mekanism.common.IConfigurable;
import mekanism.common.ITileNetwork;
import mekanism.common.Mekanism;
import mekanism.common.item.ItemConfigurator;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -29,7 +31,7 @@ import net.minecraftforge.common.ForgeDirection;
import java.util.*;
public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, ITileNetwork, IBlockableConnection
public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, ITileNetwork, IBlockableConnection, IConfigurable
{
public static IndexedCuboid6[] smallSides = new IndexedCuboid6[7];
public static IndexedCuboid6[] largeSides = new IndexedCuboid6[7];
@ -38,8 +40,15 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
public byte currentAcceptorConnections = 0x00;
public byte currentTransmitterConnections = 0x00;
public boolean isActive = false;
public boolean sendDesc;
public boolean sendDesc = false;
public boolean redstonePowered = false;
public ConnectionType[] connectionTypes = {ConnectionType.NORMAL,
ConnectionType.NORMAL,
ConnectionType.NORMAL,
ConnectionType.NORMAL,
ConnectionType.NORMAL,
ConnectionType.NORMAL
};
static
{
@ -94,6 +103,19 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
public abstract Icon getSideIcon();
public Icon getIconForSide(ForgeDirection side)
{
ConnectionType type = getConnectionType(side);
if(type == ConnectionType.NONE)
{
return getCenterIcon();
}
else
{
return getSideIcon();
}
}
public byte getPossibleTransmitterConnections()
{
byte connections = 0x00;
@ -276,6 +298,11 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
currentTransmitterConnections = packet.readByte();
currentAcceptorConnections = packet.readByte();
isActive = packet.readBoolean();
for(int i=0; i<6; i++)
{
connectionTypes[i] = ConnectionType.values()[packet.readInt()];
}
}
@Override
@ -284,6 +311,10 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
packet.writeByte(currentTransmitterConnections);
packet.writeByte(currentAcceptorConnections);
packet.writeBoolean(isActive);
for(int i=0; i<6; i++)
{
packet.writeInt(connectionTypes[i].ordinal());
}
}
@Override
@ -293,12 +324,6 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
{
return false;
}
if(item.getItem() instanceof ItemConfigurator && player.isSneaking())
{
isActive ^= true;
tile().markRender();
return true;
}
if(item.getItem() instanceof IToolWrench && player.isSneaking())
{
if(!world().isRemote)
@ -339,4 +364,59 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
{
return data;
}
public ConnectionType getConnectionType(ForgeDirection side)
{
if(!connectionMapContainsSide(getAllCurrentConnections(), side))
return ConnectionType.NONE;
if(connectionMapContainsSide(currentTransmitterConnections, side))
return ConnectionType.NORMAL;
return connectionTypes[side.ordinal()];
}
public CCModel getModelForSide(ForgeDirection side, boolean internal)
{
String name = side.name().toLowerCase();
String type = getConnectionType(side).name().toUpperCase();
name += type;
if(internal)
{
return RenderPartTransmitter.contents_models.get(name);
}
else
{
return RenderPartTransmitter.small_models.get(name);
}
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
ExtendedMOP hit = (ExtendedMOP) RayTracer.retraceBlock(world(), player, x(), y(), z());
if(hit == null)
return false;
if(hit.subHit < 6)
{
connectionTypes[hit.subHit] = ConnectionType.nextType[connectionTypes[hit.subHit].ordinal()];
sendDesc = true;
return true;
}
return false;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
public static enum ConnectionType
{
NONE,
NORMAL,
PUSH,
PULL;
public static ConnectionType[] nextType = {NORMAL, PUSH, PULL, NONE};
}
}

View file

@ -284,12 +284,6 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends Pa
super.onPartChanged(part);
refreshTransmitterNetwork();
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
return false;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
@ -297,7 +291,7 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends Pa
fixTransmitterNetwork();
return true;
}
@Override
public void chunkLoad() {}
}

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
# Blender v2.66 (sub 1) OBJ File: 'transmitter_small.blend'
# www.blender.org
g southPull
g southPULL
v -0.187500 -0.187500 0.187500
v -0.187500 0.187500 0.187500
v 0.187500 -0.187500 0.187500
@ -68,7 +68,7 @@ f 19/3/6 21/13/6 24/14/6 20/2/6
f 7/14/6 18/2/6 20/3/6 24/13/6
f 9/15/6 17/8/6 18/7/6 7/16/6
f 21/15/6 19/8/6 17/7/6 9/16/6
g southPush
g southPUSH
v -0.187500 -0.187500 0.187500
v -0.187500 0.187500 0.187500
v 0.187500 -0.187500 0.187500
@ -138,7 +138,7 @@ f 46/25/3 41/39/3 42/40/3 48/26/3
f 47/25/4 44/39/4 43/40/4 45/26/4
f 44/40/1 47/26/1 48/25/1 42/39/1
f 27/17/2 29/18/2 30/19/2 25/20/2
g downPush
g downPUSH
v -0.187500 -0.187500 -0.187500
v -0.187500 -0.187500 0.187500
v 0.187500 -0.187500 -0.187500
@ -210,7 +210,7 @@ f 70/49/3 65/63/3 66/64/3 72/50/3
f 71/49/8 68/63/8 67/64/8 69/50/8
f 68/64/5 71/50/5 72/49/5 66/63/5
f 51/41/6 53/42/6 54/43/6 49/44/6
g downPull
g downPULL
v -0.187500 -0.187500 -0.187500
v -0.187500 -0.187500 0.187500
v 0.187500 -0.187500 -0.187500
@ -273,7 +273,7 @@ f 91/67/1 93/77/1 96/78/1 92/66/1
f 79/78/1 90/66/1 92/67/1 96/77/1
f 81/79/1 89/72/1 90/71/1 79/80/1
f 93/79/1 91/72/1 89/71/1 81/80/1
g eastPull
g eastPULL
v 0.187500 -0.187500 -0.187500
v 0.187500 -0.187500 0.187500
v 0.187500 0.187500 -0.187500
@ -335,7 +335,7 @@ f 115/83/3 117/93/3 120/94/3 116/82/3
f 103/94/3 114/82/3 116/83/3 120/93/3
f 105/95/3 113/88/3 114/87/3 103/96/3
f 117/95/3 115/88/3 113/87/3 105/96/3
g eastPush
g eastPUSH
v 0.187500 -0.187500 -0.187500
v 0.187500 -0.187500 0.187500
v 0.187500 0.187500 -0.187500
@ -405,7 +405,7 @@ f 142/105/2 137/119/2 138/120/2 144/106/2
f 143/105/1 140/119/1 139/120/1 141/106/1
f 140/120/9 143/106/9 144/105/9 138/119/9
f 123/97/6 125/98/6 126/99/6 121/100/6
g westPush
g westPUSH
v -0.187500 -0.187500 -0.187500
v -0.187500 0.187500 -0.187500
v -0.187500 -0.187500 0.187500
@ -475,7 +475,7 @@ f 166/129/6 161/143/6 162/144/6 168/130/6
f 167/129/5 164/143/5 163/144/5 165/130/5
f 164/144/1 167/130/1 168/129/1 162/143/1
f 147/121/2 149/122/2 150/123/2 145/124/2
g westPull
g westPULL
v -0.187500 -0.187500 -0.187500
v -0.187500 0.187500 -0.187500
v -0.187500 -0.187500 0.187500
@ -537,7 +537,7 @@ f 187/147/4 189/157/4 192/158/4 188/146/4
f 175/158/4 186/146/4 188/147/4 192/157/4
f 177/159/4 185/152/4 186/151/4 175/160/4
f 189/159/4 187/152/4 185/151/4 177/160/4
g northPull
g northPULL
v 0.187500 -0.187500 -0.187500
v 0.187500 0.187500 -0.187500
v -0.187500 -0.187500 -0.187500
@ -599,7 +599,7 @@ f 211/163/5 213/173/5 216/174/5 212/162/5
f 199/174/5 210/162/5 212/163/5 216/173/5
f 201/175/5 209/168/5 210/167/5 199/176/5
f 213/175/5 211/168/5 209/167/5 201/176/5
g northPush
g northPUSH
v 0.187500 -0.187500 -0.187500
v 0.187500 0.187500 -0.187500
v -0.187500 -0.187500 -0.187500
@ -669,7 +669,7 @@ f 238/185/4 233/199/4 234/200/4 240/186/4
f 239/185/3 236/199/3 235/200/3 237/186/3
f 236/200/1 239/186/1 240/185/1 234/199/1
f 219/177/2 221/178/2 222/179/2 217/180/2
g downNormal
g downNORMAL
v -0.187500 -0.187500 -0.187500
v -0.187500 -0.500000 -0.187500
v -0.187500 -0.500000 0.187500
@ -687,7 +687,7 @@ f 245/201/6 246/202/6 242/203/6 241/204/6
f 247/203/5 248/204/5 244/201/5 243/202/5
f 241/201/3 242/202/3 243/203/3 244/204/3
f 248/201/4 247/202/4 246/203/4 245/204/4
g upPush
g upPUSH
v 0.187500 0.187500 -0.187500
v 0.187500 0.187500 0.187500
v -0.187500 0.187500 -0.187500
@ -757,7 +757,7 @@ f 270/213/4 265/227/4 266/228/4 272/214/4
f 271/213/3 268/227/3 267/228/3 269/214/3
f 268/228/5 271/214/5 272/213/5 266/227/5
f 251/205/6 253/206/6 254/207/6 249/208/6
g southNormal
g southNORMAL
v 0.187500 -0.187500 0.187500
v 0.187500 -0.187500 0.500000
v -0.187500 -0.187500 0.500000
@ -775,7 +775,7 @@ f 277/229/8 278/230/8 274/231/8 273/232/8
f 279/231/7 280/232/7 276/229/7 275/230/7
f 273/229/2 274/230/2 275/231/2 276/232/2
f 280/229/1 279/230/1 278/231/1 277/232/1
g westNormal
g westNORMAL
v -0.187500 -0.187500 0.187500
v -0.500000 -0.187500 0.187500
v -0.500000 -0.187500 -0.187500
@ -793,7 +793,7 @@ f 285/233/5 286/234/5 282/235/5 281/236/5
f 287/235/6 288/236/6 284/233/6 283/234/6
f 281/233/2 282/234/2 283/235/2 284/236/2
f 288/233/1 287/234/1 286/235/1 285/236/1
g northNormal
g northNORMAL
v -0.187500 -0.187500 -0.187500
v -0.187500 -0.187500 -0.500000
v 0.187500 -0.187500 -0.500000
@ -811,7 +811,7 @@ f 293/237/3 294/238/3 290/239/3 289/240/3
f 295/239/4 296/240/4 292/237/4 291/238/4
f 289/237/2 290/238/2 291/239/2 292/240/2
f 296/237/1 295/238/1 294/239/1 293/240/1
g eastNormal
g eastNORMAL
v 0.187500 -0.187500 -0.187500
v 0.500000 -0.187500 -0.187500
v 0.500000 -0.187500 0.187500
@ -829,7 +829,7 @@ f 301/241/6 302/242/6 298/243/6 297/244/6
f 303/243/5 304/244/5 300/241/5 299/242/5
f 297/241/2 298/242/2 299/243/2 300/244/2
f 304/241/1 303/242/1 302/243/1 301/244/1
g southNone
g southNONE
v 0.187500 -0.187500 0.187500
v -0.187500 -0.187500 0.187500
v 0.187500 0.187500 0.187500
@ -840,7 +840,7 @@ vt 0.000000 1.000000
vt 0.000000 0.000000
s off
f 305/245/5 307/246/5 308/247/5 306/248/5
g westNone
g westNONE
v -0.187500 -0.187500 0.187500
v -0.187500 -0.187500 -0.187500
v -0.187500 0.187500 0.187500
@ -851,7 +851,7 @@ vt 0.000000 1.000000
vt 0.000000 0.000000
s off
f 309/249/3 311/250/3 312/251/3 310/252/3
g northNone
g northNONE
v -0.187500 -0.187500 -0.187500
v 0.187500 -0.187500 -0.187500
v -0.187500 0.187500 -0.187500
@ -862,7 +862,7 @@ vt 0.000000 1.000000
vt 0.000000 0.000000
s off
f 313/253/6 315/254/6 316/255/6 314/256/6
g eastNone
g eastNONE
v 0.187500 0.187500 -0.187500
v 0.187500 0.187500 0.187500
v 0.187500 -0.187500 -0.187500
@ -873,7 +873,7 @@ vt 0.000000 1.000000
vt 0.000000 0.000000
s off
f 319/257/4 317/258/4 318/259/4 320/260/4
g upNone
g upNONE
v 0.187500 0.187500 0.187500
v -0.187500 0.187500 0.187500
v -0.187500 0.187500 -0.187500
@ -884,7 +884,7 @@ vt 0.000000 1.000000
vt 0.000000 0.000000
s off
f 321/261/1 324/262/1 323/263/1 322/264/1
g downNone
g downNONE
v -0.187500 -0.187500 0.187500
v -0.187500 -0.187500 -0.187500
v 0.187500 -0.187500 -0.187500
@ -895,7 +895,7 @@ vt 0.000000 1.000000
vt 0.000000 0.000000
s off
f 325/265/2 326/266/2 327/267/2 328/268/2
g upPull
g upPULL
v 0.187500 0.187500 -0.187500
v 0.187500 0.187500 0.187500
v -0.187500 0.187500 -0.187500
@ -957,7 +957,7 @@ f 347/271/2 349/281/2 352/282/2 348/270/2
f 335/282/2 346/270/2 348/271/2 352/281/2
f 337/283/2 345/276/2 346/275/2 335/284/2
f 349/283/2 347/276/2 345/275/2 337/284/2
g upNormal
g upNORMAL
v 0.187500 0.187500 -0.187500
v 0.187500 0.500000 -0.187500
v 0.187500 0.500000 0.187500