Update TE, add module config syncing

This commit is contained in:
Aidan Brady committed 2014-01-03 14:26:41 -05:00
1 parent a4f6690ee9
commit 1835f6ff91
11 files changed
+138 -51

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
dir.development=./
dir.mcp=${dir.development}forge/mcp
version.minecraft=1.6.4
version.mod.major=5
version.mod.minor=6
version.mod.major=6
version.mod.minor=0
version.mod.revis=0
@@ -35,11 +35,18 @@ public class EnergyStorage implements IEnergyStorage {
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
this.energy = nbt.getInteger("Energy");
if (energy > capacity) {
energy = capacity;
}
return this;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
if (energy < 0) {
energy = 0;
}
nbt.setInteger("Energy", energy);
return nbt;
}
+4 -4
View File
@@ -18,7 +18,7 @@ public interface IEnergyHandler {
* @param from
* Orientation the energy is received from.
* @param maxReceive
* Maximum amount of energy to received.
* Maximum amount of energy to receive.
* @param simulate
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received.
@@ -29,17 +29,17 @@ public interface IEnergyHandler {
* Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
*
* @param from
* Orientation the energy is extracted to.
* Orientation the energy is extracted from.
* @param maxExtract
* Maximum amount of energy to extract.
* @param simulate
* If TRUE, the discharge will only be simulated.
* If TRUE, the extraction will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted.
*/
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
/**
* Returns true if the Handler functions on a given side - if a Tile Entity can receive and/or send energy from a given side, this should return true.
* Returns true if the Handler functions on a given side - if a Tile Entity can receive or send energy on a given side, this should return true.
*/
boolean canInterface(ForgeDirection from);
+15 -4
View File
@@ -6,16 +6,27 @@ import net.minecraftforge.common.ForgeDirection;
/**
* This interface is implemented on Item Conduits. Use it to attempt to eject items into an entry point.
*
* @author Zeldo Kavira
* @author Zeldo Kavira, King Lemming
*
*/
public interface IItemConduit {
/**
* Insert items into the conduit. Returns the ItemStack left (null if fully routed). Will only accept items if they have an valid destination.
* Insert an ItemStack into the IItemConduit. Will only accept items if there is a valid destination. This returns what is remaining of the original stack -
* a null return means that the entire stack was accepted/routed!
*
* Pass the conduit the side *opposite* the one you are ejecting from!
* @param from
* Orientation the item is inserted from.
* @param item
* ItemStack to be inserted. The size of this stack corresponds to the maximum amount to insert.
* @return An ItemStack representing how much is remaining after the item was inserted (or would have been, if simulated) into the Conduit.
*/
public ItemStack sendItems(ItemStack item, ForgeDirection from);
public ItemStack insertItem(ForgeDirection from, ItemStack item);
/* THE FOLLOWING WILL BE REMOVED IN 3.0.1.X */
@Deprecated
public ItemStack insertItem(ForgeDirection from, ItemStack item, boolean simulate);
@Deprecated
public ItemStack sendItems(ItemStack item, ForgeDirection from);
}
@@ -1,15 +0,0 @@
package cofh.api.transport;
import net.minecraftforge.common.ForgeDirection;
/**
* Implement this interface to explicitly control sided Item Conduit connections for a Tile Entity.
*
* @author Zeldo Kavira
*
*/
public interface IItemConduitConnection {
public boolean canConduitConnect(ForgeDirection from);
}
+1 -1
View File
@@ -139,7 +139,7 @@ public class CommonProxy
Mekanism.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble(10000D);
Mekanism.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123).getInt();
//If this is less than 1, upgrades make machines worse. If less than 0, I don't even know.
Mekanism.maxUpgradeMultiplier = Math.max(1, Mekanism.configuration.get(Configuration.CATEGORY_GENERAL,"UpgradeModifier", 10).getInt());
Mekanism.maxUpgradeMultiplier = Math.max(1, Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10).getInt());
Mekanism.TO_TE = Mekanism.TO_BC*10;
Mekanism.FROM_TE = Mekanism.FROM_BC/10;
+17
View File
@@ -1,5 +1,10 @@
package mekanism.common;
import java.io.DataOutputStream;
import java.io.IOException;
import com.google.common.io.ByteArrayDataInput;
/**
* Implement in your main class if your mod happens to be completely reliant on Mekanism, or in other words, is a Mekanism module.
* @author aidancbrady
@@ -19,4 +24,16 @@ public interface IModule
* @return unique name of the module
*/
public String getName();
/**
* Writes this module's configuration to a ConfigSync packet.
* @param dataStream - the DataOutputStream of the sync packet
*/
public void writeConfig(DataOutputStream dataStream) throws IOException;
/**
* Reads this module's configuration from the original ConfigSync packet.
* @param dataStream - the incoming ByteArrayDataInput of the sync packet
*/
public void readConfig(ByteArrayDataInput dataStream) throws IOException;
}
@@ -2,6 +2,7 @@ package mekanism.common.network;
import java.io.DataOutputStream;
import mekanism.common.IModule;
import mekanism.common.Mekanism;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -66,6 +67,12 @@ public class PacketConfigSync implements IMekanismPacket
Mekanism.oxidationChamberUsage = dataStream.readDouble();
Mekanism.chemicalInfuserUsage = dataStream.readDouble();
Mekanism.chemicalInjectionChamberUsage = dataStream.readDouble();
Mekanism.electrolyticSeparatorUsage = dataStream.readDouble();
for(IModule module : Mekanism.modulesLoaded)
{
module.readConfig(dataStream);
}
Mekanism.proxy.onConfigSync();
}
@@ -111,5 +118,11 @@ public class PacketConfigSync implements IMekanismPacket
dataStream.writeDouble(Mekanism.oxidationChamberUsage);
dataStream.writeDouble(Mekanism.chemicalInfuserUsage);
dataStream.writeDouble(Mekanism.chemicalInjectionChamberUsage);
dataStream.writeDouble(Mekanism.electrolyticSeparatorUsage);
for(IModule module : Mekanism.modulesLoaded)
{
module.writeConfig(dataStream);
}
}
}
@@ -4,8 +4,8 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import mekanism.api.EnumColor;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.common.HashList;
import mekanism.common.IConfigurable;
import mekanism.common.ILogisticalTransporter;
@@ -34,13 +34,14 @@ 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
public class TileEntityLogisticalTransporter extends TileEntity implements ITileNetwork, ILogisticalTransporter, IPipeTile, IConfigurable, IItemConduit
{
public static final int SPEED = 5;
@@ -518,15 +519,9 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
@Override
public int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from)
{
if(doAdd)
{
TileEntity tile = Coord4D.get(this).getFromSide(from).getTileEntity(worldObj);
ItemStack rejects = TransporterUtils.insert(tile, this, stack, null, true, 0);
return TransporterManager.getToUse(stack, rejects).stackSize;
}
return 0;
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
@@ -608,4 +603,22 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
{
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);
}
}
@@ -1,5 +1,29 @@
package mekanism.generators.common;
import java.io.DataOutputStream;
import java.io.IOException;
import mekanism.api.infuse.InfuseObject;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfuseType;
import mekanism.common.IModule;
import mekanism.common.Mekanism;
import mekanism.common.MekanismRecipe;
import mekanism.common.RecipeHandler;
import mekanism.common.Version;
import mekanism.common.item.ItemMekanism;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.generators.common.block.BlockGenerator;
import mekanism.generators.common.item.ItemBlockGenerator;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.OreDictionary;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@@ -10,20 +34,6 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import mekanism.api.infuse.InfuseObject;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfuseType;
import mekanism.common.*;
import mekanism.common.item.ItemMekanism;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.generators.common.block.BlockGenerator;
import mekanism.generators.common.item.ItemBlockGenerator;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.OreDictionary;
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "6.0.0", dependencies = "required-after:Mekanism")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
@@ -174,4 +184,26 @@ public class MekanismGenerators implements IModule
{
return "Generators";
}
@Override
public void writeConfig(DataOutputStream dataStream) throws IOException
{
dataStream.writeDouble(advancedSolarGeneration);
dataStream.writeDouble(bioGeneration);
dataStream.writeDouble(heatGeneration);
dataStream.writeDouble(hydrogenGeneration);
dataStream.writeDouble(solarGeneration);
dataStream.writeDouble(windGeneration);
}
@Override
public void readConfig(ByteArrayDataInput dataStream) throws IOException
{
advancedSolarGeneration = dataStream.readDouble();
bioGeneration = dataStream.readDouble();
heatGeneration = dataStream.readDouble();
hydrogenGeneration = dataStream.readDouble();
solarGeneration = dataStream.readDouble();
windGeneration = dataStream.readDouble();
}
}
@@ -1,7 +1,10 @@
package mekanism.tools.common;
import java.io.DataOutputStream;
import java.util.Random;
import com.google.common.io.ByteArrayDataInput;
import mekanism.common.IModule;
import mekanism.common.Mekanism;
import mekanism.common.MekanismRecipe;
@@ -648,4 +651,10 @@ public class MekanismTools implements IModule
{
return "Tools";
}
@Override
public void writeConfig(DataOutputStream dataStream) {}
@Override
public void readConfig(ByteArrayDataInput dataStream) {}
}