*Fixed references to Smelting Factory.

*Fixed loop bug in gas transmission.
*Fixed hardness on bounding block.
*Fixed active block updates.
*Re-designed Factory code to be more efficient packet-wise and and
operation-wise.
This commit is contained in:
Aidan Brady 2013-03-20 13:58:36 -04:00
parent d6cdfb00cf
commit 9f7096250f
27 changed files with 71 additions and 57 deletions

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 915 B

After

Width:  |  Height:  |  Size: 915 B

View file

@ -15,9 +15,12 @@ public class GasTransferProtocol
/** List of IGasAcceptors that can take in the type of gas requested. */
public ArrayList<IGasAcceptor> availableAcceptors = new ArrayList<IGasAcceptor>();
/** Pointer of this calculation */
/** Pointer tube of this calculation */
public TileEntity pointer;
/** Original outputter Tile Entity. */
public TileEntity original;
/** Type of gas to distribute */
public EnumGas transferType;
@ -30,15 +33,17 @@ public class GasTransferProtocol
* @param type - type of gas to distribute
* @param amount - amount of gas to distribute
*/
public GasTransferProtocol(TileEntity head, EnumGas type, int amount)
public GasTransferProtocol(TileEntity head, TileEntity orig, EnumGas type, int amount)
{
pointer = head;
transferType = type;
gasToSend = amount;
original = orig;
}
/**
* Recursive loop that iterates through connected tubes and adds connected acceptors to an ArrayList.
* Recursive loop that iterates through connected tubes and adds connected acceptors to an ArrayList. Note that it will NOT add
* the original outputting tile into the availableAcceptors list, to prevent loops.
* @param tile - pointer tile entity
*/
public void loopThrough(TileEntity tile)
@ -49,7 +54,7 @@ public class GasTransferProtocol
{
if(acceptor != null)
{
if(acceptor.canReceiveGas(ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor)).getOpposite(), transferType))
if(acceptor != original && acceptor.canReceiveGas(ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor)).getOpposite(), transferType))
{
availableAcceptors.add(acceptor);
}

View file

@ -96,7 +96,7 @@ public class GasTransmission
if(pointer != null)
{
GasTransferProtocol calculation = new GasTransferProtocol(pointer, type, amount);
GasTransferProtocol calculation = new GasTransferProtocol(pointer, sender, type, amount);
return calculation.calculate();
}

View file

@ -48,15 +48,15 @@ public final class Tier
}
/**
* The tiers used by the Smelting Factory and their corresponding values.
* The tiers used by the Factory and their corresponding values.
* @author aidancbrady
*
*/
public static enum FactoryTier
{
BASIC("Basic", 3, "GuiBasicSmeltingFactory.png"),
ADVANCED("Advanced", 5, "GuiAdvancedSmeltingFactory.png"),
ELITE("Elite", 7, "GuiEliteSmeltingFactory.png");
BASIC("Basic", 3, "GuiBasicFactory.png"),
ADVANCED("Advanced", 5, "GuiAdvancedFactory.png"),
ELITE("Elite", 7, "GuiEliteFactory.png");
public int processes;
public String guiTexturePath;

View file

@ -2,7 +2,7 @@ package mekanism.client;
import mekanism.api.IFactory.RecipeType;
import mekanism.api.Tier.FactoryTier;
import mekanism.common.ContainerSmeltingFactory;
import mekanism.common.ContainerFactory;
import mekanism.common.TileEntityFactory;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
@ -15,7 +15,7 @@ public class GuiFactory extends GuiContainer
public GuiFactory(InventoryPlayer inventory, TileEntityFactory tentity)
{
super(new ContainerSmeltingFactory(inventory, tentity));
super(new ContainerFactory(inventory, tentity));
xSize+=26;
tileEntity = tentity;
}
@ -33,7 +33,7 @@ public class GuiFactory extends GuiContainer
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
mc.renderEngine.func_98187_b("/mods/mekanism/gui/smelting/" + tileEntity.tier.guiTexturePath);
mc.renderEngine.func_98187_b("/mods/mekanism/gui/factory/" + tileEntity.tier.guiTexturePath);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;

View file

@ -16,7 +16,8 @@ public class BlockBounding extends Block
public BlockBounding(int id)
{
super(id, Material.iron);
setHardness(0.8F);
setHardness(3.5F);
setResistance(8F);
}
@Override

View file

@ -146,7 +146,7 @@ public class CommonProxy
case 10:
return new ContainerGasTank(player.inventory, (TileEntityGasTank)tileEntity);
case 11:
return new ContainerSmeltingFactory(player.inventory, (TileEntityFactory)tileEntity);
return new ContainerFactory(player.inventory, (TileEntityFactory)tileEntity);
case 12:
return new ContainerMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity);
case 13:

View file

@ -14,11 +14,11 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
public class ContainerSmeltingFactory extends Container
public class ContainerFactory extends Container
{
private TileEntityFactory tileEntity;
public ContainerSmeltingFactory(InventoryPlayer inventory, TileEntityFactory tentity)
public ContainerFactory(InventoryPlayer inventory, TileEntityFactory tentity)
{
tileEntity = tentity;

View file

@ -248,6 +248,12 @@ public final class MekanismUtils
return itemstack;
}
/**
* Retrieves a Factory with a defined tier and recipe type.
* @param tier - tier to add to the Factory
* @param type - recipe type to add to the Factory
* @return factory with defined tier and recipe type
*/
public static ItemStack getFactory(FactoryTier tier, RecipeType type)
{
ItemStack itemstack = new ItemStack(Mekanism.MachineBlock, 1, 5+tier.ordinal());
@ -439,4 +445,17 @@ public final class MekanismUtils
world.setBlockAndMetadataWithNotify(x, y, z, Mekanism.BoundingBlock.blockID, 0, 2);
((TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z)).setMainLocation(origX, origY, origZ);
}
/**
* Updates a block's light value and marks it for a render update.
* @param world - world the block is in
* @param x - x coord
* @param y - y coord
* @param z - z coord
*/
public static void updateBlock(World world, int x, int y, int z)
{
world.markBlockForRenderUpdate(x, y, z);
world.updateAllLightTypes(x, y, z);
}
}

View file

@ -53,8 +53,6 @@ public abstract class TileEntityBasicBlock extends TileEntityDisableable impleme
public void handlePacketData(ByteArrayDataInput dataStream)
{
facing = dataStream.readInt();
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
}
@Override

View file

@ -208,6 +208,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
speedMultiplier = dataStream.readInt();
energyMultiplier = dataStream.readInt();
upgradeTicks = dataStream.readInt();
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override

View file

@ -129,8 +129,8 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
{
if(canOperate() && (operatingTicks+1) < MekanismUtils.getTicks(speedMultiplier))
{
operatingTicks++;
electricityStored -= ENERGY_PER_TICK;
operatingTicks++;
electricityStored -= ENERGY_PER_TICK;
}
else if(canOperate() && (operatingTicks+1) >= MekanismUtils.getTicks(speedMultiplier))
{

View file

@ -39,7 +39,7 @@ import dan200.computer.api.IPeripheral;
public class TileEntityFactory extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeManagement
{
/** This Smelting Factory's tier. */
/** This Factory's tier. */
public FactoryTier tier;
/** This machine's side configuration. */
@ -214,32 +214,34 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
upgradeTicks = 0;
}
for(int mainSlot = 0; mainSlot < tier.processes; mainSlot++)
for(int process = 0; process < tier.processes; process++)
{
if(canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)) && (progress[mainSlot]+1) < MekanismUtils.getTicks(speedMultiplier))
if(electricityStored >= ENERGY_PER_TICK)
{
++progress[mainSlot];
electricityStored -= ENERGY_PER_TICK;
}
else if(canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)) && (progress[mainSlot]+1) >= MekanismUtils.getTicks(speedMultiplier))
{
if(!worldObj.isRemote)
if(canOperate(getInputSlot(process), getOutputSlot(process)) && (progress[process]+1) < MekanismUtils.getTicks(speedMultiplier))
{
operate(getInputSlot(mainSlot), getOutputSlot(mainSlot));
++progress[process];
electricityStored -= ENERGY_PER_TICK;
}
else if(canOperate(getInputSlot(process), getOutputSlot(process)) && (progress[process]+1) >= MekanismUtils.getTicks(speedMultiplier))
{
if(!worldObj.isRemote)
{
operate(getInputSlot(process), getOutputSlot(process));
}
progress[process] = 0;
electricityStored -= ENERGY_PER_TICK;
}
progress[mainSlot] = 0;
electricityStored -= ENERGY_PER_TICK;
}
if(!canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)))
if(!canOperate(getInputSlot(process), getOutputSlot(process)))
{
progress[mainSlot] = 0;
progress[process] = 0;
}
}
if(!worldObj.isRemote)
{
boolean newActive = false;
boolean hasOperation = false;
for(int i = 0; i < tier.processes; i++)
@ -247,28 +249,16 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
if(canOperate(getInputSlot(i), getOutputSlot(i)))
{
hasOperation = true;
break;
}
}
for(int i : progress)
if(hasOperation && electricityStored >= ENERGY_PER_TICK)
{
if(i > 0)
{
newActive = true;
}
setActive(true);
}
if(testActive != newActive)
{
if(newActive)
{
setActive(true);
}
else if(!hasOperation)
{
setActive(false);
}
else {
setActive(false);
}
}
}
@ -341,11 +331,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
return false;
}
if(electricityStored < ENERGY_PER_TICK)
{
return false;
}
ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], false);
if (itemstack == null)
@ -415,6 +400,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
{
progress[i] = dataStream.readInt();
}
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override

View file

@ -461,6 +461,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
operatingTicks = dataStream.readInt();
infuseStored = dataStream.readInt();
type = InfusionType.getFromName(dataStream.readUTF());
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override

View file

@ -18,6 +18,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.IActiveState;
import mekanism.client.Sound;
import mekanism.common.Mekanism;
import mekanism.common.MekanismUtils;
import mekanism.common.PacketHandler;
import mekanism.common.TileEntityElectricBlock;
import net.minecraft.nbt.NBTTagCompound;
@ -328,6 +329,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
{
super.handlePacketData(dataStream);
isActive = dataStream.readBoolean();
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override