Properly register items, kill old transmitter code and converter as users will be starting from a clean world

This commit is contained in:
Aidan C. Brady 2014-01-05 02:24:06 -05:00
parent 7b5dd5c339
commit 7c4d0ba714
22 changed files with 247 additions and 3505 deletions

View file

@ -1,15 +1,39 @@
package mekanism.client;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.client.gui.*;
import java.io.File;
import java.util.HashMap;
import mekanism.client.gui.GuiChemicalInfuser;
import mekanism.client.gui.GuiChemicalInjectionChamber;
import mekanism.client.gui.GuiChemicalOxidizer;
import mekanism.client.gui.GuiCombiner;
import mekanism.client.gui.GuiConfiguration;
import mekanism.client.gui.GuiCredits;
import mekanism.client.gui.GuiCrusher;
import mekanism.client.gui.GuiDictionary;
import mekanism.client.gui.GuiDigitalMiner;
import mekanism.client.gui.GuiDynamicTank;
import mekanism.client.gui.GuiElectricChest;
import mekanism.client.gui.GuiElectricPump;
import mekanism.client.gui.GuiElectrolyticSeparator;
import mekanism.client.gui.GuiEnergizedSmelter;
import mekanism.client.gui.GuiEnergyCube;
import mekanism.client.gui.GuiEnrichmentChamber;
import mekanism.client.gui.GuiFactory;
import mekanism.client.gui.GuiGasTank;
import mekanism.client.gui.GuiMetallurgicInfuser;
import mekanism.client.gui.GuiOsmiumCompressor;
import mekanism.client.gui.GuiPasswordEnter;
import mekanism.client.gui.GuiPasswordModify;
import mekanism.client.gui.GuiPortableTeleporter;
import mekanism.client.gui.GuiPurificationChamber;
import mekanism.client.gui.GuiRobitCrafting;
import mekanism.client.gui.GuiRobitInventory;
import mekanism.client.gui.GuiRobitMain;
import mekanism.client.gui.GuiRobitRepair;
import mekanism.client.gui.GuiRobitSmelting;
import mekanism.client.gui.GuiRotaryCondensentrator;
import mekanism.client.gui.GuiTeleporter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.client.render.RenderTickHandler;
@ -20,14 +44,64 @@ import mekanism.client.render.entity.RenderBalloon;
import mekanism.client.render.entity.RenderObsidianTNTPrimed;
import mekanism.client.render.entity.RenderRobit;
import mekanism.client.render.item.ItemRenderingHandler;
import mekanism.client.render.tileentity.*;
import mekanism.client.render.tileentity.RenderBin;
import mekanism.client.render.tileentity.RenderChargepad;
import mekanism.client.render.tileentity.RenderChemicalInfuser;
import mekanism.client.render.tileentity.RenderChemicalOxidizer;
import mekanism.client.render.tileentity.RenderConfigurableMachine;
import mekanism.client.render.tileentity.RenderDigitalMiner;
import mekanism.client.render.tileentity.RenderDynamicTank;
import mekanism.client.render.tileentity.RenderElectricChest;
import mekanism.client.render.tileentity.RenderElectricPump;
import mekanism.client.render.tileentity.RenderElectrolyticSeparator;
import mekanism.client.render.tileentity.RenderEnergyCube;
import mekanism.client.render.tileentity.RenderGasTank;
import mekanism.client.render.tileentity.RenderLogisticalSorter;
import mekanism.client.render.tileentity.RenderMetallurgicInfuser;
import mekanism.client.render.tileentity.RenderObsidianTNT;
import mekanism.client.render.tileentity.RenderRotaryCondensentrator;
import mekanism.client.render.tileentity.RenderTeleporter;
import mekanism.client.sound.Sound;
import mekanism.client.sound.SoundHandler;
import mekanism.common.*;
import mekanism.common.CommonProxy;
import mekanism.common.EntityBalloon;
import mekanism.common.EntityObsidianTNT;
import mekanism.common.EntityRobit;
import mekanism.common.IElectricChest;
import mekanism.common.IInvConfiguration;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.inventory.InventoryElectricChest;
import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.tileentity.*;
import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityChemicalInfuser;
import mekanism.common.tileentity.TileEntityChemicalInjectionChamber;
import mekanism.common.tileentity.TileEntityChemicalOxidizer;
import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityDynamicValve;
import mekanism.common.tileentity.TileEntityElectricChest;
import mekanism.common.tileentity.TileEntityElectricMachine;
import mekanism.common.tileentity.TileEntityElectricPump;
import mekanism.common.tileentity.TileEntityElectrolyticSeparator;
import mekanism.common.tileentity.TileEntityEliteFactory;
import mekanism.common.tileentity.TileEntityEnergizedSmelter;
import mekanism.common.tileentity.TileEntityEnergyCube;
import mekanism.common.tileentity.TileEntityEnrichmentChamber;
import mekanism.common.tileentity.TileEntityFactory;
import mekanism.common.tileentity.TileEntityGasTank;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.tileentity.TileEntityMetallurgicInfuser;
import mekanism.common.tileentity.TileEntityObsidianTNT;
import mekanism.common.tileentity.TileEntityOsmiumCompressor;
import mekanism.common.tileentity.TileEntityPurificationChamber;
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
import mekanism.common.tileentity.TileEntityTeleporter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
@ -36,9 +110,15 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.Configuration;
import java.io.File;
import java.util.HashMap;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Client proxy for the Mekanism mod.
@ -170,16 +250,11 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityObsidianTNT.class, "ObsidianTNT", new RenderObsidianTNT());
ClientRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank", new RenderGasTank());
ClientRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube", new RenderEnergyCube());
ClientRegistry.registerTileEntity(TileEntityPressurizedTube.class, "PressurizedTube", new RenderPressurizedTube());
ClientRegistry.registerTileEntity(TileEntityUniversalCable.class, "UniversalCable", new RenderUniversalCable());
ClientRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump", new RenderElectricPump());
ClientRegistry.registerTileEntity(TileEntityElectricChest.class, "ElectricChest", new RenderElectricChest());
ClientRegistry.registerTileEntity(TileEntityMechanicalPipe.class, "MechanicalPipe", new RenderMechanicalPipe());
ClientRegistry.registerTileEntity(TileEntityDynamicTank.class, "DynamicTank", new RenderDynamicTank());
ClientRegistry.registerTileEntity(TileEntityDynamicValve.class, "DynamicValve", new RenderDynamicTank());
ClientRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad", new RenderChargepad());
ClientRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter", new RenderLogisticalTransporter());
ClientRegistry.registerTileEntity(TileEntityDiversionTransporter.class, "DiversionTransporter", new RenderLogisticalTransporter());
ClientRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter", new RenderLogisticalSorter());
ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin());
ClientRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner", new RenderDigitalMiner());

View file

@ -16,7 +16,6 @@ import mekanism.common.multipart.PartSidedPipe;
import mekanism.common.multipart.PartSidedPipe.ConnectionType;
import mekanism.common.multipart.PartTransmitter;
import mekanism.common.multipart.PartUniversalCable;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@ -153,7 +152,7 @@ public class RenderPartTransmitter implements IIconRegister
GL11.glPushMatrix();
entityItem.setEntityItemStack(stack.itemStack);
float[] pos = TransporterUtils.getStackPosition(transporter, stack, partialTick*TileEntityLogisticalTransporter.SPEED);
float[] pos = TransporterUtils.getStackPosition(transporter, stack, partialTick*PartLogisticalTransporter.SPEED);
GL11.glTranslated(vec.x + pos[0], vec.y + pos[1] - entityItem.yOffset, vec.z + pos[2]);
GL11.glScalef(0.75F, 0.75F, 0.75F);

View file

@ -1,308 +0,0 @@
package mekanism.client.render.tileentity;
import java.util.HashMap;
import mekanism.api.Coord4D;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.model.ModelTransporterBox;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.item.ItemConfigurator;
import mekanism.common.multipart.TransmitterType.Size;
import mekanism.common.tileentity.TileEntityDiversionTransporter;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.util.TransporterUtils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
{
private ModelTransmitter model = new ModelTransmitter(Size.LARGE);
private ModelTransporterBox modelBox = new ModelTransporterBox();
private HashMap<ForgeDirection, HashMap<Integer, DisplayInteger>> cachedOverlays = new HashMap<ForgeDirection, HashMap<Integer, DisplayInteger>>();
private Minecraft mc = Minecraft.getMinecraft();
private EntityItem entityItem = new EntityItem(null);
private RenderItem renderer = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityLogisticalTransporter)tileEntity, x, y, z, partialTick);
}
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
{
int meta = Coord4D.get(tileEntity).getMetadata(tileEntity.worldObj);
if(meta == 3)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
}
else if(meta == 4)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RestrictiveTransporter.png"));
}
else if(meta == 5)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DiversionTransporter.png"));
}
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
GL11.glDisable(GL11.GL_CULL_FACE);
if(tileEntity.color != null)
{
GL11.glColor4f(tileEntity.color.getColor(0), tileEntity.color.getColor(1), tileEntity.color.getColor(2), 1.0F);
}
boolean[] connectable = TransporterUtils.getConnections(tileEntity);
model.renderCenter(connectable);
for(int i = 0; i < 6; i++)
{
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
entityItem.age = 0;
entityItem.hoverStart = 0;
entityItem.setPosition(tileEntity.xCoord + 0.5, tileEntity.yCoord + 0.5, tileEntity.zCoord + 0.5);
entityItem.worldObj = tileEntity.worldObj;
for(TransporterStack stack : tileEntity.transit)
{
if(stack != null)
{
GL11.glPushMatrix();
entityItem.setEntityItemStack(stack.itemStack);
float[] pos = TransporterUtils.getStackPosition(tileEntity, stack, partialTick*TileEntityLogisticalTransporter.SPEED);
GL11.glTranslated(x + pos[0], y + pos[1] - entityItem.yOffset, z + pos[2]);
GL11.glScalef(0.75F, 0.75F, 0.75F);
renderer.doRenderItem(entityItem, 0, 0, 0, 0, 0);
GL11.glPopMatrix();
if(stack.color != null)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TransporterBox.png"));
GL11.glPushMatrix();
MekanismRenderer.glowOn();
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glColor4f(stack.color.getColor(0), stack.color.getColor(1), stack.color.getColor(2), 1.0F);
GL11.glTranslatef((float)(x + pos[0]), (float)(y + pos[1] - entityItem.yOffset - ((stack.itemStack.getItem() instanceof ItemBlock) ? 0.1 : 0)), (float)(z + pos[2]));
modelBox.render(0.0625F);
MekanismRenderer.glowOff();
GL11.glPopMatrix();
}
}
}
if(meta == 5)
{
EntityPlayer player = mc.thePlayer;
World world = mc.thePlayer.worldObj;
ItemStack itemStack = player.getCurrentEquippedItem();
MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F);
if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator)
{
int xPos = MathHelper.floor_double(pos.blockX);
int yPos = MathHelper.floor_double(pos.blockY);
int zPos = MathHelper.floor_double(pos.blockZ);
Coord4D obj = new Coord4D(xPos, yPos, zPos, tileEntity.worldObj.provider.dimensionId);
if(obj.equals(Coord4D.get(tileEntity)))
{
int mode = ((TileEntityDiversionTransporter)tileEntity).modes[pos.sideHit];
ForgeDirection side = ForgeDirection.getOrientation(pos.sideHit);
pushTransporter();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F);
bindTexture(mode == 0 ? MekanismRenderer.getItemsTexture() : MekanismRenderer.getBlocksTexture());
GL11.glTranslatef((float)x, (float)y, (float)z);
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
int display = getOverlayDisplay(world, side, mode).display;
GL11.glCallList(display);
popTransporter();
}
}
}
}
private void popTransporter()
{
GL11.glPopAttrib();
MekanismRenderer.glowOff();
MekanismRenderer.blendOff();
GL11.glPopMatrix();
}
private void pushTransporter()
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
MekanismRenderer.glowOn();
MekanismRenderer.blendOn();
}
private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, int mode)
{
if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(mode))
{
return cachedOverlays.get(side).get(mode);
}
Icon icon = null;
switch(mode)
{
case 0:
icon = Item.gunpowder.getIcon(new ItemStack(Item.gunpowder), 0);
break;
case 1:
icon = Block.torchRedstoneActive.getIcon(0, 0);
break;
case 2:
icon = Block.torchRedstoneIdle.getIcon(0, 0);
break;
}
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.stone;
toReturn.setTexture(icon);
DisplayInteger display = DisplayInteger.createAndStart();
if(cachedOverlays.containsKey(side))
{
cachedOverlays.get(side).put(mode, display);
}
else {
HashMap<Integer, DisplayInteger> map = new HashMap<Integer, DisplayInteger>();
map.put(mode, display);
cachedOverlays.put(side, map);
}
switch(side)
{
case DOWN:
{
toReturn.minY = -0.01;
toReturn.maxY = 0;
toReturn.minX = 0;
toReturn.minZ = 0;
toReturn.maxX = 1;
toReturn.maxZ = 1;
break;
}
case UP:
{
toReturn.minY = 1;
toReturn.maxY = 1.01;
toReturn.minX = 0;
toReturn.minZ = 0;
toReturn.maxX = 1;
toReturn.maxZ = 1;
break;
}
case NORTH:
{
toReturn.minZ = -0.01;
toReturn.maxZ = 0;
toReturn.minX = 0;
toReturn.minY = 0;
toReturn.maxX = 1;
toReturn.maxY = 1;
break;
}
case SOUTH:
{
toReturn.minZ = 1;
toReturn.maxZ = 1.01;
toReturn.minX = 0;
toReturn.minY = 0;
toReturn.maxX = 1;
toReturn.maxY = 1;
break;
}
case WEST:
{
toReturn.minX = -0.01;
toReturn.maxX = 0;
toReturn.minY = 0;
toReturn.minZ = 0;
toReturn.maxY = 1;
toReturn.maxZ = 1;
break;
}
case EAST:
{
toReturn.minX = 1;
toReturn.maxX = 1.01;
toReturn.minY = 0;
toReturn.minZ = 0;
toReturn.maxY = 1;
toReturn.maxZ = 1;
break;
}
default:
{
break;
}
}
MekanismRenderer.renderObject(toReturn);
display.endList();
return display;
}
}

View file

@ -1,258 +0,0 @@
package mekanism.client.render.tileentity;
import java.util.HashMap;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.multipart.TransmitterType.Size;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.util.PipeUtils;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderMechanicalPipe extends TileEntitySpecialRenderer
{
private ModelTransmitter model = new ModelTransmitter(Size.LARGE);
private HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>> cachedLiquids = new HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>>();
private static final int stages = 100;
private static final double height = 0.45;
private static final double offset = 0.015;
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityMechanicalPipe)tileEntity, x, y, z, partialTick);
}
public void renderAModelAt(TileEntityMechanicalPipe tileEntity, double x, double y, double z, float partialTick)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "MechanicalPipe" + (tileEntity.isActive ? "Active" : "") + ".png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
GL11.glDisable(GL11.GL_CULL_FACE);
boolean[] connectable = PipeUtils.getConnections(tileEntity);
model.renderCenter(connectable);
for(int i = 0; i < 6; i++)
{
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
Fluid fluid = tileEntity.getTransmitterNetwork().refFluid;
float scale = tileEntity.getTransmitterNetwork().fluidScale;
if(scale > 0 && fluid != null)
{
push();
MekanismRenderer.glowOn(fluid.getLuminosity());
bindTexture(MekanismRenderer.getBlocksTexture());
GL11.glTranslatef((float)x, (float)y, (float)z);
boolean gas = fluid.isGaseous();
for(int i = 0; i < 6; i++)
{
if(connectable[i])
{
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.getOrientation(i), fluid);
if(displayLists != null)
{
if(!gas)
{
displayLists[Math.max(0, (int)((float)scale*(stages-1)))].render();
}
else {
GL11.glColor4f(1F, 1F, 1F, scale);
displayLists[stages-1].render();
}
}
}
}
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, fluid);
if(displayLists != null)
{
if(!gas)
{
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
}
else {
GL11.glColor4f(1F, 1F, 1F, scale);
displayLists[stages-1].render();
}
}
MekanismRenderer.glowOff();
pop();
}
}
private void pop()
{
GL11.glPopAttrib();
GL11.glPopMatrix();
}
private void push()
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid)
{
if(side == null || fluid == null || fluid.getIcon() == null)
{
return null;
}
if(cachedLiquids.containsKey(side) && cachedLiquids.get(side).containsKey(fluid))
{
return cachedLiquids.get(side).get(fluid);
}
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.waterStill;
toReturn.setTexture(fluid.getIcon());
toReturn.setSideRender(side, false);
toReturn.setSideRender(side.getOpposite(), false);
DisplayInteger[] displays = new DisplayInteger[stages];
if(cachedLiquids.containsKey(side))
{
cachedLiquids.get(side).put(fluid, displays);
}
else {
HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>();
map.put(fluid, displays);
cachedLiquids.put(side, map);
}
MekanismRenderer.colorFluid(fluid);
for(int i = 0; i < stages; i++)
{
displays[i] = DisplayInteger.createAndStart();
switch(side)
{
case UNKNOWN:
{
toReturn.minX = 0.25 + offset;
toReturn.minY = 0.25 + offset;
toReturn.minZ = 0.25 + 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 - (((float)i / (float)stages)*height)/2;
toReturn.minY = 0.0;
toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/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 - (((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 + (((float)i / (float)stages)*height)/2;
toReturn.maxY = 1.0;
toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2;
break;
}
case NORTH:
{
toReturn.minX = 0.25 + offset;
toReturn.minY = 0.25 + offset;
toReturn.minZ = 0.0;
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.25 + offset;
toReturn.minY = 0.25 + offset;
toReturn.minZ = 0.75 - offset;
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.25 + offset;
toReturn.minZ = 0.25 + 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.75 - offset;
toReturn.minY = 0.25 + offset;
toReturn.minZ = 0.25 + offset;
toReturn.maxX = 1.0;
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
toReturn.maxZ = 0.75 - offset;
break;
}
}
MekanismRenderer.renderObject(toReturn);
displays[i].endList();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return displays;
}
}

View file

@ -1,356 +0,0 @@
package mekanism.client.render.tileentity;
import java.util.Arrays;
import java.util.HashMap;
import mekanism.api.Coord4D;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.ITubeConnection;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.BooleanArray;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.multipart.TransmitterType.Size;
import mekanism.common.tileentity.TileEntityGasTank;
import mekanism.common.tileentity.TileEntityPressurizedTube;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderPressurizedTube extends TileEntitySpecialRenderer
{
private ModelTransmitter model = new ModelTransmitter(Size.SMALL);
private boolean[] connectable;
private HashMap<BooleanArray, HashMap<Gas, DisplayInteger>> cachedCenterGasses = new HashMap<BooleanArray, HashMap<Gas, DisplayInteger>>();
private HashMap<TubeRenderData, HashMap<Gas, DisplayInteger>> cachedSideGasses = new HashMap<TubeRenderData, HashMap<Gas, DisplayInteger>>();
private static final double offset = 0.015;
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityPressurizedTube)tileEntity, x, y, z, partialTick);
}
@SuppressWarnings("incomplete-switch")
public void renderAModelAt(TileEntityPressurizedTube tileEntity, double x, double y, double z, float partialTick)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PressurizedTube.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
GL11.glDisable(GL11.GL_CULL_FACE);
connectable = new boolean[] {false, false, false, false, false, false};
ITubeConnection[] connections = GasTransmission.getConnections(tileEntity);
for(ITubeConnection connection : connections)
{
if(connection != null)
{
int side = Arrays.asList(connections).indexOf(connection);
if(connection.canTubeConnect(ForgeDirection.getOrientation(side).getOpposite()))
{
connectable[side] = true;
}
}
}
model.renderCenter(connectable);
for(int i = 0; i < 6; i++)
{
TileEntity sideTile = Coord4D.get(tileEntity).getFromSide(ForgeDirection.getOrientation(i)).getTileEntity(tileEntity.worldObj);
if(sideTile instanceof TileEntityGasTank && i != 0 && i != 1)
{
GL11.glPushMatrix();
switch(ForgeDirection.getOrientation(i))
{
case NORTH:
GL11.glScalef(1, 1, 1.7F);
GL11.glTranslatef(0, 0, -.077F);
break;
case SOUTH:
GL11.glScalef(1, 1, 1.7F);
GL11.glTranslatef(0, 0, .077F);
break;
case WEST:
GL11.glScalef(1.7F, 1, 1);
GL11.glTranslatef(.077F, 0, 0);
break;
case EAST:
GL11.glScalef(1.7F, 1, 1);
GL11.glTranslatef(-.077F, 0, 0);
break;
}
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
GL11.glPopMatrix();
}
else {
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
}
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
Gas gasType = tileEntity.getTransmitterNetwork().refGas;
float scale = tileEntity.getTransmitterNetwork().gasScale;
if(scale > 0 && gasType != null && gasType.getIcon() != null)
{
push();
GL11.glColor4f(1.0F, 1.0F, 1.0F, scale);
bindTexture(MekanismRenderer.getBlocksTexture());
GL11.glTranslatef((float)x, (float)y, (float)z);
for(int i = 0; i < 6; i++)
{
if(connectable[i])
{
Coord4D obj = Coord4D.get(tileEntity).getFromSide(ForgeDirection.getOrientation(i));
Block b = Block.blocksList[obj.getBlockId(tileEntity.worldObj)];
b.setBlockBoundsBasedOnState(tileEntity.worldObj, obj.xCoord, obj.yCoord, obj.zCoord);
getListAndRender(ForgeDirection.getOrientation(i), gasType, b).render();
}
}
getListAndRender(ForgeDirection.UNKNOWN, gasType, null).render();
pop();
}
}
private void pop()
{
GL11.glPopAttrib();
GL11.glPopMatrix();
}
private void push()
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
@SuppressWarnings("incomplete-switch")
private DisplayInteger getListAndRender(ForgeDirection side, Gas type, Block block)
{
if(side == ForgeDirection.UNKNOWN)
{
if(cachedCenterGasses.containsKey(side) && cachedCenterGasses.get(side).containsKey(type))
{
return cachedCenterGasses.get(new BooleanArray(connectable)).get(type);
}
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.waterStill;
toReturn.setTexture(type.getIcon());
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 0.7 - offset;
for(ForgeDirection face : ForgeDirection.VALID_DIRECTIONS)
{
toReturn.setSideRender(face, !connectable[face.ordinal()]);
}
DisplayInteger display = DisplayInteger.createAndStart();
MekanismRenderer.renderObject(toReturn);
DisplayInteger.endList();
if(cachedCenterGasses.containsKey(side))
{
cachedCenterGasses.get(side).put(type, display);
}
else {
HashMap<Gas, DisplayInteger> map = new HashMap<Gas, DisplayInteger>();
map.put(type, display);
cachedCenterGasses.put(new BooleanArray(connectable), map);
}
return display;
}
TubeRenderData data = TubeRenderData.get(side, block);
if(cachedSideGasses.containsKey(data) && cachedSideGasses.get(data).containsKey(type))
{
return cachedSideGasses.get(data).get(type);
}
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.waterStill;
toReturn.setTexture(type.getIcon());
toReturn.setSideRender(side, false);
toReturn.setSideRender(side.getOpposite(), false);
DisplayInteger display = DisplayInteger.createAndStart();
if(cachedSideGasses.containsKey(data))
{
cachedSideGasses.get(data).put(type, display);
}
else {
HashMap<Gas, DisplayInteger> map = new HashMap<Gas, DisplayInteger>();
map.put(type, display);
cachedSideGasses.put(data, map);
}
switch(side)
{
case DOWN:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.0 - (1-block.getBlockBoundsMaxY());
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 0.3 + offset;
toReturn.maxZ = 0.7 - offset;
break;
}
case UP:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.7 - offset;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 1.0 + block.getBlockBoundsMinY();
toReturn.maxZ = 0.7 - offset;
break;
}
case NORTH:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.0 - (1-block.getBlockBoundsMaxZ());
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 0.3 + offset;
break;
}
case SOUTH:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.7 - offset;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 1.0 + block.getBlockBoundsMinZ();
break;
}
case WEST:
{
toReturn.minX = 0.0 - (1-block.getBlockBoundsMaxX());
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 0.3 + offset;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 0.7 - offset;
break;
}
case EAST:
{
toReturn.minX = 0.7 - offset;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 1.0 + block.getBlockBoundsMinX();
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 0.7 - offset;
break;
}
}
MekanismRenderer.renderObject(toReturn);
display.endList();
return display;
}
public static class TubeRenderData
{
public double minX;
public double maxX;
public double minY;
public double maxY;
public double minZ;
public double maxZ;
public ForgeDirection side;
@Override
public int hashCode()
{
int code = 1;
code = 31 * code + new Double(minX).hashCode();
code = 31 * code + new Double(maxX).hashCode();
code = 31 * code + new Double(minY).hashCode();
code = 31 * code + new Double(maxY).hashCode();
code = 31 * code + new Double(minZ).hashCode();
code = 31 * code + new Double(maxZ).hashCode();
code = 31 * code + side.ordinal();
return code;
}
@Override
public boolean equals(Object data)
{
return data instanceof TubeRenderData && ((TubeRenderData)data).minX == minX && ((TubeRenderData)data).maxX == maxX &&
((TubeRenderData)data).minY == minY && ((TubeRenderData)data).maxY == maxY && ((TubeRenderData)data).minZ == minZ &&
((TubeRenderData)data).maxZ == maxZ && ((TubeRenderData)data).side == side;
}
public static TubeRenderData get(ForgeDirection dir, Block b)
{
TubeRenderData data = new TubeRenderData();
data.side = dir;
data.minX = b.getBlockBoundsMinX();
data.maxX = b.getBlockBoundsMaxX();
data.minY = b.getBlockBoundsMinY();
data.maxY = b.getBlockBoundsMaxY();
data.minZ = b.getBlockBoundsMinZ();
data.maxZ = b.getBlockBoundsMaxZ();
return data;
}
}
}

View file

@ -1,267 +0,0 @@
package mekanism.client.render.tileentity;
import java.util.HashMap;
import java.util.Map;
import mekanism.client.MekanismClient;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.BooleanArray;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.multipart.TransmitterType.Size;
import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.util.CableUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderUniversalCable extends TileEntitySpecialRenderer
{
private static ModelTransmitter model = new ModelTransmitter(Size.SMALL);
private static Model3D[] energy = null;
private static Map<ForgeDirection, DisplayInteger> sideDisplayLists = new HashMap<ForgeDirection, DisplayInteger>();
private static Map<BooleanArray, DisplayInteger> centerDisplayLists = new HashMap<BooleanArray, DisplayInteger>();
private static final double offset = 0.015;
private boolean[] connectable;
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityUniversalCable)tileEntity, x, y, z, partialTick);
}
public void renderAModelAt(TileEntityUniversalCable tileEntity, double x, double y, double z, float partialTick)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "UniversalCable.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
GL11.glDisable(GL11.GL_CULL_FACE);
connectable = CableUtils.getConnections(tileEntity);
model.renderCenter(connectable);
for(int i = 0; i < 6; i++)
{
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
if(tileEntity.getTransmitterNetwork().clientEnergyScale <= 0 || !MekanismClient.fancyUniversalCableRender)
{
return;
}
push();
MekanismRenderer.glowOn();
GL11.glColor4f(1F, 1F, 1F, (float)tileEntity.getTransmitterNetwork().clientEnergyScale);
bindTexture(MekanismRenderer.getBlocksTexture());
GL11.glTranslatef((float)x, (float)y, (float)z);
if(energy == null)
{
energy = assignEnergy();
}
for(int i = 0; i < 6; i++)
{
if(connectable[i])
{
renderEnergy(ForgeDirection.getOrientation(i));
}
}
renderEnergy(ForgeDirection.UNKNOWN);
MekanismRenderer.glowOff();
pop();
}
private void renderEnergy(ForgeDirection side)
{
DisplayInteger list = getDisplayList(side);
list.render();
}
private void pop()
{
GL11.glPopAttrib();
GL11.glPopMatrix();
}
private void push()
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
@SuppressWarnings("incomplete-switch")
private static Model3D[] assignEnergy()
{
Model3D[] energyArray = new Model3D[7];
Model3D centerModel = new Model3D();
centerModel.baseBlock = Block.waterStill;
centerModel.setTexture(MekanismRenderer.energyIcon);
centerModel.minX = 0.3 + offset;
centerModel.minY = 0.3 + offset;
centerModel.minZ = 0.3 + offset;
centerModel.maxX = 0.7 - offset;
centerModel.maxY = 0.7 - offset;
centerModel.maxZ = 0.7 - offset;
energyArray[ForgeDirection.UNKNOWN.ordinal()] = centerModel;
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.waterStill;
toReturn.setTexture(MekanismRenderer.energyIcon);
toReturn.setSideRender(side, false);
toReturn.setSideRender(side.getOpposite(), false);
switch(side)
{
case DOWN:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.0;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 0.3 + offset;
toReturn.maxZ = 0.7 - offset;
break;
}
case UP:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.7 - offset;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 1.0;
toReturn.maxZ = 0.7 - offset;
break;
}
case NORTH:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.0;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 0.3 + offset;
break;
}
case SOUTH:
{
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.7 - offset;
toReturn.maxX = 0.7 - offset;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 1.0;
break;
}
case WEST:
{
toReturn.minX = 0.0;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 0.3 + offset;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 0.7 - offset;
break;
}
case EAST:
{
toReturn.minX = 0.7 - offset;
toReturn.minY = 0.3 + offset;
toReturn.minZ = 0.3 + offset;
toReturn.maxX = 1.0;
toReturn.maxY = 0.7 - offset;
toReturn.maxZ = 0.7 - offset;
break;
}
}
energyArray[side.ordinal()] = toReturn;
}
return energyArray;
}
private DisplayInteger getDisplayList(ForgeDirection side)
{
DisplayInteger newDisplayList;
Model3D toRender = energy[side.ordinal()];
if(side == ForgeDirection.UNKNOWN)
{
newDisplayList = centerDisplayLists.get(new BooleanArray(connectable));
if(newDisplayList != null)
{
return newDisplayList;
}
for(ForgeDirection face : ForgeDirection.VALID_DIRECTIONS)
{
toRender.setSideRender(face, !connectable[face.ordinal()]);
}
newDisplayList = DisplayInteger.createAndStart();
MekanismRenderer.renderObject(toRender);
newDisplayList.endList();
centerDisplayLists.put(new BooleanArray(connectable), newDisplayList);
}
else {
newDisplayList = sideDisplayLists.get(side);
if(newDisplayList != null)
{
return newDisplayList;
}
newDisplayList = DisplayInteger.createAndStart();
MekanismRenderer.renderObject(toRender);
newDisplayList.endList();
sideDisplayLists.put(side, newDisplayList);
}
return newDisplayList;
}
}

View file

@ -1,18 +1,68 @@
package mekanism.common;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import mekanism.common.inventory.container.*;
import mekanism.common.tileentity.*;
import java.io.File;
import mekanism.common.inventory.container.ContainerAdvancedElectricMachine;
import mekanism.common.inventory.container.ContainerChemicalInfuser;
import mekanism.common.inventory.container.ContainerChemicalOxidizer;
import mekanism.common.inventory.container.ContainerDictionary;
import mekanism.common.inventory.container.ContainerDigitalMiner;
import mekanism.common.inventory.container.ContainerDynamicTank;
import mekanism.common.inventory.container.ContainerElectricMachine;
import mekanism.common.inventory.container.ContainerElectricPump;
import mekanism.common.inventory.container.ContainerElectrolyticSeparator;
import mekanism.common.inventory.container.ContainerEnergyCube;
import mekanism.common.inventory.container.ContainerFactory;
import mekanism.common.inventory.container.ContainerFilter;
import mekanism.common.inventory.container.ContainerGasTank;
import mekanism.common.inventory.container.ContainerMetallurgicInfuser;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.inventory.container.ContainerRobitCrafting;
import mekanism.common.inventory.container.ContainerRobitInventory;
import mekanism.common.inventory.container.ContainerRobitMain;
import mekanism.common.inventory.container.ContainerRobitRepair;
import mekanism.common.inventory.container.ContainerRobitSmelting;
import mekanism.common.inventory.container.ContainerRotaryCondensentrator;
import mekanism.common.inventory.container.ContainerTeleporter;
import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityChemicalInfuser;
import mekanism.common.tileentity.TileEntityChemicalInjectionChamber;
import mekanism.common.tileentity.TileEntityChemicalOxidizer;
import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityContainerBlock;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityDynamicValve;
import mekanism.common.tileentity.TileEntityElectricChest;
import mekanism.common.tileentity.TileEntityElectricMachine;
import mekanism.common.tileentity.TileEntityElectricPump;
import mekanism.common.tileentity.TileEntityElectrolyticSeparator;
import mekanism.common.tileentity.TileEntityEliteFactory;
import mekanism.common.tileentity.TileEntityEnergizedSmelter;
import mekanism.common.tileentity.TileEntityEnergyCube;
import mekanism.common.tileentity.TileEntityEnrichmentChamber;
import mekanism.common.tileentity.TileEntityFactory;
import mekanism.common.tileentity.TileEntityGasTank;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.tileentity.TileEntityMetallurgicInfuser;
import mekanism.common.tileentity.TileEntityObsidianTNT;
import mekanism.common.tileentity.TileEntityOsmiumCompressor;
import mekanism.common.tileentity.TileEntityPurificationChamber;
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
import mekanism.common.tileentity.TileEntityTeleporter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.Configuration;
import java.io.File;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
/**
* Common proxy for the Mekanism mod.
@ -38,16 +88,11 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser");
GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank");
GameRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube");
GameRegistry.registerTileEntity(TileEntityPressurizedTube.class, "PressurizedTube");
GameRegistry.registerTileEntity(TileEntityUniversalCable.class, "UniversalCable");
GameRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump");
GameRegistry.registerTileEntity(TileEntityElectricChest.class, "ElectricChest");
GameRegistry.registerTileEntity(TileEntityMechanicalPipe.class, "MechanicalPipe");
GameRegistry.registerTileEntity(TileEntityDynamicTank.class, "DynamicTank");
GameRegistry.registerTileEntity(TileEntityDynamicValve.class, "DynamicValve");
GameRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad");
GameRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter");
GameRegistry.registerTileEntity(TileEntityDiversionTransporter.class, "DiversionTransporter");
GameRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter");
GameRegistry.registerTileEntity(TileEntityBin.class, "Bin");
GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner");
@ -112,7 +157,6 @@ public class CommonProxy
Mekanism.energyCubeID = Mekanism.configuration.getBlock("EnergyCube", 3004).getInt();
Mekanism.boundingBlockID = Mekanism.configuration.getBlock("BoundingBlock", 3005).getInt();
Mekanism.gasTankID = Mekanism.configuration.getBlock("GasTank", 3006).getInt();
Mekanism.transmitterID = Mekanism.configuration.getBlock("Transmitter", 3007).getInt();
Mekanism.machineBlock2ID = Mekanism.configuration.getBlock("MachineBlock2", 3008).getInt();
Mekanism.osmiumGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OsmiumGenerationEnabled", true).getBoolean(true);

View file

@ -13,7 +13,6 @@ import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.ITransmitterNetwork;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.util.PipeUtils;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;

View file

@ -1,15 +1,15 @@
package mekanism.common;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import mekanism.api.ChemicalInput;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
@ -31,12 +31,66 @@ import mekanism.common.IFactory.RecipeType;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.Tier.EnergyCubeTier;
import mekanism.common.Tier.FactoryTier;
import mekanism.common.block.*;
import mekanism.common.item.*;
import mekanism.common.block.BlockBasic;
import mekanism.common.block.BlockBounding;
import mekanism.common.block.BlockEnergyCube;
import mekanism.common.block.BlockGasTank;
import mekanism.common.block.BlockMachine;
import mekanism.common.block.BlockObsidianTNT;
import mekanism.common.block.BlockOre;
import mekanism.common.item.ItemAtomicDisassembler;
import mekanism.common.item.ItemBalloon;
import mekanism.common.item.ItemBlockBasic;
import mekanism.common.item.ItemBlockEnergyCube;
import mekanism.common.item.ItemBlockGasTank;
import mekanism.common.item.ItemBlockMachine;
import mekanism.common.item.ItemBlockOre;
import mekanism.common.item.ItemClump;
import mekanism.common.item.ItemConfigurator;
import mekanism.common.item.ItemDictionary;
import mekanism.common.item.ItemDirtyDust;
import mekanism.common.item.ItemDust;
import mekanism.common.item.ItemElectricBow;
import mekanism.common.item.ItemEnergized;
import mekanism.common.item.ItemGasMask;
import mekanism.common.item.ItemIngot;
import mekanism.common.item.ItemJetpack;
import mekanism.common.item.ItemMachineUpgrade;
import mekanism.common.item.ItemMekanism;
import mekanism.common.item.ItemNetworkReader;
import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.item.ItemProxy;
import mekanism.common.item.ItemRobit;
import mekanism.common.item.ItemScubaTank;
import mekanism.common.item.ItemShard;
import mekanism.common.item.ItemWalkieTalkie;
import mekanism.common.multipart.ItemPartTransmitter;
import mekanism.common.multipart.MultipartMekanism;
import mekanism.common.network.*;
import mekanism.common.network.PacketConfigSync;
import mekanism.common.network.PacketConfigurationUpdate;
import mekanism.common.network.PacketConfiguratorState;
import mekanism.common.network.PacketDataRequest;
import mekanism.common.network.PacketDigitUpdate;
import mekanism.common.network.PacketDigitalMinerGui;
import mekanism.common.network.PacketEditFilter;
import mekanism.common.network.PacketElectricBowState;
import mekanism.common.network.PacketElectricChest;
import mekanism.common.network.PacketJetpackData;
import mekanism.common.network.PacketKey;
import mekanism.common.network.PacketLogisticalSorterGui;
import mekanism.common.network.PacketNewFilter;
import mekanism.common.network.PacketPortableTeleport;
import mekanism.common.network.PacketPortalFX;
import mekanism.common.network.PacketRedstoneControl;
import mekanism.common.network.PacketRemoveUpgrade;
import mekanism.common.network.PacketRobit;
import mekanism.common.network.PacketScubaTankData;
import mekanism.common.network.PacketSimpleGui;
import mekanism.common.network.PacketStatusUpdate;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.network.PacketTransmitterUpdate;
import mekanism.common.network.PacketTransmitterUpdate.PacketType;
import mekanism.common.network.PacketWalkieTalkieState;
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
import mekanism.common.tileentity.TileEntityBoundingBlock;
import mekanism.common.tileentity.TileEntityElectricBlock;
@ -60,10 +114,20 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import rebelkeithy.mods.metallurgy.api.IOreInfo;
import rebelkeithy.mods.metallurgy.api.MetallurgyAPI;
import java.io.File;
import java.util.*;
import java.util.logging.Logger;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* Mekanism - the mod that doesn't have a category.
@ -137,7 +201,6 @@ public class Mekanism
public static int energyCubeID;
public static int boundingBlockID;
public static int gasTankID;
public static int transmitterID;
//Items
public static ItemElectricBow ElectricBow;
@ -176,7 +239,6 @@ public class Mekanism
public static Block EnergyCube;
public static Block BoundingBlock;
public static Block GasTank;
public static Block Transmitter;
//Multi-ID Items
public static Item Dust;
@ -496,13 +558,6 @@ public class Mekanism
}
}
}
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 0), new ItemStack(Transmitter, 1, 1));
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 1), new ItemStack(Transmitter, 1, 2));
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 2), new ItemStack(Transmitter, 1, 0));
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 3), new ItemStack(Transmitter, 1, 3));
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 4), new ItemStack(Transmitter, 1, 5));
CraftingManager.getInstance().addShapelessRecipe(new ItemStack(PartTransmitter, 1, 4), new ItemStack(Transmitter, 1, 5));
//Furnace Recipes
FurnaceRecipes.smelting().addSmelting(oreBlockID, 0, new ItemStack(Ingot, 1, 1), 1.0F);
@ -677,11 +732,16 @@ public class Mekanism
ObsidianTNT = new BlockObsidianTNT(obsidianTNTID).setUnlocalizedName("ObsidianTNT").setCreativeTab(tabMekanism);
BoundingBlock = (BlockBounding) new BlockBounding(boundingBlockID).setUnlocalizedName("BoundingBlock");
GasTank = new BlockGasTank(gasTankID).setUnlocalizedName("GasTank");
Transmitter = new BlockTransmitter(transmitterID).setUnlocalizedName("Transmitter");
//Registrations
GameRegistry.registerBlock(BasicBlock, ItemBlockBasic.class, "BasicBlock");
GameRegistry.registerBlock(MachineBlock, ItemBlockMachine.class, "MachineBlock");
GameRegistry.registerBlock(MachineBlock2, ItemBlockMachine.class, "MachineBlock2");
GameRegistry.registerBlock(OreBlock, ItemBlockOre.class, "OreBlock");
GameRegistry.registerBlock(EnergyCube, ItemBlockEnergyCube.class, "EnergyCube");
GameRegistry.registerBlock(ObsidianTNT, "ObsidianTNT");
GameRegistry.registerBlock(BoundingBlock, "BoundingBlock");
GameRegistry.registerBlock(GasTank, ItemBlockBasic.class, "GasTank");
//Add block items into itemsList for blocks with common IDs.
Item.itemsList[basicBlockID] = new ItemBlockBasic(basicBlockID - 256, BasicBlock).setUnlocalizedName("BasicBlock");
@ -690,7 +750,6 @@ public class Mekanism
Item.itemsList[oreBlockID] = new ItemBlockOre(oreBlockID - 256, OreBlock).setUnlocalizedName("OreBlock");
Item.itemsList[energyCubeID] = new ItemBlockEnergyCube(energyCubeID - 256, EnergyCube).setUnlocalizedName("EnergyCube");
Item.itemsList[gasTankID] = new ItemBlockGasTank(gasTankID - 256, GasTank).setUnlocalizedName("GasTank");
Item.itemsList[transmitterID] = new ItemBlockTransmitter(transmitterID - 256, Transmitter).setUnlocalizedName("Transmitter");
}
/**
@ -699,7 +758,7 @@ public class Mekanism
public void registerOreDict()
{
//Add specific items to ore dictionary for recipe usage in other mods. @Calclavia
OreDictionary.registerOre("universalCable", new ItemStack(Transmitter, 8, 1));
OreDictionary.registerOre("universalCable", new ItemStack(PartTransmitter, 8, 0));
OreDictionary.registerOre("battery", EnergyTablet.getUnchargedItem());
OreDictionary.registerOre("dustIron", new ItemStack(Dust, 1, 0));

View file

@ -1,454 +0,0 @@
package mekanism.common.block;
import java.util.Arrays;
import java.util.List;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.client.ClientProxy;
import mekanism.common.Mekanism;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTransmitterUpdate;
import mekanism.common.network.PacketTransmitterUpdate.PacketType;
import mekanism.common.tileentity.TileEntityDiversionTransporter;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.tileentity.TileEntityPressurizedTube;
import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.CableUtils;
import mekanism.common.util.PipeUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Block class for handling multiple transmitter IDs.
* 0: Pressurized Tube
* 1: Universal Cable
* 2: Mechanical Pipe
* 3: Logistical Transporter
* 4: Restrictive Transporter
* 5: Diversion Transporter
* @author AidanBrady
*
*/
public class BlockTransmitter extends Block
{
public static final float SMALL_MIN_BOUND = 0.3125F;
public static final float SMALL_MAX_BOUND = 0.6875F;
public static final float LARGE_MIN_BOUND = 0.25F;
public static final float LARGE_MAX_BOUND = 0.75F;
public BlockTransmitter(int id)
{
super(id, Material.wood);
setHardness(2.0F);
setResistance(5.0F);
}
public float getMinBound(IBlockAccess world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
if(metadata < 2)
{
return SMALL_MIN_BOUND;
}
else {
return LARGE_MIN_BOUND;
}
}
public float getMaxBound(IBlockAccess world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
if(metadata < 2)
{
return SMALL_MAX_BOUND;
}
else {
return LARGE_MAX_BOUND;
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister register) {}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(int i, CreativeTabs creativetabs, List list)
{
list.add(new ItemStack(i, 1, 0));
list.add(new ItemStack(i, 1, 1));
list.add(new ItemStack(i, 1, 2));
list.add(new ItemStack(i, 1, 3));
list.add(new ItemStack(i, 1, 4));
list.add(new ItemStack(i, 1, 5));
}
@Override
public int damageDropped(int i)
{
return i;
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List list, Entity entity)
{
boolean[] connectable = getConnectable(world, x, y, z);
setBlockBounds(getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z));
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
if(connectable[4])
{
setBlockBounds(0.0F, getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z));
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
}
if(connectable[5])
{
setBlockBounds(getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMinBound(world, x, y, z), 1.0F, getMaxBound(world, x, y, z), getMaxBound(world, x, y, z));
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
}
if(connectable[0])
{
setBlockBounds(getMinBound(world, x, y, z), 0.0F, getMinBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z));
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
}
if(connectable[1])
{
setBlockBounds(getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMaxBound(world, x, y, z), 1.0F, getMaxBound(world, x, y, z));
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
}
if(connectable[2])
{
setBlockBounds(getMinBound(world, x, y, z), getMinBound(world, x, y, z), 0.0F, getMaxBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z));
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
}
if(connectable[3])
{
setBlockBounds(getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMinBound(world, x, y, z), getMaxBound(world, x, y, z), getMaxBound(world, x, y, z), 1.0F);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
}
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
boolean[] connectable = getConnectable(world, x, y, z);
if(connectable != null)
{
float minX = getMinBound(world, x, y, z);
float minY = getMinBound(world, x, y, z);
float minZ = getMinBound(world, x, y, z);
float maxX = getMaxBound(world, x, y, z);
float maxY = getMaxBound(world, x, y, z);
float maxZ = getMaxBound(world, x, y, z);
if(connectable[0])
{
minY = 0.0F;
}
if(connectable[1])
{
maxY = 1.0F;
}
if(connectable[2])
{
minZ = 0.0F;
}
if(connectable[3])
{
maxZ = 1.0F;
}
if(connectable[4])
{
minX = 0.0F;
}
if(connectable[5])
{
maxX = 1.0F;
}
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
}
return super.getSelectedBoundingBoxFromPool(world, x, y, z);
}
public boolean[] getConnectable(IBlockAccess world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
boolean[] connectable = null;
if(tileEntity != null)
{
connectable = new boolean[] {false, false, false, false, false, false};
if(world.getBlockMetadata(x, y, z) == 0)
{
ITubeConnection[] connections = GasTransmission.getConnections(tileEntity);
for(ITubeConnection connection : connections)
{
if(connection != null)
{
int side = Arrays.asList(connections).indexOf(connection);
if(connection.canTubeConnect(ForgeDirection.getOrientation(side).getOpposite()))
{
connectable[side] = true;
}
}
}
}
else if(world.getBlockMetadata(x, y, z) == 1)
{
connectable = CableUtils.getConnections(tileEntity);
}
else if(world.getBlockMetadata(x, y, z) == 2)
{
connectable = PipeUtils.getConnections(tileEntity);
}
else if(world.getBlockMetadata(x, y, z) == 3 || world.getBlockMetadata(x, y, z) == 4 || world.getBlockMetadata(x, y, z) == 5)
{
connectable = TransporterUtils.getConnections((TileEntityLogisticalTransporter)tileEntity);
}
}
return connectable;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
float minX = getMinBound(world, x, y, z);
float minY = getMinBound(world, x, y, z);
float minZ = getMinBound(world, x, y, z);
float maxX = getMaxBound(world, x, y, z);
float maxY = getMaxBound(world, x, y, z);
float maxZ = getMaxBound(world, x, y, z);
boolean[] connectable = getConnectable(world, x, y, z);
if(connectable != null)
{
if(connectable[0])
{
minY = 0.0F;
}
if(connectable[1])
{
maxY = 1.0F;
}
if(connectable[2])
{
minZ = 0.0F;
}
if(connectable[3])
{
maxZ = 1.0F;
}
if(connectable[4])
{
minX = 0.0F;
}
if(connectable[5])
{
maxX = 1.0F;
}
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(!world.isRemote)
{
if(tileEntity instanceof IGridTransmitter)
{
((IGridTransmitter)tileEntity).refreshTransmitterNetwork();
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTransmitterUpdate().setParams(PacketType.UPDATE, tileEntity), world.provider.dimensionId);
}
}
}
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(!world.isRemote)
{
if(tileEntity instanceof IGridTransmitter)
{
((IGridTransmitter)tileEntity).refreshTransmitterNetwork();
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTransmitterUpdate().setParams(PacketType.UPDATE, tileEntity), world.provider.dimensionId);
if(tileEntity instanceof TileEntityUniversalCable)
{
((TileEntityUniversalCable)tileEntity).register();
}
}
}
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType()
{
return ClientProxy.TRANSMITTER_RENDER_ID;
}
@Override
public boolean hasTileEntity(int metadata)
{
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata)
{
switch(metadata)
{
case 0:
return new TileEntityPressurizedTube();
case 1:
return new TileEntityUniversalCable();
case 2:
return new TileEntityMechanicalPipe();
case 3:
return new TileEntityLogisticalTransporter();
case 4:
return new TileEntityLogisticalTransporter();
case 5:
return new TileEntityDiversionTransporter();
default:
return null;
}
}
@Override
public void breakBlock(World world, int x, int y, int z, int i1, int i2)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(!world.isRemote && tileEntity instanceof TileEntityLogisticalTransporter)
{
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)world.getBlockTileEntity(x, y, z);
for(TransporterStack stack : transporter.transit)
{
TransporterUtils.drop(transporter, stack);
}
}
super.breakBlock(world, x, y, z, i1, i2);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ)
{
if(world.isRemote)
{
return true;
}
if(entityplayer.getCurrentEquippedItem() != null)
{
Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(tool instanceof IToolWrench && ((IToolWrench)tool).canWrench(entityplayer, x, y, z))
{
if(entityplayer.isSneaking())
{
dismantleBlock(world, x, y, z, false);
}
return true;
}
}
return false;
}
public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock)
{
int meta = world.getBlockMetadata(x, y, z);
ItemStack itemStack = new ItemStack(blockID, 1, meta);
world.setBlockToAir(x, y, z);
if(!returnBlock)
{
float motion = 0.3F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack);
world.spawnEntityInWorld(entityItem);
}
return itemStack;
}
}

View file

@ -1,133 +0,0 @@
package mekanism.common.item;
import java.util.List;
import org.lwjgl.input.Keyboard;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.EnumColor;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
/**
* Item class for handling multiple transmitter IDs.
* 0: Pressurized Tube
* 1: Universal Cable
* 2: Mechanical Pipe
* 3: Logistical Transporter
* 4: Restrictive Transporter
* 5: Diversion Transporter
* @author AidanBrady
*
*/
public class ItemBlockTransmitter extends ItemBlock
{
public Block metaBlock;
public ItemBlockTransmitter(int id, Block block)
{
super(id);
metaBlock = block;
setHasSubtypes(true);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
{
list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for details.");
}
else {
if(itemstack.getItemDamage() == 0)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "O " + EnumColor.GREY + "(Oxygen)");
list.add("- " + EnumColor.PURPLE + "H " + EnumColor.GREY + "(Hydrogen)");
}
else if(itemstack.getItemDamage() == 1)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "RF " + EnumColor.GREY + "(ThermalExpansion)");
list.add("- " + EnumColor.PURPLE + "EU " + EnumColor.GREY + "(IndustrialCraft)");
list.add("- " + EnumColor.PURPLE + "MJ " + EnumColor.GREY + "(BuildCraft)");
list.add("- " + EnumColor.PURPLE + "Joules " + EnumColor.GREY + "(Mekanism, UE)");
}
else if(itemstack.getItemDamage() == 2)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "mB " + EnumColor.GREY + "(FluidRegistry)");
}
else if(itemstack.getItemDamage() == 3)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "Items (universal)");
list.add("- " + EnumColor.PURPLE + "Blocks (universal)");
}
else if(itemstack.getItemDamage() == 4)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "Items (universal)");
list.add("- " + EnumColor.PURPLE + "Blocks (universal)");
list.add("- " + EnumColor.DARK_RED + "Only used if no other paths available");
}
else if(itemstack.getItemDamage() == 5)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "Items (universal)");
list.add("- " + EnumColor.PURPLE + "Blocks (universal)");
list.add("- " + EnumColor.DARK_RED + "Controllable by redstone");
}
}
}
@Override
public int getMetadata(int i)
{
return i;
}
@Override
public Icon getIconFromDamage(int i)
{
return metaBlock.getIcon(2, i);
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
String name = "";
switch(itemstack.getItemDamage())
{
case 0:
name = "PressurizedTube";
break;
case 1:
name = "UniversalCable";
break;
case 2:
name = "MechanicalPipe";
break;
case 3:
name = "LogisticalTransporter";
break;
case 4:
name = "RestrictiveTransporter";
break;
case 5:
name = "DiversionTransporter";
break;
default:
name = "Unknown";
break;
}
return getUnlocalizedName() + "." + name;
}
}

View file

@ -1,15 +1,11 @@
package mekanism.common.multipart;
import mekanism.common.Mekanism;
import net.minecraft.world.World;
import codechicken.lib.vec.BlockCoord;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartConverter;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.TMultiPart;
public class MultipartMekanism implements IPartFactory, IPartConverter
public class MultipartMekanism implements IPartFactory
{
public MultipartMekanism()
{
@ -18,7 +14,6 @@ public class MultipartMekanism implements IPartFactory, IPartConverter
public void init()
{
MultiPartRegistry.registerConverter(this);
MultiPartRegistry.registerParts(this, new String[] {"mekanism:universal_cable", "mekanism:mechanical_pipe", "mekanism:pressurized_tube", "mekanism:logistical_transporter",
"mekanism:restrictive_transporter", "mekanism:diversion_transporter"});
@ -64,22 +59,4 @@ public class MultipartMekanism implements IPartFactory, IPartConverter
return null;
}
@Override
public boolean canConvert(int blockID)
{
return blockID == Mekanism.transmitterID;
}
@Override
public TMultiPart convert(World world, BlockCoord pos)
{
if(world.getBlockId(pos.x, pos.y, pos.z) == Mekanism.transmitterID)
{
int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
return PartTransmitter.getPartType(TransmitterType.fromOldMeta(meta));
}
return null;
}
}

View file

@ -7,12 +7,10 @@ import mekanism.api.EnumColor;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityDiversionTransporter;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;

View file

@ -10,7 +10,6 @@ import mekanism.common.ITileNetwork;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -65,11 +64,6 @@ public class PacketDataRequest implements IMekanismPacket
{
((DynamicNetwork)transmitter.getTransmitterNetwork()).addUpdate(player);
}
if(!(tileEntity instanceof TileEntityMechanicalPipe))
{
return;
}
}
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(worldServer.getBlockTileEntity(x, y, z)), ((ITileNetwork)worldServer.getBlockTileEntity(x, y, z)).getNetworkedData(new ArrayList())));

View file

@ -1,128 +0,0 @@
package mekanism.common.tileentity;
import java.util.ArrayList;
import mekanism.api.EnumColor;
import mekanism.api.Coord4D;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent;
import net.minecraftforge.common.ForgeDirection;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityDiversionTransporter extends TileEntityLogisticalTransporter
{
public int[] modes = {0, 0, 0, 0, 0, 0};
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
modes = nbtTags.getIntArray("modes");
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setIntArray("modes", modes);
}
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
super.handlePacketData(dataStream);
modes[0] = dataStream.readInt();
modes[1] = dataStream.readInt();
modes[2] = dataStream.readInt();
modes[3] = dataStream.readInt();
modes[4] = dataStream.readInt();
modes[5] = dataStream.readInt();
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
data = super.getNetworkedData(data);
data.add(modes[0]);
data.add(modes[1]);
data.add(modes[2]);
data.add(modes[3]);
data.add(modes[4]);
data.add(modes[5]);
return data;
}
@Override
public ArrayList getSyncPacket(TransporterStack stack, boolean kill)
{
ArrayList data = super.getSyncPacket(stack, kill);
data.add(modes[0]);
data.add(modes[1]);
data.add(modes[2]);
data.add(modes[3]);
data.add(modes[4]);
data.add(modes[5]);
return data;
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
int newMode = (modes[side] + 1) % 3;
String description = "ERROR";
modes[side] = newMode;
switch(newMode)
{
case 0:
description = MekanismUtils.localize("control.disabled.desc");
break;
case 1:
description = MekanismUtils.localize("control.high.desc");
break;
case 2:
description = MekanismUtils.localize("control.low.desc");
break;
}
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description));
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 50D);
return true;
}
@Override
public boolean canConnect(ForgeDirection side)
{
if(!super.canConnect(side))
{
return false;
}
int mode = modes[side.ordinal()];
boolean redstone = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
{
return false;
}
return true;
}
}

View file

@ -13,6 +13,7 @@ import mekanism.api.Coord4D;
import mekanism.api.energy.ICableOutputter;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.common.ITileNetwork;
import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils;
@ -335,7 +336,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Override
public double injectEnergyUnits(ForgeDirection direction, double i)
{
if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof IGridTransmitter)
{
return i;
}

View file

@ -1,624 +0,0 @@
package mekanism.common.tileentity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.common.HashList;
import mekanism.common.IConfigurable;
import mekanism.common.ILogisticalTransporter;
import mekanism.common.ITileNetwork;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketDataRequest;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.transporter.TransporterManager;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.transporter.TransporterStack.Path;
import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatMessageComponent;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import cofh.api.transport.IItemConduit;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityLogisticalTransporter extends TileEntity implements ITileNetwork, ILogisticalTransporter, IPipeTile, IConfigurable, IItemConduit
{
public static final int SPEED = 5;
public EnumColor color;
public HashList<TransporterStack> transit = new HashList<TransporterStack>();
public Set<TransporterStack> needsSync = new HashSet<TransporterStack>();
@Override
public void updateEntity()
{
if(worldObj.isRemote)
{
for(TransporterStack stack : transit)
{
if(stack != null)
{
stack.progress = Math.min(100, stack.progress+SPEED);
}
}
}
else {
Set<TransporterStack> remove = new HashSet<TransporterStack>();
for(TransporterStack stack : transit)
{
if(!stack.initiatedPath)
{
if(!recalculate(stack, null))
{
remove.add(stack);
continue;
}
}
stack.progress += SPEED;
if(stack.progress > 100)
{
Coord4D prevSet = null;
if(stack.hasPath())
{
int currentIndex = stack.pathToTarget.indexOf(Coord4D.get(this));
Coord4D next = stack.pathToTarget.get(currentIndex-1);
if(!stack.isFinal(this))
{
if(next != null && stack.canInsertToTransporter(stack.getNext(this).getTileEntity(worldObj), ForgeDirection.getOrientation(stack.getSide(this))))
{
ILogisticalTransporter nextTile = (ILogisticalTransporter)next.getTileEntity(worldObj);
nextTile.entityEntering(stack);
remove.add(stack);
continue;
}
else if(next != null)
{
prevSet = next;
}
}
else {
if(stack.pathType != Path.NONE)
{
if(next != null && next.getTileEntity(worldObj) instanceof IInventory)
{
needsSync.add(stack);
IInventory inventory = (IInventory)next.getTileEntity(worldObj);
if(inventory != null)
{
ItemStack rejected = InventoryUtils.putStackInInventory(inventory, stack.itemStack, stack.getSide(this), stack.pathType == Path.HOME);
if(rejected == null)
{
TransporterManager.remove(stack);
remove.add(stack);
continue;
}
else {
needsSync.add(stack);
stack.itemStack = rejected;
prevSet = next;
}
}
}
}
}
}
if(!recalculate(stack, prevSet))
{
remove.add(stack);
continue;
}
else {
if(prevSet != null)
{
stack.progress = 0;
}
else {
stack.progress = 50;
}
}
}
else if(stack.progress == 50)
{
if(stack.isFinal(this))
{
if(stack.pathType == Path.DEST && !InventoryUtils.canInsert(stack.getDest().getTileEntity(worldObj), stack.color, stack.itemStack, stack.getSide(this), false))
{
if(!recalculate(stack, null))
{
remove.add(stack);
continue;
}
}
else if(stack.pathType == Path.HOME && !InventoryUtils.canInsert(stack.getDest().getTileEntity(worldObj), stack.color, stack.itemStack, stack.getSide(this), true))
{
if(!recalculate(stack, null))
{
remove.add(stack);
continue;
}
}
else if(stack.pathType == Path.NONE)
{
if(!recalculate(stack, null))
{
remove.add(stack);
continue;
}
}
}
else {
TileEntity next = stack.getNext(this).getTileEntity(worldObj);
boolean recalculate = false;
if(!stack.canInsertToTransporter(next, ForgeDirection.getOrientation(stack.getSide(this))))
{
recalculate = true;
}
if(recalculate)
{
if(!recalculate(stack, null))
{
remove.add(stack);
continue;
}
}
}
}
}
for(TransporterStack stack : remove)
{
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getSyncPacket(stack, true)), Coord4D.get(this), 50D);
transit.remove(stack);
MekanismUtils.saveChunk(this);
}
for(TransporterStack stack : needsSync)
{
if(transit.contains(stack))
{
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getSyncPacket(stack, false)), Coord4D.get(this), 50D);
}
}
needsSync.clear();
}
}
private boolean recalculate(TransporterStack stack, Coord4D from)
{
needsSync.add(stack);
if(!TransporterManager.didEmit(stack.itemStack, stack.recalculatePath(this, 0)))
{
if(!stack.calculateIdle(this))
{
TransporterUtils.drop(this, stack);
return false;
}
}
if(from != null)
{
stack.originalLocation = from;
}
return true;
}
@Override
public ItemStack insert(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min)
{
TransporterStack stack = new TransporterStack();
stack.itemStack = itemStack;
stack.originalLocation = original;
stack.homeLocation = original;
stack.color = color;
if(!canReceiveFrom(original.getTileEntity(worldObj), ForgeDirection.getOrientation(stack.getSide(this))) || !stack.canInsertToTransporter(this, ForgeDirection.getOrientation(stack.getSide(this))))
{
return itemStack;
}
ItemStack rejected = stack.recalculatePath(this, min);
if(TransporterManager.didEmit(stack.itemStack, rejected))
{
stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected);
transit.add(stack);
TransporterManager.add(stack);
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getSyncPacket(stack, false)), Coord4D.get(this), 50D);
MekanismUtils.saveChunk(this);
return rejected;
}
return itemStack;
}
@Override
public ItemStack insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color, boolean doEmit, int min)
{
TransporterStack stack = new TransporterStack();
stack.itemStack = itemStack;
stack.originalLocation = Coord4D.get(outputter);
stack.homeLocation = Coord4D.get(outputter);
stack.color = color;
if(!canReceiveFrom(outputter, ForgeDirection.getOrientation(stack.getSide(this))) || !stack.canInsertToTransporter(this, ForgeDirection.getOrientation(stack.getSide(this))))
{
return itemStack;
}
ItemStack rejected = stack.recalculateRRPath(outputter, this, min);
if(TransporterManager.didEmit(stack.itemStack, rejected))
{
stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected);
transit.add(stack);
TransporterManager.add(stack);
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getSyncPacket(stack, false)), Coord4D.get(this), 50D);
MekanismUtils.saveChunk(this);
return rejected;
}
return itemStack;
}
@Override
public void entityEntering(TransporterStack stack)
{
stack.progress = 0;
transit.add(stack);
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getSyncPacket(stack, false)), Coord4D.get(this), 50D);
MekanismUtils.saveChunk(this);
}
@Override
public void validate()
{
super.validate();
if(worldObj.isRemote)
{
PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Coord4D.get(this)));
}
}
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
int type = dataStream.readInt();
if(type == 0)
{
int c = dataStream.readInt();
if(c != -1)
{
color = TransporterUtils.colors.get(c);
}
else {
color = null;
}
transit.clear();
int amount = dataStream.readInt();
for(int i = 0; i < amount; i++)
{
transit.add(TransporterStack.readFromPacket(dataStream));
}
}
else if(type == 1)
{
boolean kill = dataStream.readBoolean();
int index = dataStream.readInt();
if(kill)
{
transit.remove(index);
}
else {
TransporterStack stack = TransporterStack.readFromPacket(dataStream);
if(stack.progress == 0)
{
stack.progress = 5;
}
transit.replace(index, stack);
}
}
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
data.add(0);
if(color != null)
{
data.add(TransporterUtils.colors.indexOf(color));
}
else {
data.add(-1);
}
data.add(transit.size());
for(TransporterStack stack : transit)
{
stack.write(this, data);
}
return data;
}
public ArrayList getSyncPacket(TransporterStack stack, boolean kill)
{
ArrayList data = new ArrayList();
data.add(1);
data.add(kill);
data.add(transit.indexOf(stack));
if(!kill)
{
stack.write(this, data);
}
return data;
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
if(nbtTags.hasKey("color"))
{
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
if(nbtTags.hasKey("stacks"))
{
NBTTagList tagList = nbtTags.getTagList("stacks");
for(int i = 0; i < tagList.tagCount(); i++)
{
TransporterStack stack = TransporterStack.readFromNBT((NBTTagCompound)tagList.tagAt(i));
transit.add(stack);
TransporterManager.add(stack);
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
if(color != null)
{
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
}
NBTTagList stacks = new NBTTagList();
for(TransporterStack stack : transit)
{
NBTTagCompound tagCompound = new NBTTagCompound();
stack.write(tagCompound);
stacks.appendTag(tagCompound);
}
if(stacks.tagCount() != 0)
{
nbtTags.setTag("stacks", stacks);
}
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
return INFINITE_EXTENT_AABB;
}
@Override
public boolean isSolidOnSide(ForgeDirection side)
{
return true;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid)
{
return false;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid)
{
return false;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
return null;
}
@Override
public IPipe getPipe()
{
return null;
}
@Override
public PipeType getPipeType()
{
return PipeType.ITEM;
}
@Override
public int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from)
{
TileEntity tile = Coord4D.get(this).getFromSide(from).getTileEntity(worldObj);
ItemStack rejects = TransporterUtils.insert(tile, this, stack, null, doAdd, 0);
return TransporterManager.getToUse(stack, rejects).stackSize;
}
@Override
public boolean isPipeConnected(ForgeDirection with)
{
return true;
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
TransporterUtils.incrementColor(this);
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 50D);
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + (color != null ? color.getName() : EnumColor.BLACK + MekanismUtils.localize("gui.none"))));
return true;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
@Override
public EnumColor getColor()
{
return color;
}
@Override
public void setColor(EnumColor c)
{
color = c;
}
@Override
public TileEntity getTile()
{
return this;
}
@Override
public boolean canConnect(ForgeDirection side)
{
return true;
}
@Override
public boolean canConnectMutual(ForgeDirection side)
{
return true;
}
@Override
public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side)
{
if(!canConnect(side))
{
return false;
}
return true;
}
@Override
public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side)
{
if(!canConnect(side))
{
return false;
}
return true;
}
@Override
public int getCost()
{
return 1;
}
@Override
public ItemStack insertItem(ForgeDirection from, ItemStack item)
{
return TransporterUtils.insert(Coord4D.get(this).getFromSide(from).getTileEntity(worldObj), this, item, null, true, 0);
}
@Override
public ItemStack insertItem(ForgeDirection from, ItemStack item, boolean simulate)
{
return insertItem(from, item);
}
@Override
public ItemStack sendItems(ItemStack item, ForgeDirection from)
{
return sendItems(item, from);
}
}

View file

@ -1,294 +0,0 @@
package mekanism.common.tileentity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import mekanism.api.Coord4D;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.FluidNetwork;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketDataRequest;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.util.PipeUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork> implements IFluidHandler
{
/** The fake tank used for fluid transfer calculations. */
public FluidTank dummyTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
/** This pipe's active state. */
public boolean isActive = false;
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.FLUID;
}
@Override
public FluidNetwork getTransmitterNetwork(boolean createIfNull)
{
if(theNetwork == null && createIfNull)
{
TileEntity[] adjacentPipes = PipeUtils.getConnectedPipes(this);
HashSet<FluidNetwork> connectedNets = new HashSet<FluidNetwork>();
for(TileEntity pipe : adjacentPipes)
{
if(TransmissionType.checkTransmissionType(pipe, getTransmissionType()) && ((IGridTransmitter<FluidNetwork>)pipe).getTransmitterNetwork(false) != null)
{
connectedNets.add(((IGridTransmitter<FluidNetwork>)pipe).getTransmitterNetwork());
}
}
if(connectedNets.size() == 0)
{
theNetwork = new FluidNetwork(this);
}
else if(connectedNets.size() == 1)
{
theNetwork = connectedNets.iterator().next();
theNetwork.transmitters.add(this);
}
else {
theNetwork = new FluidNetwork(connectedNets);
theNetwork.transmitters.add(this);
}
}
return theNetwork;
}
@Override
public void fixTransmitterNetwork()
{
getTransmitterNetwork().fixMessedUpNetwork(this);
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
getTransmitterNetwork().split(this);
}
@Override
public void invalidate()
{
getTransmitterNetwork().split(this);
if(!worldObj.isRemote)
{
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
}
super.invalidate();
}
@Override
public void removeFromTransmitterNetwork()
{
if(theNetwork != null)
{
theNetwork.removeTransmitter(this);
}
}
@Override
public void refreshTransmitterNetwork()
{
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj);
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()))
{
getTransmitterNetwork().merge(((IGridTransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork());
}
}
getTransmitterNetwork().refresh();
}
@Override
public void updateEntity()
{
if(!worldObj.isRemote)
{
if(isActive)
{
IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(this);
for(IFluidHandler container : connectedAcceptors)
{
ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(connectedAcceptors).indexOf(container));
if(container != null)
{
FluidStack received = container.drain(side.getOpposite(), 100, false);
if(received != null && received.amount != 0)
{
container.drain(side.getOpposite(), getTransmitterNetwork().emit(received, true), true);
}
}
}
}
}
}
@Override
public boolean canUpdate()
{
return true;
}
@Override
public void validate()
{
super.validate();
if(worldObj.isRemote)
{
PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Coord4D.get(this)));
}
}
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
isActive = dataStream.readBoolean();
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
data.add(isActive);
return data;
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
isActive = nbtTags.getBoolean("isActive");
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setBoolean("isActive", isActive);
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
return INFINITE_EXTENT_AABB;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
if(!isActive)
{
return getTransmitterNetwork().emit(resource, doFill);
}
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid)
{
return true;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid)
{
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
return new FluidTankInfo[] {dummyTank.getInfo()};
}
@Override
public int getTransmitterNetworkSize()
{
return getTransmitterNetwork().getSize();
}
@Override
public int getTransmitterNetworkAcceptorSize()
{
return getTransmitterNetwork().getAcceptorSize();
}
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
isActive = !isActive;
refreshTransmitterNetwork();
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())));
return true;
}
@Override
public int getCapacity()
{
return 1000;
}
}

View file

@ -1,151 +0,0 @@
package mekanism.common.tileentity;
import java.util.HashSet;
import mekanism.api.Coord4D;
import mekanism.api.gas.GasNetwork;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasTransmitter;
import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork> implements ITubeConnection, IGasTransmitter
{
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.GAS;
}
@Override
public GasNetwork getTransmitterNetwork(boolean createIfNull)
{
if(theNetwork == null && createIfNull)
{
TileEntity[] adjacentTubes = GasTransmission.getConnectedTubes(this);
HashSet<GasNetwork> connectedNets = new HashSet<GasNetwork>();
for(TileEntity tube : adjacentTubes)
{
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, this) && ((IGridTransmitter<GasNetwork>)tube).getTransmitterNetwork(false) != null)
{
connectedNets.add(((IGridTransmitter<GasNetwork>)tube).getTransmitterNetwork());
}
}
if(connectedNets.size() == 0)
{
theNetwork = new GasNetwork(this);
}
else if(connectedNets.size() == 1)
{
theNetwork = (GasNetwork)connectedNets.iterator().next();
theNetwork.transmitters.add(this);
}
else {
theNetwork = new GasNetwork(connectedNets);
theNetwork.transmitters.add(this);
}
}
return theNetwork;
}
@Override
public void fixTransmitterNetwork()
{
getTransmitterNetwork().fixMessedUpNetwork(this);
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
getTransmitterNetwork().split(this);
}
@Override
public void invalidate()
{
getTransmitterNetwork().split(this);
if(!worldObj.isRemote)
{
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
}
super.invalidate();
}
@Override
public void removeFromTransmitterNetwork()
{
if(theNetwork != null)
{
theNetwork.removeTransmitter(this);
}
}
@Override
public void refreshTransmitterNetwork()
{
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj);
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, this))
{
getTransmitterNetwork().merge(((IGridTransmitter<GasNetwork>)tileEntity).getTransmitterNetwork());
}
}
getTransmitterNetwork().refresh();
}
@Override
public boolean canTubeConnect(ForgeDirection side)
{
return true;
}
@Override
public int getTransmitterNetworkSize()
{
return getTransmitterNetwork().getSize();
}
@Override
public int getTransmitterNetworkAcceptorSize()
{
return getTransmitterNetwork().getAcceptorSize();
}
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
}
@Override
public boolean canTransferGasToTube(TileEntity tile)
{
return tile instanceof IGasTransmitter;
}
@Override
public int getCapacity()
{
return 256;
}
}

View file

@ -1,123 +0,0 @@
package mekanism.common.tileentity;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.IConfigurable;
import mekanism.common.ITileNetwork;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class TileEntityTransmitter<N extends DynamicNetwork<?, N>> extends TileEntity implements IGridTransmitter<N>, ITileNetwork, IConfigurable
{
public N theNetwork;
public int delayTicks = 0;
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
return INFINITE_EXTENT_AABB;
}
@Override
public boolean canUpdate()
{
return FMLCommonHandler.instance().getEffectiveSide().isClient();
}
@Override
public void updateEntity()
{
super.updateEntity();
if(worldObj.isRemote)
{
if(delayTicks == 3)
{
delayTicks++;
refreshTransmitterNetwork();
}
else if(delayTicks < 3)
{
delayTicks++;
}
}
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
if(!worldObj.isRemote)
{
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
}
}
@Override
public void setTransmitterNetwork(N network)
{
if(network != theNetwork)
{
removeFromTransmitterNetwork();
theNetwork = network;
}
}
@Override
public boolean areTransmitterNetworksEqual(TileEntity tileEntity)
{
return tileEntity instanceof IGridTransmitter && getTransmissionType() == ((IGridTransmitter)tileEntity).getTransmissionType();
}
@Override
public N getTransmitterNetwork()
{
return getTransmitterNetwork(true);
}
@Override
public void chunkLoad() {}
@Override
public void handlePacketData(ByteArrayDataInput dataStream) throws Exception {}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
return data;
}
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
return false;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
fixTransmitterNetwork();
return true;
}
@Override
public boolean canConnectToAcceptor(ForgeDirection side, boolean ignoreActive)
{
return true;
}
}

View file

@ -1,301 +0,0 @@
package mekanism.common.tileentity;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import java.util.HashSet;
import mekanism.api.Coord4D;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.EnergyNetwork;
import mekanism.common.Mekanism;
import mekanism.common.util.CableUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import cofh.api.energy.IEnergyHandler;
public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwork> implements IPowerReceptor, IEnergySink, IEnergyHandler
{
/** A fake power handler used to initiate energy transfer calculations. */
public PowerHandler powerHandler;
public double energyScale;
public TileEntityUniversalCable()
{
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
powerHandler.configurePowerPerdition(0, 0);
powerHandler.configure(0, 0, 0, 0);
}
@Override
public TransmissionType getTransmissionType()
{
return TransmissionType.ENERGY;
}
@Override
public EnergyNetwork getTransmitterNetwork(boolean createIfNull)
{
if(theNetwork == null && createIfNull)
{
TileEntity[] adjacentCables = CableUtils.getConnectedCables(this);
HashSet<EnergyNetwork> connectedNets = new HashSet<EnergyNetwork>();
for(TileEntity cable : adjacentCables)
{
if(TransmissionType.checkTransmissionType(cable, TransmissionType.ENERGY) && ((IGridTransmitter<EnergyNetwork>)cable).getTransmitterNetwork(false) != null)
{
connectedNets.add(((IGridTransmitter<EnergyNetwork>)cable).getTransmitterNetwork());
}
}
if(connectedNets.size() == 0)
{
theNetwork = new EnergyNetwork(this);
}
else if(connectedNets.size() == 1)
{
theNetwork = connectedNets.iterator().next();
theNetwork.transmitters.add(this);
}
else {
theNetwork = new EnergyNetwork(connectedNets);
theNetwork.transmitters.add(this);
}
}
return theNetwork;
}
@Override
public void fixTransmitterNetwork()
{
getTransmitterNetwork().fixMessedUpNetwork(this);
}
@Override
public void invalidate()
{
getTransmitterNetwork().split(this);
if(!worldObj.isRemote)
{
TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks();
Mekanism.ic2Registered.remove(Coord4D.get(this));
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
}
super.invalidate();
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
getTransmitterNetwork().split(this);
if(!worldObj.isRemote)
{
Mekanism.ic2Registered.remove(Coord4D.get(this));
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
}
}
@Override
public void removeFromTransmitterNetwork()
{
if(theNetwork != null)
{
theNetwork.removeTransmitter(this);
}
}
@Override
public void refreshTransmitterNetwork()
{
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj);
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
getTransmitterNetwork().merge(((IGridTransmitter<EnergyNetwork>)tileEntity).getTransmitterNetwork());
}
}
getTransmitterNetwork().refresh();
reconfigure();
}
@Override
public void chunkLoad()
{
register();
}
public void register()
{
if(!worldObj.isRemote)
{
if(!Mekanism.ic2Registered.contains(Coord4D.get(this)))
{
Mekanism.ic2Registered.add(Coord4D.get(this));
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
}
getTransmitterNetwork().refresh();
}
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getTransmitterNetwork().getEnergyNeeded() == 0)
{
return null;
}
return powerHandler.getPowerReceiver();
}
@Override
public World getWorld()
{
return worldObj;
}
private void reconfigure()
{
if(MekanismUtils.useBuildCraft())
{
float needed = (float)(getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_BC);
powerHandler.configure(1, needed, 0, needed);
}
}
@Override
public void doWork(PowerHandler workProvider)
{
if(MekanismUtils.useBuildCraft())
{
if(powerHandler.getEnergyStored() > 0)
{
getTransmitterNetwork().emit(powerHandler.getEnergyStored()*Mekanism.FROM_BC);
}
powerHandler.setEnergy(0);
reconfigure();
}
}
public void setCachedEnergy(double scale)
{
energyScale = scale;
}
public float getEnergyScale()
{
return (float)energyScale;
}
@Override
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
return true;
}
@Override
public double demandedEnergyUnits()
{
return getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_IC2;
}
@Override
public double injectEnergyUnits(ForgeDirection direction, double i)
{
return getTransmitterNetwork().emit(i*Mekanism.FROM_IC2)*Mekanism.TO_IC2;
}
@Override
public int getMaxSafeInput()
{
return Integer.MAX_VALUE;
}
@Override
public int getTransmitterNetworkSize()
{
return getTransmitterNetwork().getSize();
}
@Override
public int getTransmitterNetworkAcceptorSize()
{
return getTransmitterNetwork().getAcceptorSize();
}
@Override
public String getTransmitterNetworkNeeded()
{
return getTransmitterNetwork().getNeeded();
}
@Override
public String getTransmitterNetworkFlow()
{
return getTransmitterNetwork().getFlow();
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
if(!simulate)
{
return maxReceive - (int)Math.round(getTransmitterNetwork().emit(maxReceive*Mekanism.FROM_TE)*Mekanism.TO_TE);
}
return 0;
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
{
return 0;
}
@Override
public boolean canInterface(ForgeDirection from)
{
return true;
}
@Override
public int getEnergyStored(ForgeDirection from)
{
return 0;
}
@Override
public int getMaxEnergyStored(ForgeDirection from)
{
return (int)Math.round(getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_TE);
}
@Override
public int getCapacity()
{
return 10000;
}
}

View file

@ -8,7 +8,6 @@ import mekanism.api.EnumColor;
import mekanism.api.ListUtils;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.common.ILogisticalTransporter;
import mekanism.common.tileentity.TileEntityDiversionTransporter;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.transporter.TransporterManager;
import mekanism.common.transporter.TransporterStack;
@ -72,15 +71,9 @@ public final class TransporterUtils
{
int side = Arrays.asList(connectedInventories).indexOf(inventory);
if(tileEntity instanceof TileEntityDiversionTransporter)
if(!tileEntity.canConnect(ForgeDirection.getOrientation(side)))
{
int mode = ((TileEntityDiversionTransporter)tileEntity).modes[side];
boolean redstone = tileEntity.getTile().worldObj.isBlockIndirectlyGettingPowered(tileEntity.getTile().xCoord, tileEntity.getTile().yCoord, tileEntity.getTile().zCoord);
if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
{
continue;
}
continue;
}
ForgeDirection forgeSide = ForgeDirection.getOrientation(side).getOpposite();