Fixed IC2 integration :)
This commit is contained in:
parent
f373b06218
commit
8509eaf0ad
8 changed files with 75 additions and 25 deletions
|
@ -113,14 +113,17 @@ public class TransmitterNetworkRegistry implements ITickHandler
|
||||||
{
|
{
|
||||||
int x = event.getChunk().xPosition;
|
int x = event.getChunk().xPosition;
|
||||||
int z = event.getChunk().zPosition;
|
int z = event.getChunk().zPosition;
|
||||||
|
|
||||||
IChunkProvider cProvider = event.getChunk().worldObj.getChunkProvider();
|
IChunkProvider cProvider = event.getChunk().worldObj.getChunkProvider();
|
||||||
Chunk[] neighbors = new Chunk[5];
|
Chunk[] neighbors = new Chunk[5];
|
||||||
|
|
||||||
neighbors[0] = event.getChunk();
|
neighbors[0] = event.getChunk();
|
||||||
|
|
||||||
if(cProvider.chunkExists(x + 1, z)) neighbors[1] = cProvider.provideChunk(x + 1, z);
|
if(cProvider.chunkExists(x + 1, z)) neighbors[1] = cProvider.provideChunk(x + 1, z);
|
||||||
if(cProvider.chunkExists(x - 1, z)) neighbors[2] = cProvider.provideChunk(x - 1, z);
|
if(cProvider.chunkExists(x - 1, z)) neighbors[2] = cProvider.provideChunk(x - 1, z);
|
||||||
if(cProvider.chunkExists(x, z + 1)) neighbors[3] = cProvider.provideChunk(x, z + 1);
|
if(cProvider.chunkExists(x, z + 1)) neighbors[3] = cProvider.provideChunk(x, z + 1);
|
||||||
if(cProvider.chunkExists(x, z - 1)) neighbors[4] = cProvider.provideChunk(x, z - 1);
|
if(cProvider.chunkExists(x, z - 1)) neighbors[4] = cProvider.provideChunk(x, z - 1);
|
||||||
|
|
||||||
for(Chunk c : neighbors)
|
for(Chunk c : neighbors)
|
||||||
{
|
{
|
||||||
refreshChunk(c);
|
refreshChunk(c);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package mekanism.common;
|
package mekanism.common;
|
||||||
|
|
||||||
|
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||||
|
import ic2.api.energy.tile.IEnergyTile;
|
||||||
import ic2.api.recipe.RecipeInputItemStack;
|
import ic2.api.recipe.RecipeInputItemStack;
|
||||||
import ic2.api.recipe.Recipes;
|
import ic2.api.recipe.Recipes;
|
||||||
|
|
||||||
|
@ -72,9 +74,11 @@ import mekanism.common.network.PacketTransmitterTransferUpdate.TransmitterTransf
|
||||||
import mekanism.common.network.PacketWeather;
|
import mekanism.common.network.PacketWeather;
|
||||||
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
||||||
import mekanism.common.tileentity.TileEntityControlPanel;
|
import mekanism.common.tileentity.TileEntityControlPanel;
|
||||||
|
import mekanism.common.tileentity.TileEntityElectricBlock;
|
||||||
import mekanism.common.tileentity.TileEntityEnergyCube;
|
import mekanism.common.tileentity.TileEntityEnergyCube;
|
||||||
import mekanism.common.tileentity.TileEntityGasTank;
|
import mekanism.common.tileentity.TileEntityGasTank;
|
||||||
import mekanism.common.tileentity.TileEntityTeleporter;
|
import mekanism.common.tileentity.TileEntityTeleporter;
|
||||||
|
import mekanism.common.tileentity.TileEntityUniversalCable;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -82,9 +86,11 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
import net.minecraft.item.crafting.CraftingManager;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.Configuration;
|
import net.minecraftforge.common.Configuration;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
import net.minecraftforge.event.ForgeSubscribe;
|
||||||
|
import net.minecraftforge.event.world.ChunkEvent;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||||
import rebelkeithy.mods.metallurgy.api.IOreInfo;
|
import rebelkeithy.mods.metallurgy.api.IOreInfo;
|
||||||
|
@ -1279,4 +1285,21 @@ public class Mekanism
|
||||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterTransferUpdate().setParams(TransmitterTransferType.FLUID, event.fluidNetwork.transmitters.iterator().next(), event.fluidSent));
|
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterTransferUpdate().setParams(TransmitterTransferType.FLUID, event.fluidNetwork.transmitters.iterator().next(), event.fluidSent));
|
||||||
} catch(Exception e) {}
|
} catch(Exception e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ForgeSubscribe
|
||||||
|
public void onChunkLoad(ChunkEvent.Load event)
|
||||||
|
{
|
||||||
|
for(Object obj : event.getChunk().chunkTileEntityMap.values())
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = (TileEntity)obj;
|
||||||
|
|
||||||
|
if(tileEntity != null)
|
||||||
|
{
|
||||||
|
if(tileEntity instanceof TileEntityElectricBlock || tileEntity instanceof TileEntityUniversalCable)
|
||||||
|
{
|
||||||
|
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile)tileEntity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -70,23 +70,27 @@ public final class MekanismHooks
|
||||||
|
|
||||||
for(Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())
|
for(Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())
|
||||||
{
|
{
|
||||||
if(MekanismUtils.getName(entry.getKey().getInputs().get(0)).startsWith("ore"))
|
if(!entry.getKey().getInputs().isEmpty())
|
||||||
{
|
{
|
||||||
if(!Recipe.ENRICHMENT_CHAMBER.containsRecipe(entry.getKey().getInputs().get(0)))
|
if(MekanismUtils.getName(entry.getKey().getInputs().get(0)).startsWith("ore"))
|
||||||
{
|
{
|
||||||
RecipeHandler.addEnrichmentChamberRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0));
|
if(!Recipe.ENRICHMENT_CHAMBER.containsRecipe(entry.getKey().getInputs().get(0)))
|
||||||
|
{
|
||||||
|
RecipeHandler.addEnrichmentChamberRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if(MekanismUtils.getName(entry.getKey().getInputs().get(0)).startsWith("ingot"))
|
||||||
else if(MekanismUtils.getName(entry.getKey().getInputs().get(0)).startsWith("ingot"))
|
|
||||||
{
|
|
||||||
if(!Recipe.CRUSHER.containsRecipe(entry.getKey().getInputs().get(0)))
|
|
||||||
{
|
{
|
||||||
RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0));
|
if(!Recipe.CRUSHER.containsRecipe(entry.getKey().getInputs().get(0)))
|
||||||
|
{
|
||||||
|
RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
|
||||||
tag.setInteger("amplification", 50000);
|
tag.setInteger("amplification", 50000);
|
||||||
|
|
||||||
Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.EnrichedAlloy), 1), tag);
|
Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.EnrichedAlloy), 1), tag);
|
||||||
|
|
19
common/mekanism/common/TransporterStack.java
Normal file
19
common/mekanism/common/TransporterStack.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package mekanism.common;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
public class TransporterStack
|
||||||
|
{
|
||||||
|
public ItemStack transferStack;
|
||||||
|
|
||||||
|
public void write(NBTTagCompound nbtTags)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void read(NBTTagCompound nbtTags)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
package mekanism.common.block;
|
package mekanism.common.block;
|
||||||
|
|
||||||
|
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||||
|
import ic2.api.energy.tile.IEnergyTile;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -29,6 +32,7 @@ import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import buildcraft.api.tools.IToolWrench;
|
import buildcraft.api.tools.IToolWrench;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -283,6 +287,11 @@ public class BlockTransmitter extends Block
|
||||||
if(!world.isRemote)
|
if(!world.isRemote)
|
||||||
{
|
{
|
||||||
((ITransmitter)tileEntity).refreshTransmitterNetwork();
|
((ITransmitter)tileEntity).refreshTransmitterNetwork();
|
||||||
|
|
||||||
|
if(tileEntity instanceof TileEntityUniversalCable)
|
||||||
|
{
|
||||||
|
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile)tileEntity));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,6 @@ import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork
|
public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork
|
||||||
{
|
{
|
||||||
/** Whether or not this machine has initialized and registered with other mods. */
|
|
||||||
public boolean initialized;
|
|
||||||
|
|
||||||
/** The direction this block is facing. */
|
/** The direction this block is facing. */
|
||||||
public int facing;
|
public int facing;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package mekanism.common.tileentity;
|
package mekanism.common.tileentity;
|
||||||
|
|
||||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
|
||||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||||
import ic2.api.energy.tile.IEnergyTile;
|
import ic2.api.energy.tile.IEnergyTile;
|
||||||
import ic2.api.tile.IWrenchable;
|
import ic2.api.tile.IWrenchable;
|
||||||
|
@ -56,16 +55,6 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
{
|
{
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
if(!initialized)
|
|
||||||
{
|
|
||||||
if(Mekanism.hooks.IC2Loaded)
|
|
||||||
{
|
|
||||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getEnergy() < getMaxEnergy() && powerHandler.getEnergyStored() > 0)
|
if(getEnergy() < getMaxEnergy() && powerHandler.getEnergyStored() > 0)
|
||||||
{
|
{
|
||||||
setEnergy(getEnergy() + powerHandler.useEnergy(0, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
|
setEnergy(getEnergy() + powerHandler.useEnergy(0, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
|
||||||
|
@ -131,7 +120,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
@Override
|
@Override
|
||||||
public void invalidate()
|
public void invalidate()
|
||||||
{
|
{
|
||||||
if(initialized && !worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
if(Mekanism.hooks.IC2Loaded)
|
if(Mekanism.hooks.IC2Loaded)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package mekanism.common.tileentity;
|
package mekanism.common.tileentity;
|
||||||
|
|
||||||
|
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||||
import ic2.api.energy.tile.IEnergySink;
|
import ic2.api.energy.tile.IEnergySink;
|
||||||
import ic2.api.energy.tile.IEnergyTile;
|
import ic2.api.energy.tile.IEnergyTile;
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ import mekanism.common.util.CableUtils;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import buildcraft.api.power.IPowerReceptor;
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
|
@ -99,6 +101,11 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
getTransmitterNetwork().split(this);
|
getTransmitterNetwork().split(this);
|
||||||
|
|
||||||
|
if(Mekanism.hooks.IC2Loaded)
|
||||||
|
{
|
||||||
|
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
|
@ -174,7 +181,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
||||||
{
|
{
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
list.add(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj));
|
list.add(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj));
|
||||||
return getTransmitterNetwork().emit(i, list);
|
return i - (getTransmitterNetwork().emit(i*Mekanism.FROM_IC2, list)*Mekanism.TO_IC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -248,7 +255,6 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
|
||||||
|
|
||||||
public class FakeUENetwork implements IElectricityNetwork
|
public class FakeUENetwork implements IElectricityNetwork
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void split(IConductor connection) {}
|
public void split(IConductor connection) {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue