Multipart work
This commit is contained in:
parent
09b3a98a2a
commit
5dc8d2fc80
8 changed files with 158 additions and 167 deletions
|
@ -39,7 +39,7 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
public static Icon[] uniCableTextures = new Icon[2];
|
||||
public static Icon[] mechPipeTextures = new Icon[2];
|
||||
public static Icon[] pressTubeTextures = new Icon[2];
|
||||
public static Icon liquidEnergyTexture;
|
||||
|
||||
public static Icon sideTexture;
|
||||
public static Map<TransmissionType, Icon[]> typeMap = new HashMap<TransmissionType, Icon[]>();
|
||||
|
||||
|
@ -47,20 +47,25 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
public static Map<String, CCModel> cableContentsModels;
|
||||
|
||||
private static final int stages = 40;
|
||||
private static final double height = 0.45;
|
||||
private static final double offset = 0.015;
|
||||
private HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>> cachedLiquids = new HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>>();
|
||||
|
||||
static
|
||||
{
|
||||
models = CCModel.parseObjModels(new ResourceLocation("mekanism", "models/transmitter.obj"), 7, null);
|
||||
for (CCModel c : models.values()) {
|
||||
|
||||
for(CCModel c : models.values())
|
||||
{
|
||||
c.apply(new Translation(.5, .5, .5));
|
||||
c.computeLighting(LightModel.standardLightModel);
|
||||
c.shrinkUVs(0.0005);
|
||||
}
|
||||
|
||||
cableContentsModels = CCModel.parseObjModels(new ResourceLocation("mekanism", "models/transmitterEnergy.obj"), 7, null);
|
||||
for (CCModel c : cableContentsModels.values()) {
|
||||
|
||||
for(CCModel c : cableContentsModels.values())
|
||||
{
|
||||
c.apply(new Translation(.5, .5, .5));
|
||||
c.computeLighting(LightModel.standardLightModel);
|
||||
c.shrinkUVs(0.0005);
|
||||
|
@ -100,63 +105,65 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
|
||||
public void renderContents(PartUniversalCable cable, Vector3 pos)
|
||||
{
|
||||
if(cable.transmitting == 0)
|
||||
if(cable.getTransmitterNetwork().clientEnergyScale == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
CCRenderState.reset();
|
||||
CCRenderState.useNormals(true);
|
||||
CCRenderState.useModelColours(true);
|
||||
//CCRenderState.setBrightness(255);
|
||||
CCRenderState.startDrawing(7);
|
||||
GL11.glTranslated(pos.x, pos.y, pos.z);
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
renderEnergySide(side, cable);
|
||||
}
|
||||
//MekanismRenderer.glowOn();
|
||||
|
||||
MekanismRenderer.glowOn();
|
||||
CCRenderState.draw();
|
||||
//MekanismRenderer.glowOff();
|
||||
MekanismRenderer.glowOff();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderContents(PartMechanicalPipe pipe, Vector3 pos)
|
||||
{
|
||||
if(pipe.fluidScale > 0 && pipe.transmitting != null)
|
||||
if(pipe.getTransmitterNetwork().fluidScale > 0)
|
||||
{
|
||||
Fluid fluid = pipe.getTransmitterNetwork().refFluid;
|
||||
float scale = pipe.getTransmitterNetwork().fluidScale;
|
||||
|
||||
push();
|
||||
|
||||
if(pipe.transmitting.getFluid() == FluidRegistry.LAVA)
|
||||
{
|
||||
MekanismRenderer.glowOn();
|
||||
}
|
||||
MekanismRenderer.glowOn(fluid.getLuminosity());
|
||||
|
||||
CCRenderState.changeTexture((MekanismRenderer.getBlocksTexture()));
|
||||
GL11.glTranslated(pos.x, pos.y, pos.z);
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(PartTransmitter.connectionMapContainsSide(pipe.getAllCurrentConnections(), side))
|
||||
{
|
||||
DisplayInteger[] displayLists = getListAndRender(side, pipe.transmitting.getFluid());
|
||||
DisplayInteger[] displayLists = getListAndRender(side, fluid);
|
||||
|
||||
if(displayLists != null)
|
||||
{
|
||||
displayLists[Math.max(3, (int)((float)pipe.fluidScale*(stages-1)))].render();
|
||||
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, pipe.transmitting.getFluid());
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, fluid);
|
||||
|
||||
if(displayLists != null)
|
||||
{
|
||||
displayLists[Math.max(3, (int)((float)pipe.fluidScale*(stages-1)))].render();
|
||||
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
|
||||
}
|
||||
|
||||
if(pipe.transmitting.getFluid() == FluidRegistry.LAVA)
|
||||
{
|
||||
MekanismRenderer.glowOff();
|
||||
}
|
||||
MekanismRenderer.glowOff();
|
||||
|
||||
pop();
|
||||
}
|
||||
|
@ -204,79 +211,79 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
{
|
||||
case UNKNOWN:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
toReturn.minX = 0.25 + offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.25 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
toReturn.maxX = 0.75 - offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.75 - offset;
|
||||
break;
|
||||
}
|
||||
case DOWN:
|
||||
{
|
||||
toReturn.minX = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2;
|
||||
toReturn.minY = 0.0;
|
||||
toReturn.minZ = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2;
|
||||
|
||||
toReturn.maxX = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxY = 0.3 + offset;
|
||||
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2;
|
||||
toReturn.maxY = 0.25 + offset;
|
||||
toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2;
|
||||
break;
|
||||
}
|
||||
case UP:
|
||||
{
|
||||
toReturn.minX = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.minZ = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2;
|
||||
toReturn.minY = 0.25 - offset + ((float)i / (float)stages)*height;
|
||||
toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2;
|
||||
|
||||
toReturn.maxX = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2;
|
||||
toReturn.maxY = 1.0;
|
||||
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2;
|
||||
break;
|
||||
}
|
||||
case NORTH:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minX = 0.25 + offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.0;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.3 + offset;
|
||||
toReturn.maxX = 0.75 - offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.25 + offset;
|
||||
break;
|
||||
}
|
||||
case SOUTH:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.7 - offset;
|
||||
toReturn.minX = 0.25 + offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.75 - offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxX = 0.75 - offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 1.0;
|
||||
break;
|
||||
}
|
||||
case WEST:
|
||||
{
|
||||
toReturn.minX = 0.0;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.25 + offset;
|
||||
|
||||
toReturn.maxX = 0.3 + offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
toReturn.maxX = 0.25 + offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.75 - offset;
|
||||
break;
|
||||
}
|
||||
case EAST:
|
||||
{
|
||||
toReturn.minX = 0.7 - offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
toReturn.minX = 0.75 - offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.25 + offset;
|
||||
|
||||
toReturn.maxX = 1.0;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.75 - offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +329,7 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
boolean connected = PartTransmitter.connectionMapContainsSide(cable.getAllCurrentConnections(), side);
|
||||
String name = side.name().toLowerCase();
|
||||
name += connected ? "Out" : "In";
|
||||
renderTransparency(liquidEnergyTexture, cableContentsModels.get(name), new ColourRGBA(1.0, 1.0, 1.0, cable.transmitting));
|
||||
renderTransparency(MekanismRenderer.energyIcon, cableContentsModels.get(name), new ColourRGBA(1.0, 1.0, 1.0, cable.getTransmitterNetwork().clientEnergyScale));
|
||||
}
|
||||
|
||||
public void renderPart(Icon icon, CCModel cc, double x, double y, double z) {
|
||||
|
@ -351,8 +358,6 @@ public class RenderPartTransmitter implements IIconRegister
|
|||
pressTubeTextures[1] = pressTubeTextures[0];
|
||||
mechPipeTextures[0] = register.registerIcon("mekanism:models/MechanicalPipe");
|
||||
mechPipeTextures[1] = register.registerIcon("mekanism:models/MechanicalPipeActive");
|
||||
|
||||
liquidEnergyTexture = register.registerIcon("mekanism:LiquidEnergy");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -366,6 +366,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork, Dou
|
|||
|
||||
if(needsUpdate)
|
||||
{
|
||||
System.out.println("sent update");
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTransferEvent(this, currentPowerScale));
|
||||
needsUpdate = false;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public class MultipartMekanism implements IPartFactory
|
|||
{
|
||||
MultiPartRegistry.registerParts(this, new String[]{"mekanism:universal_cable", "mekanism:mechanical_pipe", "mekanism:pressurized_tube"});
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.ITransmitter");
|
||||
MultipartGenerator.registerPassThroughInterface("mekanism.common.ITileNetwork");
|
||||
MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler");
|
||||
MultipartGenerator.registerPassThroughInterface("ic2.api.energy.tile.IEnergySink");
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork, FluidStack
|
|||
{
|
||||
/** The fake tank used for fluid transfer calculations. */
|
||||
public FluidTank dummyTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
|
||||
/** The scale (0F -> 1F) of this pipe's fluid level. */
|
||||
public float fluidScale;
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
|
@ -40,19 +37,6 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork, FluidStack
|
|||
{
|
||||
return TransmissionType.FLUID;
|
||||
}
|
||||
|
||||
public void clientUpdate(FluidStack fluidStack)
|
||||
{
|
||||
if(fluidStack.isFluidEqual(transmitting))
|
||||
{
|
||||
fluidScale = Math.min(1, fluidScale+((float)fluidStack.amount/50F));
|
||||
}
|
||||
else if(transmitting == null)
|
||||
{
|
||||
transmitting = fluidStack.copy();
|
||||
fluidScale += Math.min(1, ((float)fluidStack.amount/50F));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidAcceptor(TileEntity tile, ForgeDirection side)
|
||||
|
@ -129,17 +113,8 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork, FluidStack
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
if(world().isRemote)
|
||||
if(!world().isRemote)
|
||||
{
|
||||
if(fluidScale > 0)
|
||||
{
|
||||
fluidScale -= .01;
|
||||
}
|
||||
else {
|
||||
transmitting = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(isActive)
|
||||
{
|
||||
IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile());
|
||||
|
@ -162,9 +137,6 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork, FluidStack
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkLoad() {}
|
||||
|
||||
@Override
|
||||
public int getTransmitterNetworkSize()
|
||||
{
|
||||
|
|
|
@ -42,13 +42,6 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork, Gas>
|
|||
return new GasNetwork(networks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkLoad()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransmitterNetworkSize()
|
||||
{
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
package mekanism.common.multipart;
|
||||
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.client.render.RenderPartTransmitter;
|
||||
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;
|
||||
|
@ -15,15 +24,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.client.render.RenderPartTransmitter;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.lighting.LazyLightMatrix;
|
||||
|
@ -43,11 +44,10 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> extends TMultiPart implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, ITransmitter<N, D>
|
||||
public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> extends TMultiPart implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, ITransmitter<N, D>, ITileNetwork
|
||||
{
|
||||
public int delayTicks;
|
||||
public N theNetwork;
|
||||
public D transmitting;
|
||||
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
|
||||
public ForgeDirection testingSide = null;
|
||||
public byte currentAcceptorConnections = 0x00;
|
||||
|
@ -83,14 +83,13 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
@Override
|
||||
public void bind(TileMultipart t)
|
||||
{
|
||||
if (tile() != null && theNetwork != null)
|
||||
if(tile() != null && theNetwork != null)
|
||||
{
|
||||
getTransmitterNetwork().transmitters.remove(tile());
|
||||
super.bind(t);
|
||||
getTransmitterNetwork().transmitters.add((ITransmitter<N, D>) tile());
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
super.bind(t);
|
||||
}
|
||||
}
|
||||
|
@ -98,20 +97,24 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
public static boolean connectionMapContainsSide(byte connections, ForgeDirection side)
|
||||
{
|
||||
byte tester = (byte) (1 << side.ordinal());
|
||||
return ((connections & tester) > 0);
|
||||
return (connections & tester) > 0;
|
||||
}
|
||||
|
||||
public byte getPossibleTransmitterConnections()
|
||||
{
|
||||
byte connections = 0x00;
|
||||
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return connections;
|
||||
}
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (canConnectMutual(side))
|
||||
if(canConnectMutual(side))
|
||||
{
|
||||
TileEntity tileEntity = Object3D.get(tile()).getFromSide(side).getTileEntity(world());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
|
||||
{
|
||||
connections |= 1 << side.ordinal();
|
||||
|
@ -124,12 +127,15 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
public byte getPossibleAcceptorConnections()
|
||||
{
|
||||
byte connections = 0x00;
|
||||
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return connections;
|
||||
}
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (canConnectMutual(side))
|
||||
if(canConnectMutual(side))
|
||||
{
|
||||
TileEntity tileEntity = Object3D.get(tile()).getFromSide(side).getTileEntity(world());
|
||||
|
||||
|
@ -140,41 +146,46 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
return connections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshTransmitterNetwork()
|
||||
{
|
||||
if(!world().isRemote)
|
||||
byte possibleTransmitters = getPossibleTransmitterConnections();
|
||||
byte possibleAcceptors = getPossibleAcceptorConnections();
|
||||
|
||||
if(possibleTransmitters != currentTransmitterConnections)
|
||||
{
|
||||
byte possibleTransmitters = getPossibleTransmitterConnections();
|
||||
byte possibleAcceptors = getPossibleAcceptorConnections();
|
||||
byte or = (byte)(possibleTransmitters | currentTransmitterConnections);
|
||||
|
||||
if(possibleTransmitters != currentTransmitterConnections)
|
||||
if(or != possibleTransmitters)
|
||||
{
|
||||
byte or = (byte)(possibleTransmitters | currentTransmitterConnections);
|
||||
if(or != possibleTransmitters)
|
||||
((DynamicNetwork<?, N, D>)getTransmitterNetwork()).split((ITransmitter<N, D>)tile());
|
||||
setTransmitterNetwork(null);
|
||||
}
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(connectionMapContainsSide(possibleTransmitters, side))
|
||||
{
|
||||
((DynamicNetwork<?, N, D>)getTransmitterNetwork()).split((ITransmitter<N, D>)tile());
|
||||
setTransmitterNetwork(null);
|
||||
}
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(connectionMapContainsSide(possibleTransmitters, side))
|
||||
TileEntity tileEntity = Object3D.get(tile()).getFromSide(side).getTileEntity(world());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
|
||||
{
|
||||
TileEntity tileEntity = Object3D.get(tile()).getFromSide(side).getTileEntity(world());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
|
||||
((DynamicNetwork<?,N, D>)getTransmitterNetwork()).merge(((ITransmitter<N, D>)tileEntity).getTransmitterNetwork());
|
||||
((DynamicNetwork<?,N, D>)getTransmitterNetwork()).merge(((ITransmitter<N, D>)tileEntity).getTransmitterNetwork());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
((DynamicNetwork<?,N, D>)getTransmitterNetwork()).refresh();
|
||||
|
||||
if(!world().isRemote)
|
||||
{
|
||||
currentTransmitterConnections = possibleTransmitters;
|
||||
currentAcceptorConnections = possibleAcceptors;
|
||||
|
||||
((DynamicNetwork<?,N, D>)getTransmitterNetwork()).refresh();
|
||||
|
||||
sendDescUpdate();
|
||||
}
|
||||
|
@ -182,7 +193,7 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
|
||||
public byte getAllCurrentConnections()
|
||||
{
|
||||
return (byte) (currentTransmitterConnections | currentAcceptorConnections);
|
||||
return (byte)(currentTransmitterConnections | currentAcceptorConnections);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -195,13 +206,18 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
public Iterable<IndexedCuboid6> getSubParts()
|
||||
{
|
||||
Set<IndexedCuboid6> subParts = new HashSet<IndexedCuboid6>();
|
||||
|
||||
if(tile() != null)
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
int ord = side.ordinal();
|
||||
byte connections = getAllCurrentConnections();
|
||||
if(connectionMapContainsSide(connections, side) || side == testingSide) subParts.add(sides[ord]);
|
||||
|
||||
if(connectionMapContainsSide(connections, side) || side == testingSide)
|
||||
{
|
||||
subParts.add(sides[ord]);
|
||||
}
|
||||
}
|
||||
}
|
||||
subParts.add(sides[6]);
|
||||
|
@ -313,7 +329,7 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
}
|
||||
}
|
||||
|
||||
if(connectedNets.size() == 0 || world().isRemote)
|
||||
if(connectedNets.size() == 0)
|
||||
{
|
||||
theNetwork = createNetworkFromSingleTransmitter((ITransmitter<N, D>)tile());
|
||||
}
|
||||
|
@ -365,7 +381,10 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
public boolean canConnect(ForgeDirection side)
|
||||
{
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
testingSide = side;
|
||||
boolean unblocked = tile().canReplacePart(this, this);
|
||||
testingSide = null;
|
||||
|
@ -417,6 +436,7 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
tile().dropItems(getDrops());
|
||||
tile().remPart(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -432,11 +452,14 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
@Override
|
||||
public void preRemove()
|
||||
{
|
||||
if(!world().isRemote && tile() instanceof ITransmitter)
|
||||
if(tile() instanceof ITransmitter)
|
||||
{
|
||||
getTransmitterNetwork().split((ITransmitter<N, D>)tile());
|
||||
|
||||
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
|
||||
if(!world().isRemote)
|
||||
{
|
||||
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
|
||||
}
|
||||
}
|
||||
|
||||
super.preRemove();
|
||||
|
@ -464,6 +487,9 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
{
|
||||
return FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkLoad() {}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
|
@ -492,4 +518,13 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N, D>, D> exte
|
|||
super.onPartChanged(part);
|
||||
refreshTransmitterNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream) throws Exception {}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,9 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class PartUniversalCable extends PartTransmitter<EnergyNetwork, Double> implements IEnergySink
|
||||
{
|
||||
public Double setLevel = 0.0;
|
||||
private int ticks;
|
||||
|
||||
public PartUniversalCable()
|
||||
{
|
||||
super();
|
||||
transmitting = 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,21 +104,8 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork, Double> i
|
|||
public void renderDynamic(Vector3 pos, float frame, int pass)
|
||||
{
|
||||
if(pass == 1)
|
||||
RenderPartTransmitter.getInstance().renderContents(this, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if(world().isRemote)
|
||||
{
|
||||
System.out.println("print");
|
||||
if(transmitting != setLevel)
|
||||
{
|
||||
transmitting = (transmitting *4.0 + setLevel)/5.0;
|
||||
if(Math.max(transmitting - setLevel, setLevel - transmitting) < 0.05)
|
||||
transmitting = setLevel;
|
||||
}
|
||||
RenderPartTransmitter.getInstance().renderContents(this, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,16 +3,17 @@ package mekanism.common.network;
|
|||
import java.io.DataOutputStream;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasNetwork;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.common.tileentity.TileEntityMechanicalPipe;
|
||||
import mekanism.common.tileentity.TileEntityPressurizedTube;
|
||||
import mekanism.common.tileentity.TileEntityUniversalCable;
|
||||
import mekanism.common.EnergyNetwork;
|
||||
import mekanism.common.FluidNetwork;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -86,7 +87,7 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
((TileEntityUniversalCable)tileEntity).getTransmitterNetwork().clientEnergyScale = powerLevel;
|
||||
((ITransmitter<EnergyNetwork, Double>)tileEntity).getTransmitterNetwork().clientEnergyScale = powerLevel;
|
||||
}
|
||||
}
|
||||
else if(transmitterType == 2)
|
||||
|
@ -98,8 +99,8 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
((TileEntityPressurizedTube)tileEntity).getTransmitterNetwork().refGas = gasType;
|
||||
((TileEntityPressurizedTube)tileEntity).getTransmitterNetwork().didTransfer = didGasTransfer;
|
||||
((ITransmitter<GasNetwork, Gas>)tileEntity).getTransmitterNetwork().refGas = gasType;
|
||||
((ITransmitter<GasNetwork, Gas>)tileEntity).getTransmitterNetwork().didTransfer = didGasTransfer;
|
||||
}
|
||||
}
|
||||
else if(transmitterType == 3)
|
||||
|
@ -112,8 +113,8 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
((TileEntityMechanicalPipe)tileEntity).getTransmitterNetwork().refFluid = fluidType;
|
||||
((TileEntityMechanicalPipe)tileEntity).getTransmitterNetwork().didTransfer = didFluidTransfer;
|
||||
((ITransmitter<FluidNetwork, FluidStack>)tileEntity).getTransmitterNetwork().refFluid = fluidType;
|
||||
((ITransmitter<FluidNetwork, FluidStack>)tileEntity).getTransmitterNetwork().didTransfer = didFluidTransfer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue