Don’t replace furnaces, that was for ModJam
This commit is contained in:
parent
25f1a72a16
commit
57c16a0916
4 changed files with 0 additions and 352 deletions
|
@ -31,7 +31,6 @@ public class InductionCommonProxy implements IGuiHandler
|
|||
MekanismInduction.FURNACE_WATTAGE = (float)Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", MekanismInduction.FURNACE_WATTAGE).getDouble(MekanismInduction.FURNACE_WATTAGE);
|
||||
MekanismInduction.SOUND_FXS = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", MekanismInduction.SOUND_FXS).getBoolean(MekanismInduction.SOUND_FXS);
|
||||
MekanismInduction.MAX_CONTRACTOR_DISTANCE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MekanismInduction.MAX_CONTRACTOR_DISTANCE).getInt(MekanismInduction.MAX_CONTRACTOR_DISTANCE);
|
||||
MekanismInduction.REPLACE_FURNACE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Replace vanilla furnace", MekanismInduction.REPLACE_FURNACE).getBoolean(MekanismInduction.REPLACE_FURNACE);
|
||||
|
||||
TileEntityEMContractor.ACCELERATION = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", TileEntityEMContractor.ACCELERATION).getDouble(TileEntityEMContractor.ACCELERATION);
|
||||
TileEntityEMContractor.MAX_REACH = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", TileEntityEMContractor.MAX_REACH).getInt(TileEntityEMContractor.MAX_REACH);
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import mekanism.common.IModule;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Version;
|
||||
import mekanism.induction.common.block.BlockAdvancedFurnace;
|
||||
import mekanism.induction.common.block.BlockBattery;
|
||||
import mekanism.induction.common.block.BlockEMContractor;
|
||||
import mekanism.induction.common.block.BlockMultimeter;
|
||||
|
@ -17,7 +12,6 @@ import mekanism.induction.common.item.ItemBlockMultimeter;
|
|||
import mekanism.induction.common.item.ItemCapacitor;
|
||||
import mekanism.induction.common.item.ItemInfiniteCapacitor;
|
||||
import mekanism.induction.common.item.ItemLinker;
|
||||
import mekanism.induction.common.tileentity.TileEntityAdvancedFurnace;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import mekanism.induction.common.tileentity.TileEntityMultimeter;
|
||||
|
@ -25,8 +19,6 @@ import mekanism.induction.common.tileentity.TileEntityTesla;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
@ -34,12 +26,9 @@ import universalelectricity.compatibility.Compatibility;
|
|||
import universalelectricity.core.item.IItemElectric;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import calclavia.lib.UniversalRecipes;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
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.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
|
@ -88,7 +77,6 @@ public class MekanismInduction implements IModule
|
|||
*/
|
||||
public static float FURNACE_WATTAGE = 10;
|
||||
public static boolean SOUND_FXS = true;
|
||||
public static boolean REPLACE_FURNACE = true;
|
||||
|
||||
/** Block ID by Jyzarc */
|
||||
private static final int BLOCK_ID_PREFIX = 3200;
|
||||
|
@ -141,17 +129,6 @@ public class MekanismInduction implements IModule
|
|||
ElectromagneticContractor = new BlockEMContractor(Mekanism.configuration.getBlock("ElectromagneticContractor", getNextBlockID()).getInt()).setUnlocalizedName("ElectromagneticContractor");
|
||||
Battery = new BlockBattery(Mekanism.configuration.getBlock("Battery", getNextBlockID()).getInt()).setUnlocalizedName("Battery");
|
||||
|
||||
if(REPLACE_FURNACE)
|
||||
{
|
||||
blockAdvancedFurnaceIdle = BlockAdvancedFurnace.createNew(false);
|
||||
blockAdvancedFurnaceBurning = BlockAdvancedFurnace.createNew(true);
|
||||
|
||||
GameRegistry.registerBlock(blockAdvancedFurnaceIdle, "ri_" + blockAdvancedFurnaceIdle.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(blockAdvancedFurnaceBurning, "ri_" + blockAdvancedFurnaceBurning.getUnlocalizedName() + "2");
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityAdvancedFurnace.class, blockAdvancedFurnaceIdle.getUnlocalizedName());
|
||||
}
|
||||
|
||||
Mekanism.configuration.save();
|
||||
|
||||
GameRegistry.registerItem(Capacitor, "Capacitor");
|
||||
|
@ -207,28 +184,6 @@ public class MekanismInduction implements IModule
|
|||
|
||||
/** EM Contractor */
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ElectromagneticContractor, " I ", "GCG", "WWW", 'W', UniversalRecipes.PRIMARY_METAL, 'C', emptyCapacitor, 'G', UniversalRecipes.SECONDARY_METAL, 'I', UniversalRecipes.PRIMARY_METAL));
|
||||
|
||||
/** Inject new furnace tile class */
|
||||
replaceTileEntity(TileEntityFurnace.class, TileEntityAdvancedFurnace.class);
|
||||
}
|
||||
|
||||
public static void replaceTileEntity(Class<? extends TileEntity> findTile, Class<? extends TileEntity> replaceTile)
|
||||
{
|
||||
try {
|
||||
Map<String, Class> nameToClassMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "nameToClassMap", "a");
|
||||
Map<Class, String> classToNameMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_b", "classToNameMap", "b");
|
||||
|
||||
String findTileID = classToNameMap.get(findTile);
|
||||
|
||||
if(findTileID != null)
|
||||
{
|
||||
nameToClassMap.put(findTileID, replaceTile);
|
||||
classToNameMap.put(replaceTile, findTileID);
|
||||
classToNameMap.remove(findTile);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package mekanism.induction.common.block;
|
||||
|
||||
import mekanism.induction.common.tileentity.TileEntityAdvancedFurnace;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockAdvancedFurnace extends BlockFurnace
|
||||
{
|
||||
protected BlockAdvancedFurnace(int id, boolean isBurning)
|
||||
{
|
||||
super(id, isBurning);
|
||||
this.setHardness(3.5F);
|
||||
this.setStepSound(soundStoneFootstep);
|
||||
this.setUnlocalizedName("furnace");
|
||||
|
||||
if (isBurning)
|
||||
{
|
||||
this.setLightValue(0.875F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockAdvancedFurnace createNew(boolean isBurning)
|
||||
{
|
||||
int id = Block.furnaceIdle.blockID;
|
||||
|
||||
if (isBurning)
|
||||
{
|
||||
id = Block.furnaceBurning.blockID;
|
||||
}
|
||||
|
||||
Block.blocksList[id] = null;
|
||||
Item.itemsList[id] = null;
|
||||
return new BlockAdvancedFurnace(id, isBurning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int newID)
|
||||
{
|
||||
super.onNeighborBlockChange(world, x, y, z, newID);
|
||||
((TileEntityAdvancedFurnace)world.getBlockTileEntity(x, y, z)).checkProduce();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityAdvancedFurnace();
|
||||
}
|
||||
}
|
|
@ -1,246 +0,0 @@
|
|||
package mekanism.induction.common.tileentity;
|
||||
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.block.IElectrical;
|
||||
import universalelectricity.core.electricity.ElectricityHelper;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.grid.IElectricityNetwork;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
|
||||
/**
|
||||
* Meant to replace the furnace class.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IElectrical
|
||||
{
|
||||
private static final float WATTAGE = 5;
|
||||
private boolean doProduce = false;
|
||||
private boolean init = true;
|
||||
private float energyBuffer = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (this.init)
|
||||
{
|
||||
this.checkProduce();
|
||||
this.init = false;
|
||||
}
|
||||
|
||||
if (this.energyBuffer >= MekanismInduction.FURNACE_WATTAGE / 20)
|
||||
{
|
||||
this.furnaceCookTime++;
|
||||
|
||||
if (this.furnaceCookTime == 200)
|
||||
{
|
||||
this.furnaceCookTime = 0;
|
||||
this.smeltItem();
|
||||
this.onInventoryChanged();
|
||||
}
|
||||
|
||||
this.energyBuffer = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (this.doProduce)
|
||||
{
|
||||
if (this.getStackInSlot(0) == null)
|
||||
{
|
||||
boolean hasRequest = false;
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity instanceof IConductor)
|
||||
{
|
||||
if (((IConductor) tileEntity).getNetwork().getRequest(this).getWatts() > 0)
|
||||
{
|
||||
if (this.furnaceBurnTime > 0)
|
||||
{
|
||||
this.produceUE(direction);
|
||||
}
|
||||
|
||||
hasRequest = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasRequest)
|
||||
{
|
||||
/**
|
||||
* Steal power from furnace.
|
||||
*/
|
||||
boolean doBlockStateUpdate = this.furnaceBurnTime > 0;
|
||||
|
||||
if (this.furnaceBurnTime == 0)
|
||||
{
|
||||
int burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1));
|
||||
this.decrStackSize(1, 1);
|
||||
this.furnaceBurnTime = burnTime;
|
||||
}
|
||||
|
||||
if (doBlockStateUpdate != this.furnaceBurnTime > 0)
|
||||
{
|
||||
//BlockFurnace.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
this.refreshConductors();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the furnace should produce power.
|
||||
*/
|
||||
public void checkProduce()
|
||||
{
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity instanceof IConductor)
|
||||
{
|
||||
this.doProduce = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.doProduce = false;
|
||||
}
|
||||
|
||||
public void refreshConductors()
|
||||
{
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity instanceof IConductor)
|
||||
{
|
||||
((IConductor) tileEntity).refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces UE power towards a specific direction.
|
||||
*
|
||||
* @param outputDirection - The output direction.
|
||||
*/
|
||||
public boolean produceUE(ForgeDirection outputDirection)
|
||||
{
|
||||
if (!this.worldObj.isRemote && outputDirection != null && outputDirection != ForgeDirection.UNKNOWN)
|
||||
{
|
||||
float provide = this.getProvide(outputDirection);
|
||||
|
||||
if (provide > 0)
|
||||
{
|
||||
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
|
||||
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
|
||||
if (outputNetwork != null)
|
||||
{
|
||||
ElectricityPack powerRequest = outputNetwork.getRequest(this);
|
||||
|
||||
if (powerRequest.getWatts() > 0)
|
||||
{
|
||||
ElectricityPack sendPack = ElectricityPack.getFromWatts(provide, this.getVoltage());
|
||||
float rejectedPower = outputNetwork.produce(sendPack, this);
|
||||
this.provideElectricity(outputDirection.getOpposite(), ElectricityPack.getFromWatts(sendPack.getWatts() - rejectedPower, this.getVoltage()), true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canSmelt()
|
||||
{
|
||||
if (this.getStackInSlot(0) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.getStackInSlot(0));
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (this.getStackInSlot(2) == null)
|
||||
return true;
|
||||
if (!this.getStackInSlot(2).isItemEqual(itemstack))
|
||||
return false;
|
||||
int result = getStackInSlot(2).stackSize + itemstack.stackSize;
|
||||
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
|
||||
{
|
||||
if (doReceive)
|
||||
{
|
||||
this.energyBuffer += receive.getWatts();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return receive.getWatts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
|
||||
{
|
||||
return ElectricityPack.getFromWatts(MekanismInduction.FURNACE_WATTAGE / 20, this.getVoltage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRequest(ForgeDirection direction)
|
||||
{
|
||||
if (this.canSmelt() && this.getStackInSlot(1) == null && this.furnaceBurnTime == 0)
|
||||
{
|
||||
return MekanismInduction.FURNACE_WATTAGE / 20;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProvide(ForgeDirection direction)
|
||||
{
|
||||
if (this.furnaceBurnTime > 0)
|
||||
{
|
||||
return MekanismInduction.FURNACE_WATTAGE / 20;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVoltage()
|
||||
{
|
||||
return 0.12f;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue