It now gets to the main menu without ic2 :) o/ Next I need to fix the powered items.

This commit is contained in:
modmuss50 2015-07-23 16:19:07 +01:00
parent 496151fcae
commit 8725c5932d
12 changed files with 1183 additions and 1299 deletions

View file

@ -1,251 +0,0 @@
package techreborn.blocks.storage;
import ic2.api.energy.EnergyNet;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.network.INetworkClientTileEntityEventListener;
import ic2.api.tile.IEnergyStorage;
import ic2.core.IC2;
import ic2.core.block.TileEntityInventory;
import ic2.core.init.MainConfig;
import ic2.core.util.ConfigUtil;
import ic2.core.util.StackUtil;
import ic2.core.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class EUStorageTile extends TileEntityInventory implements IEnergySink, IEnergySource, INetworkClientTileEntityEventListener, IEnergyStorage {
public int tier;
public int output;
public double maxStorage;
public double energy = 0.0D;
public boolean hasRedstone = false;
public byte redstoneMode = 0;
public static byte redstoneModes = 7;
private boolean isEmittingRedstone = false;
private int redstoneUpdateInhibit = 5;
public boolean addedToEnergyNet = false;
public EUStorageTile(int tier1, int output1, int maxStorage1) {
this.tier = tier1;
this.output = output1;
this.maxStorage = maxStorage1;
}
public float getChargeLevel() {
float ret = (float)this.energy / (float)this.maxStorage;
if(ret > 1.0F) {
ret = 1.0F;
}
return ret;
}
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
this.energy = Util.limit(nbttagcompound.getDouble("energy"), 0.0D, (double) this.maxStorage + EnergyNet.instance.getPowerFromTier(this.tier));
this.redstoneMode = nbttagcompound.getByte("redstoneMode");
}
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setDouble("energy", this.energy);
nbttagcompound.setBoolean("active", this.getActive());
nbttagcompound.setByte("redstoneMode", this.redstoneMode);
}
public void onLoaded() {
super.onLoaded();
if(IC2.platform.isSimulating()) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this.addedToEnergyNet = true;
}
}
public void onUnloaded() {
if(IC2.platform.isSimulating() && this.addedToEnergyNet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
this.addedToEnergyNet = false;
}
super.onUnloaded();
}
public boolean enableUpdateEntity() {
return IC2.platform.isSimulating();
}
public void updateEntity() {
super.updateEntity();
boolean needsInvUpdate = false;
if(this.redstoneMode == 5 || this.redstoneMode == 6) {
this.hasRedstone = this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord);
}
boolean shouldEmitRedstone1 = this.shouldEmitRedstone();
if(shouldEmitRedstone1 != this.isEmittingRedstone) {
this.isEmittingRedstone = shouldEmitRedstone1;
this.setActive(this.isEmittingRedstone);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
}
if(needsInvUpdate) {
this.markDirty();
}
}
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
return !this.facingMatchesDirection(direction);
}
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) {
return this.facingMatchesDirection(direction);
}
public boolean facingMatchesDirection(ForgeDirection direction) {
return direction.ordinal() == this.getFacing();
}
public double getOfferedEnergy() {
return this.energy >= (double)this.output && (this.redstoneMode != 5 || !this.hasRedstone) && (this.redstoneMode != 6 || !this.hasRedstone || this.energy >= (double)this.maxStorage)?Math.min(this.energy, (double)this.output):0.0D;
}
public void drawEnergy(double amount) {
this.energy -= amount;
}
public double getDemandedEnergy() {
return (double)this.maxStorage - this.energy;
}
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
if(this.energy >= (double)this.maxStorage) {
return amount;
} else {
this.energy += amount;
return 0.0D;
}
}
public int getSourceTier() {
return this.tier;
}
public int getSinkTier() {
return this.tier;
}
public void onGuiClosed(EntityPlayer entityPlayer) {
}
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
return this.getFacing() != side;
}
public void setFacing(short facing) {
if(this.addedToEnergyNet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
}
super.setFacing(facing);
if(this.addedToEnergyNet) {
this.addedToEnergyNet = false;
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this.addedToEnergyNet = true;
}
}
public boolean isEmittingRedstone() {
return this.isEmittingRedstone;
}
public boolean shouldEmitRedstone() {
boolean shouldEmitRedstone = false;
switch(this.redstoneMode) {
case 1:
shouldEmitRedstone = this.energy >= (double)(this.maxStorage - this.output * 20);
break;
case 2:
shouldEmitRedstone = this.energy > (double)this.output && this.energy < (double)this.maxStorage;
break;
case 3:
shouldEmitRedstone = this.energy > (double)this.output && this.energy < (double)this.maxStorage || this.energy < (double)this.output;
break;
case 4:
shouldEmitRedstone = this.energy < (double)this.output;
}
if(this.isEmittingRedstone != shouldEmitRedstone && this.redstoneUpdateInhibit != 0) {
--this.redstoneUpdateInhibit;
return this.isEmittingRedstone;
} else {
this.redstoneUpdateInhibit = 5;
return shouldEmitRedstone;
}
}
public void onNetworkEvent(EntityPlayer player, int event) {
++this.redstoneMode;
if(this.redstoneMode >= redstoneModes) {
this.redstoneMode = 0;
}
IC2.platform.messagePlayer(player, this.getredstoneMode(), new Object[0]);
}
public String getredstoneMode() {
return this.redstoneMode <= 6 && this.redstoneMode >= 0? StatCollector.translateToLocal("ic2.EUStorage.gui.mod.redstone" + this.redstoneMode):"";
}
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
ItemStack ret = super.getWrenchDrop(entityPlayer);
float energyRetainedInStorageBlockDrops = ConfigUtil.getFloat(MainConfig.get(), "balance/energyRetainedInStorageBlockDrops");
if(energyRetainedInStorageBlockDrops > 0.0F) {
NBTTagCompound nbttagcompound = StackUtil.getOrCreateNbtData(ret);
nbttagcompound.setDouble("energy", this.energy * (double)energyRetainedInStorageBlockDrops);
}
return ret;
}
public int getStored() {
return (int)this.energy;
}
public int getCapacity() {
return (int) this.maxStorage;
}
public int getOutput() {
return this.output;
}
public double getOutputEnergyUnitsPerTick() {
return (double)this.output;
}
public void setStored(int energy1) {
this.energy = (double)energy1;
}
public int addEnergy(int amount) {
this.energy += (double)amount;
return amount;
}
public boolean isTeleporterCompatible(ForgeDirection side) {
return true;
}
}

View file

@ -24,7 +24,7 @@ public class CompatManager {
public CompatManager() {
registerCompact(CompatModuleWaila.class, "Waila");
registerCompact(RecipesIC2.class, "IC2");
registerCompact(RecipesBuildcraft.class, "BuildCraft|Core");
registerCompact(RecipesBuildcraft.class, "BuildCraft|Core", "IC2");
registerCompact(RecipesThermalExpansion.class, "ThermalExpansion");
registerCompact(EmcValues.class, "EE3");
registerCompact(RecipesNatura.class, "Natura");
@ -34,15 +34,18 @@ public class CompatManager {
registerCompact(MinetweakerCompat.class, "MineTweaker");
}
public void registerCompact(Class<?> moduleClass, String modid) {
if (Loader.isModLoaded(modid)) {
try {
compatModules.add((ICompatModule) moduleClass.newInstance());
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
public void registerCompact(Class<?> moduleClass, String... modid) {
for(String id : modid){
if(!Loader.isModLoaded(id)){
return;
}
}
try {
compatModules.add((ICompatModule) moduleClass.newInstance());
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View file

@ -14,121 +14,16 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import ic2.api.item.IC2Items;
import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeInputFluidContainer;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.RecipeInputOreDict;
import ic2.api.recipe.RecipeOutput;
import ic2.api.recipe.Recipes;
import ic2.core.AdvRecipe;
import ic2.core.AdvShapelessRecipe;
import ic2.core.Ic2Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidStack;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.RecipeHandler;
import techreborn.compat.ICompatModule;
import techreborn.items.ItemParts;
import techreborn.items.ItemPlates;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class EmcValues implements ICompatModule {
public static void addIC2Handlers() {
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.compressor.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.extractor.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.metalformerCutting.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.metalformerExtruding.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.metalformerRolling.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.oreWashing.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.centrifuge.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.blockcutter.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.blastfurance.getRecipes().entrySet())
sendRecipeEntry(entry);
for (Object recipeObject : CraftingManager.getInstance().getRecipeList()) {
if (recipeObject instanceof AdvRecipe || recipeObject instanceof AdvShapelessRecipe) {
IRecipe recipe = (IRecipe) recipeObject;
if (recipe.getRecipeOutput() != null) {
List<Object> recipeInputs = getRecipeInputs(recipe);
if (recipeInputs != null && !recipeInputs.isEmpty()) {
RecipeRegistryProxy.addRecipe(recipe.getRecipeOutput(), recipeInputs);
}
}
}
}
}
private static void sendRecipeEntry(Map.Entry<IRecipeInput, RecipeOutput> entry) {
List<ItemStack> recipeStackOutputs = entry.getValue().items;
if (recipeStackOutputs.size() == 1) {
ItemStack recipeOutput = recipeStackOutputs.get(0);
if (recipeOutput != null) {
recipeOutput = recipeOutput.copy();
recipeOutput.setTagCompound(entry.getValue().metadata);
for (ItemStack recipeInput : entry.getKey().getInputs()) {
if (recipeInput != null) {
recipeInput = recipeInput.copy();
recipeInput.stackSize = entry.getKey().getAmount();
RecipeRegistryProxy.addRecipe(recipeOutput, Arrays.asList(recipeInput));
}
}
}
}
}
private static List<Object> getRecipeInputs(IRecipe recipe) {
List<Object> recipeInputs = new ArrayList<Object>();
if (recipe instanceof AdvRecipe) {
for (Object object : ((AdvRecipe) recipe).input) {
addInputToList(recipeInputs, object);
}
} else if (recipe instanceof AdvShapelessRecipe) {
for (Object object : ((AdvShapelessRecipe) recipe).input) {
addInputToList(recipeInputs, object);
}
}
return recipeInputs;
}
public static void addInputToList(List<Object> recipeInputs, Object object) {
if (object instanceof ItemStack) {
ItemStack itemStack = ((ItemStack) object).copy();
recipeInputs.add(itemStack);
} else if (object instanceof String) {
OreStack stack = new OreStack((String) object);
recipeInputs.add(stack);
} else if (object instanceof IRecipeInput) {
if (object instanceof RecipeInputItemStack)
recipeInputs.add(((RecipeInputItemStack) object).input);
else if (object instanceof RecipeInputOreDict)
recipeInputs.add(new OreStack(((RecipeInputOreDict) object).input));
else if (object instanceof RecipeInputFluidContainer)
recipeInputs.add(new FluidStack(((RecipeInputFluidContainer) object).fluid, ((RecipeInputFluidContainer) object).amount));
}
}
@Override
public void preInit(FMLPreInitializationEvent event) {
@ -165,22 +60,8 @@ public class EmcValues implements ICompatModule {
addOre("dustTin", 256);
}
if(!Loader.isModLoaded("EE3Compatibility")){
addStack(IC2Items.getItem("rubber"), 32);
addStack(IC2Items.getItem("carbonPlate"), 256);
addStack(Ic2Items.energyCrystal, 32896 / 9);
addStack(Ic2Items.chargingEnergyCrystal, 32896 / 9);
addStack(IC2Items.getItem("refinedIronIngot"), 512);
addStack(Ic2Items.plateadviron, 512);
addStack(Ic2Items.reBattery, 608);
addStack(Ic2Items.chargedReBattery, 608);
}
addStack(ItemPlates.getPlateByName("steel"), 512);
addStack(ItemParts.getPartByName("lazuriteChunk"), 7776);
if(!Loader.isModLoaded("EE3Compatibility")){
addIC2Handlers();
}
}
@Override

View file

@ -3,14 +3,9 @@ package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ic2.core.util.DrawUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.util.ItemUtils;

View file

@ -3,13 +3,13 @@ package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ic2.core.util.DrawUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.client.GuiUtil;
import techreborn.client.gui.GuiGrinder;
import techreborn.util.ItemUtils;
@ -91,7 +91,7 @@ public class GrinderRecipeHandler extends GenericRecipeHander implements INeiBas
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
int liquidHeight = grinderRecipe.fluidStack.amount * 100 / 16000;
DrawUtil.drawRepeated(fluidIcon, 7, 22 + 47 - liquidHeight, 14.0D, liquidHeight, GuiDraw.gui.getZLevel());
GuiUtil.drawRepeated(fluidIcon, 7, 22 + 47 - liquidHeight, 14.0D, liquidHeight, GuiDraw.gui.getZLevel());
}
GuiDraw.drawString(grinderRecipe.fluidStack.amount + "mb of " + grinderRecipe.fluidStack.getLocalizedName(), 14, 135, -1);

View file

@ -1,19 +1,13 @@
package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ic2.core.util.DrawUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.util.ItemUtils;
import java.awt.Rectangle;
import java.awt.*;
import java.util.List;
public class IndustrialElectrolyzerRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {

View file

@ -3,13 +3,13 @@ package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ic2.core.util.DrawUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
import techreborn.client.GuiUtil;
import techreborn.client.gui.GuiIndustrialSawmill;
import java.awt.*;
@ -84,7 +84,7 @@ public class IndustrialSawmillRecipeHandler extends GenericRecipeHander implemen
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
int liquidHeight = grinderRecipe.fluidStack.amount * 100 / 16000;
DrawUtil.drawRepeated(fluidIcon, 7, 22 + 47 - liquidHeight, 14.0D, liquidHeight, GuiDraw.gui.getZLevel());
GuiUtil.drawRepeated(fluidIcon, 7, 22 + 47 - liquidHeight, 14.0D, liquidHeight, GuiDraw.gui.getZLevel());
}
GuiDraw.drawString(grinderRecipe.fluidStack.amount + "mb of " + grinderRecipe.fluidStack.getLocalizedName(), 14, 135, -1);

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
package techreborn.init;
import cpw.mods.fml.common.Loader;
import net.minecraft.item.ItemStack;
import techreborn.partSystem.IPartProvider;
import techreborn.partSystem.ModPartRegistry;
@ -14,11 +15,13 @@ public class ModParts {
public static void init()
{
for (int i = 0; i < 13; i++) {
CablePart part = new CablePart();
part.setType(i);
ModPartRegistry.registerPart(part);
}
if(Loader.isModLoaded("IC2")){
for (int i = 0; i < 13; i++) {
CablePart part = new CablePart();
part.setType(i);
ModPartRegistry.registerPart(part);
}
}
ModPartRegistry.registerPart(new FarmInventoryCable());
ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory",
"ForgeMultipart");

File diff suppressed because it is too large Load diff

View file

@ -1,35 +1,30 @@
package techreborn.items;
import ic2.core.Ic2Items;
import ic2.core.item.ItemFluidCell;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModItems;
import techreborn.util.LogHelper;
import java.util.List;
public class ItemCells extends ItemTR {
//TODO recode this only using the ic2 api
public static ItemStack getCellByName(String name, int count)
{
ItemFluidCell itemFluidCell = (ItemFluidCell) Ic2Items.FluidCell.getItem();
Fluid fluid = FluidRegistry.getFluid("fluid" + name.toLowerCase());
if(fluid != null){
ItemStack stack = Ic2Items.FluidCell.copy();
itemFluidCell.fill(stack, new FluidStack(fluid.getID(), 2147483647), true);
stack.stackSize = count;
return stack;
} else {
LogHelper.error("Could not find " + "fluid" + name + " in the fluid registry!");
}
// ItemFluidCell itemFluidCell = (ItemFluidCell) Ic2Items.FluidCell.getItem();
// Fluid fluid = FluidRegistry.getFluid("fluid" + name.toLowerCase());
// if(fluid != null){
// ItemStack stack = Ic2Items.FluidCell.copy();
// itemFluidCell.fill(stack, new FluidStack(fluid.getID(), 2147483647), true);
// stack.stackSize = count;
// return stack;
// } else {
// LogHelper.error("Could not find " + "fluid" + name + " in the fluid registry!");
// }
int index = -1;
for (int i = 0; i < types.length; i++) {
if (types[i].equals(name)) {

View file

@ -1,26 +1,17 @@
package techreborn.tiles.idsu;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.network.INetworkClientTileEntityEventListener;
import ic2.api.tile.IEnergyStorage;
import ic2.core.IC2;
import ic2.core.block.TileEntityBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.Core;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySource, INetworkClientTileEntityEventListener, IEnergyStorage {
public class TileIDSU extends TilePowerAcceptor {
public int channelID = 0;
@ -43,20 +34,40 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channelID).storedPower = energy;
}
public int tier;
@Override
public double getMaxPower() {
return 0;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return false;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 0;
}
public int tier;
public int output;
public double maxStorage;
public boolean hasRedstone = false;
public byte redstoneMode = 0;
public static byte redstoneModes = 7;
private boolean isEmittingRedstone = false;
private int redstoneUpdateInhibit = 5;
public boolean addedToEnergyNet = false;
private double euLastTick = 0;
private double euChange;
private int ticks;
public TileIDSU(int tier1, int output1, int maxStorage1) {
super(tier1);
this.tier = tier1;
this.output = output1;
this.maxStorage = maxStorage1;
@ -77,38 +88,14 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
this.redstoneMode = nbttagcompound.getByte("redstoneMode");
this.channelID = nbttagcompound.getInteger("channel");
}
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setByte("redstoneMode", this.redstoneMode);
nbttagcompound.setInteger("channel", this.channelID);
}
public void onLoaded() {
super.onLoaded();
if (IC2.platform.isSimulating()) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this.addedToEnergyNet = true;
}
}
public void onUnloaded() {
if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
this.addedToEnergyNet = false;
}
super.onUnloaded();
}
public boolean enableUpdateEntity() {
return IC2.platform.isSimulating();
}
public void updateEntity() {
super.updateEntity();
@ -128,16 +115,6 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
boolean needsInvUpdate = false;
if (this.redstoneMode == 5 || this.redstoneMode == 6) {
this.hasRedstone = this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord);
}
boolean shouldEmitRedstone1 = this.shouldEmitRedstone();
if (shouldEmitRedstone1 != this.isEmittingRedstone) {
this.isEmittingRedstone = shouldEmitRedstone1;
this.setActive(this.isEmittingRedstone);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
}
if (needsInvUpdate) {
this.markDirty();
@ -146,19 +123,11 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
}
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
return !this.facingMatchesDirection(direction);
return false;
}
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) {
return this.facingMatchesDirection(direction);
}
public boolean facingMatchesDirection(ForgeDirection direction) {
return direction.ordinal() == this.getFacing();
}
public double getOfferedEnergy() {
return this.getEnergy() >= (double) this.output && (this.redstoneMode != 5 || !this.hasRedstone) && (this.redstoneMode != 6 || !this.hasRedstone || this.getEnergy() >= (double) this.maxStorage) ? Math.min(this.getEnergy(), (double) this.output) : 0.0D;
return false;
}
public void drawEnergy(double amount) {
@ -191,59 +160,11 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
}
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
return this.getFacing() != side;
return false;
}
public void setFacing(short facing) {
if (this.addedToEnergyNet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
}
super.setFacing(facing);
if (this.addedToEnergyNet) {
this.addedToEnergyNet = false;
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this.addedToEnergyNet = true;
}
}
public boolean shouldEmitRedstone() {
boolean shouldEmitRedstone = false;
switch (this.redstoneMode) {
case 1:
shouldEmitRedstone = this.getEnergy() >= (double) (this.maxStorage - this.output * 20);
break;
case 2:
shouldEmitRedstone = this.getEnergy() > (double) this.output && this.getEnergy() < (double) this.maxStorage;
break;
case 3:
shouldEmitRedstone = this.getEnergy() > (double) this.output && this.getEnergy() < (double) this.maxStorage || this.getEnergy() < (double) this.output;
break;
case 4:
shouldEmitRedstone = this.getEnergy() < (double) this.output;
}
if (this.isEmittingRedstone != shouldEmitRedstone && this.redstoneUpdateInhibit != 0) {
--this.redstoneUpdateInhibit;
return this.isEmittingRedstone;
} else {
this.redstoneUpdateInhibit = 5;
return shouldEmitRedstone;
}
}
public void onNetworkEvent(EntityPlayer player, int event) {
++this.redstoneMode;
if (this.redstoneMode >= redstoneModes) {
this.redstoneMode = 0;
}
IC2.platform.messagePlayer(player, this.getredstoneMode(), new Object[0]);
}
public String getredstoneMode() {
return this.redstoneMode <= 6 && this.redstoneMode >= 0 ? StatCollector.translateToLocal("ic2.EUStorage.gui.mod.redstone" + this.redstoneMode) : "";
}
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {