diff options
Diffstat (limited to 'src')
18 files changed, 1462 insertions, 0 deletions
diff --git a/src/Java/cofh/api/energy/EnergyStorage.java b/src/Java/cofh/api/energy/EnergyStorage.java new file mode 100644 index 0000000000..2aad94be72 --- /dev/null +++ b/src/Java/cofh/api/energy/EnergyStorage.java @@ -0,0 +1,129 @@ +package cofh.api.energy; + +import net.minecraft.nbt.NBTTagCompound; + +public class EnergyStorage + implements IEnergyStorage +{ + protected int energy; + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public EnergyStorage(int capacity) + { + this(capacity, capacity, capacity); + } + + public EnergyStorage(int capacity, int maxTransfer) + { + this(capacity, maxTransfer, maxTransfer); + } + + public EnergyStorage(int capacity, int maxReceive, int maxExtract) + { + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } + + public EnergyStorage readFromNBT(NBTTagCompound nbt) + { + this.energy = nbt.getInteger("Energy"); + if (this.energy > this.capacity) { + this.energy = this.capacity; + } + return this; + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbt) + { + if (this.energy < 0) { + this.energy = 0; + } + nbt.setInteger("Energy", this.energy); + return nbt; + } + + public void setCapacity(int capacity) + { + this.capacity = capacity; + if (this.energy > capacity) { + this.energy = capacity; + } + } + + public void setMaxTransfer(int maxTransfer) + { + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } + + public void setMaxReceive(int maxReceive) + { + this.maxReceive = maxReceive; + } + + public void setMaxExtract(int maxExtract) + { + this.maxExtract = maxExtract; + } + + public int getMaxReceive() + { + return this.maxReceive; + } + + public int getMaxExtract() + { + return this.maxExtract; + } + + public void setEnergyStored(int energy) + { + this.energy = energy; + if (this.energy > this.capacity) { + this.energy = this.capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } + + public void modifyEnergyStored(int energy) + { + this.energy += energy; + if (this.energy > this.capacity) { + this.energy = this.capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } + + public int receiveEnergy(int maxReceive, boolean simulate) + { + int energyReceived = Math.min(this.capacity - this.energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) { + this.energy += energyReceived; + } + return energyReceived; + } + + public int extractEnergy(int maxExtract, boolean simulate) + { + int energyExtracted = Math.min(this.energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) { + this.energy -= energyExtracted; + } + return energyExtracted; + } + + public int getEnergyStored() + { + return this.energy; + } + + public int getMaxEnergyStored() + { + return this.capacity; + } +} diff --git a/src/Java/cofh/api/energy/IEnergyConnection.java b/src/Java/cofh/api/energy/IEnergyConnection.java new file mode 100644 index 0000000000..b038c7edb2 --- /dev/null +++ b/src/Java/cofh/api/energy/IEnergyConnection.java @@ -0,0 +1,8 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +public abstract interface IEnergyConnection +{ + public abstract boolean canConnectEnergy(ForgeDirection paramForgeDirection); +} diff --git a/src/Java/cofh/api/energy/IEnergyContainerItem.java b/src/Java/cofh/api/energy/IEnergyContainerItem.java new file mode 100644 index 0000000000..0d0a3cfe7f --- /dev/null +++ b/src/Java/cofh/api/energy/IEnergyContainerItem.java @@ -0,0 +1,14 @@ +package cofh.api.energy; + +import net.minecraft.item.ItemStack; + +public abstract interface IEnergyContainerItem +{ + public abstract int receiveEnergy(ItemStack paramItemStack, int paramInt, boolean paramBoolean); + + public abstract int extractEnergy(ItemStack paramItemStack, int paramInt, boolean paramBoolean); + + public abstract int getEnergyStored(ItemStack paramItemStack); + + public abstract int getMaxEnergyStored(ItemStack paramItemStack); +} diff --git a/src/Java/cofh/api/energy/IEnergyHandler.java b/src/Java/cofh/api/energy/IEnergyHandler.java new file mode 100644 index 0000000000..fb9aae3900 --- /dev/null +++ b/src/Java/cofh/api/energy/IEnergyHandler.java @@ -0,0 +1,15 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +public abstract interface IEnergyHandler + extends IEnergyProvider, IEnergyReceiver +{ + public abstract int receiveEnergy(ForgeDirection paramForgeDirection, int paramInt, boolean paramBoolean); + + public abstract int extractEnergy(ForgeDirection paramForgeDirection, int paramInt, boolean paramBoolean); + + public abstract int getEnergyStored(ForgeDirection paramForgeDirection); + + public abstract int getMaxEnergyStored(ForgeDirection paramForgeDirection); +} diff --git a/src/Java/cofh/api/energy/IEnergyProvider.java b/src/Java/cofh/api/energy/IEnergyProvider.java new file mode 100644 index 0000000000..c0a032db01 --- /dev/null +++ b/src/Java/cofh/api/energy/IEnergyProvider.java @@ -0,0 +1,13 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +public abstract interface IEnergyProvider + extends IEnergyConnection +{ + public abstract int extractEnergy(ForgeDirection paramForgeDirection, int paramInt, boolean paramBoolean); + + public abstract int getEnergyStored(ForgeDirection paramForgeDirection); + + public abstract int getMaxEnergyStored(ForgeDirection paramForgeDirection); +} diff --git a/src/Java/cofh/api/energy/IEnergyReceiver.java b/src/Java/cofh/api/energy/IEnergyReceiver.java new file mode 100644 index 0000000000..20f177b01c --- /dev/null +++ b/src/Java/cofh/api/energy/IEnergyReceiver.java @@ -0,0 +1,13 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +public abstract interface IEnergyReceiver + extends IEnergyConnection +{ + public abstract int receiveEnergy(ForgeDirection paramForgeDirection, int paramInt, boolean paramBoolean); + + public abstract int getEnergyStored(ForgeDirection paramForgeDirection); + + public abstract int getMaxEnergyStored(ForgeDirection paramForgeDirection); +} diff --git a/src/Java/cofh/api/energy/IEnergyStorage.java b/src/Java/cofh/api/energy/IEnergyStorage.java new file mode 100644 index 0000000000..421a51dd15 --- /dev/null +++ b/src/Java/cofh/api/energy/IEnergyStorage.java @@ -0,0 +1,12 @@ +package cofh.api.energy; + +public abstract interface IEnergyStorage +{ + public abstract int receiveEnergy(int paramInt, boolean paramBoolean); + + public abstract int extractEnergy(int paramInt, boolean paramBoolean); + + public abstract int getEnergyStored(); + + public abstract int getMaxEnergyStored(); +} diff --git a/src/Java/cofh/api/energy/ItemEnergyContainer.java b/src/Java/cofh/api/energy/ItemEnergyContainer.java new file mode 100644 index 0000000000..86defc0ae3 --- /dev/null +++ b/src/Java/cofh/api/energy/ItemEnergyContainer.java @@ -0,0 +1,98 @@ +package cofh.api.energy; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ItemEnergyContainer + extends Item + implements IEnergyContainerItem +{ + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public ItemEnergyContainer() {} + + public ItemEnergyContainer(int capacity) + { + this(capacity, capacity, capacity); + } + + public ItemEnergyContainer(int capacity, int maxTransfer) + { + this(capacity, maxTransfer, maxTransfer); + } + + public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) + { + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } + + public ItemEnergyContainer setCapacity(int capacity) + { + this.capacity = capacity; + return this; + } + + public void setMaxTransfer(int maxTransfer) + { + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } + + public void setMaxReceive(int maxReceive) + { + this.maxReceive = maxReceive; + } + + public void setMaxExtract(int maxExtract) + { + this.maxExtract = maxExtract; + } + + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) + { + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) + { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyReceived; + } + + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) + { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyExtracted; + } + + public int getEnergyStored(ItemStack container) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + return 0; + } + return container.stackTagCompound.getInteger("Energy"); + } + + public int getMaxEnergyStored(ItemStack container) + { + return this.capacity; + } +} diff --git a/src/Java/cofh/api/energy/TileEnergyHandler.java b/src/Java/cofh/api/energy/TileEnergyHandler.java new file mode 100644 index 0000000000..8965adfccd --- /dev/null +++ b/src/Java/cofh/api/energy/TileEnergyHandler.java @@ -0,0 +1,49 @@ +package cofh.api.energy; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEnergyHandler + extends TileEntity + implements IEnergyHandler +{ + protected EnergyStorage storage = new EnergyStorage(32000); + + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.storage.readFromNBT(nbt); + } + + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + this.storage.writeToNBT(nbt); + } + + public boolean canConnectEnergy(ForgeDirection from) + { + return true; + } + + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) + { + return this.storage.receiveEnergy(maxReceive, simulate); + } + + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) + { + return this.storage.extractEnergy(maxExtract, simulate); + } + + public int getEnergyStored(ForgeDirection from) + { + return this.storage.getEnergyStored(); + } + + public int getMaxEnergyStored(ForgeDirection from) + { + return this.storage.getMaxEnergyStored(); + } +} diff --git a/src/Java/cofh/api/energy/package-info.java b/src/Java/cofh/api/energy/package-info.java new file mode 100644 index 0000000000..90b2a99c40 --- /dev/null +++ b/src/Java/cofh/api/energy/package-info.java @@ -0,0 +1,6 @@ +package cofh.api.energy; + +import cpw.mods.fml.common.API; + +@API(apiVersion="1.7.10R1.0.0", owner="CoFHAPI", provides="CoFHAPI|energy") +abstract interface package-info {} diff --git a/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialSinter.java b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialSinter.java new file mode 100644 index 0000000000..0c0ffb8cbd --- /dev/null +++ b/src/Java/miscutil/core/handler/registration/gregtech/GregtechIndustrialSinter.java @@ -0,0 +1,24 @@ +package miscutil.core.handler.registration.gregtech; + +import miscutil.core.util.Utils; +import miscutil.core.xmod.gregtech.api.enums.GregtechItemList; +import miscutil.core.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityIndustrialSinter; + +public class GregtechIndustrialSinter{ + + public static void run() + { + if (miscutil.core.lib.LoadedMods.Gregtech){ + Utils.LOG_INFO("Gregtech5u Content | Registering Industrial Sinter Furnace Multiblock."); + run1(); + } + + } + + private static void run1() + { + //Industrial Electrolyzer Multiblock + GregtechItemList.Industrial_SinterFurnace.set(new GregtechMetaTileEntityIndustrialSinter(800, "industrialsinterfurnace.controller.tier.single", "Sinter Furnace").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java index d4784a14f4..2ce795501e 100644 --- a/src/Java/miscutil/core/item/ModItems.java +++ b/src/Java/miscutil/core/item/ModItems.java @@ -18,6 +18,7 @@ import miscutil.core.item.base.rotors.BaseItemRotor; import miscutil.core.item.base.screws.BaseItemScrew; import miscutil.core.item.effects.RarityUncommon; import miscutil.core.item.general.BufferCore; +import miscutil.core.item.general.RF2EU_Battery; import miscutil.core.item.general.fuelrods.FuelRod_Base; import miscutil.core.item.init.ItemsFoods; import miscutil.core.item.tool.misc.SandstoneHammer; @@ -160,6 +161,8 @@ public final class ModItems { public static BaseItemBolt itemBoltBloodSteel; public static BaseItemBolt itemBoltTantalloy60; public static BaseItemBolt itemBoltTantalloy61; + + public static Item RfEuBattery; //@SuppressWarnings("unused") @@ -324,6 +327,7 @@ public final class ModItems { FuelRod_Thorium = new FuelRod_Base("itemFuelRod_Thorium", "Thorium", 1000, 1000); FuelRod_Uranium = new FuelRod_Base("itemFuelRod_Uranium", "Uranium", 2500, 2500); FuelRod_Plutonium = new FuelRod_Base("itemFuelRod_Plutonium", "Plutonium", 5000, 5000); + RfEuBattery = new RF2EU_Battery(); //Registry //GameRegistry.registerItem(FuelRod_Empty, "itemFuelRod_Empty"); //GameRegistry.registerItem(FuelRod_Thorium, "itemFuelRod_Thorium"); diff --git a/src/Java/miscutil/core/item/general/RF2EU_Battery.java b/src/Java/miscutil/core/item/general/RF2EU_Battery.java new file mode 100644 index 0000000000..9cb017e1a7 --- /dev/null +++ b/src/Java/miscutil/core/item/general/RF2EU_Battery.java @@ -0,0 +1,296 @@ +package miscutil.core.item.general; + +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; + +import java.util.List; + +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.lib.CORE; +import miscutil.core.util.Utils; +import miscutil.core.util.item.UtilsItems; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cofh.api.energy.ItemEnergyContainer; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, IElectricItemManager, IFuelHandler{ + + private final String unlocalizedName = "rfEUBattery"; + private final ItemStack thisStack; + private final static int maxValueEU = 100000000; + private final static int maxValueRF = maxValueEU * 4; + private double chargeEU = 0; + + public RF2EU_Battery(){ + super(maxValueRF, maxValueRF, maxValueRF); + GameRegistry.registerFuelHandler(this); + //this.setMaxDamage(Integer.MAX_VALUE); + //this.setDamage(UtilsItems.getSimpleStack(this), 0); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.thisStack = UtilsItems.getSimpleStack(this); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void onUpdate(ItemStack itemStack, World worldObj, Entity player, int p_77663_4_, boolean p_77663_5_) { + getEnergyStored(itemStack); + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer){ + for (ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + IElectricItem electricItem = (IElectricItem) is.getItem(); + chargeEU = ElectricItem.manager.getCharge(is); + } + + } + } + } + + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(ItemStack itemStack) { + return 3; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return 8196; + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + + return ("Conversion Device"); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + //return 1.0D - getEnergyStored(stack) / this.capacity; + return Utils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + int i = 30; + + float f13 = (float)(Minecraft.getSystemTime() % 6000L) / 3000.0F * 3.141592F * 2.0F; + + float t = 0.9F + 0.1F * MathHelper.cos(f13); + + double v = 1.0D - getDurabilityForDisplay(par1ItemStack); + + int r = i + (int)(v * (255 - i) * t); + if (r > 255) { + r = 255; + } + int g = i + (int)(v * (64 - i) * t); + + return r << 16 | g << 8 | i; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return false; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add("IC2/EU Information"); + list.add("Tier: ["+getTier(thisStack)+"]"+" Current Power: ["+(long) getCharge(stack)+"/EU]"); + list.add("Transfer Limit: ["+getTransferLimit(thisStack)+"Eu/t]"+" Burn Time: ["+getBurnTime(stack)/20+"s]"); + list.add(""); + list.add("RF Information"); + list.add("Extraction Rate: [" + this.maxExtract + "Rf/t]" + " Insert Rate: [" + this.maxReceive+"Rf/t]"); + list.add("Current Charge: ["+getEnergyStored(stack) + "Rf / " + getMaxEnergyStored(stack)+"Rf] "+Utils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack))+"%"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) + { + ItemStack newItem = itemStack.copy(); + newItem.stackSize = 1; + extractEnergy(newItem, 150000, false); + return newItem; + } + + @Override + public boolean hasContainerItem(ItemStack stack) + { + return true; + } + + @Override + public int getBurnTime(ItemStack fuel) { + if ((fuel == null) || (fuel.getItem() != this)) { + return 0; + } + return extractEnergy(fuel, 150000, true) / 50 / 100; + } + + @Override + public double charge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean simulate) { + if (stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); + } + int energy = stack.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) + { + energy += energyReceived; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy/4, 3, true, false); + + } + return ElectricItem.manager.charge(stack, amount, tier, ignoreTransferLimit, simulate); + } + + @Override + public double discharge(ItemStack stack, double amount, int tier, + boolean ignoreTransferLimit, boolean externally, boolean simulate) { + if ((stack.stackTagCompound == null) || (!stack.stackTagCompound.hasKey("Energy"))) { + return 0; + } + int energy = stack.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) + { + energy -= energyExtracted; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy/4, 3, true, false); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(ItemStack stack, double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(ItemStack stack, double amount, EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) + { + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) + { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/4, 3, true, false); + + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) + { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/4, 3, true, false); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) + { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy/4, 3, true, false); + return energy; + } + +} diff --git a/src/Java/miscutil/core/util/Utils.java b/src/Java/miscutil/core/util/Utils.java index 5ead0bc76f..344e52eb4a 100644 --- a/src/Java/miscutil/core/util/Utils.java +++ b/src/Java/miscutil/core/util/Utils.java @@ -129,6 +129,12 @@ public class Utils { FMLLog.warning("GT++: "+s); } } + + public static double findPercentage(double currentNumber, double maxNumber){ + double c = ((double) currentNumber / maxNumber) * 100; + double roundOff = Math.round(c * 100.00) / 100.00; + return roundOff; + } //Errors public static void LOG_ERROR(String s){ diff --git a/src/Java/miscutil/core/util/debug/RenderingTE_ForDebug.java b/src/Java/miscutil/core/util/debug/RenderingTE_ForDebug.java new file mode 100644 index 0000000000..92792c814d --- /dev/null +++ b/src/Java/miscutil/core/util/debug/RenderingTE_ForDebug.java @@ -0,0 +1,9 @@ +package miscutil.core.util.debug; + +import net.minecraft.tileentity.TileEntity; + +public class RenderingTE_ForDebug extends TileEntity { + + + +} diff --git a/src/Java/miscutil/core/util/debug/UtilityGL11Debug.java b/src/Java/miscutil/core/util/debug/UtilityGL11Debug.java new file mode 100644 index 0000000000..2e25986cfa --- /dev/null +++ b/src/Java/miscutil/core/util/debug/UtilityGL11Debug.java @@ -0,0 +1,343 @@ +package miscutil.core.util.debug; + +import java.nio.ByteBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + + +/** + * User: The Grey Ghost + * Date: 9/02/14 + */ +public class UtilityGL11Debug +{ + public class GLproperty + { + public GLproperty(int init_gLconstant, String init_name, String init_description, String init_category, String init_fetchCommand) { + gLconstant = init_gLconstant; + name = init_name; + description = init_description; + category = init_category; + fetchCommand = init_fetchCommand; + } + + public int gLconstant; + public String name; + public String description; + public String category; + public String fetchCommand; + } + + public static UtilityGL11Debug instance = new UtilityGL11Debug(); + + public GLproperty[] propertyList = + + { + new GLproperty(GL11.GL_CURRENT_COLOR, "GL_CURRENT_COLOR", "Current color", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_INDEX, "GL_CURRENT_INDEX", "Current color index", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_TEXTURE_COORDS, "GL_CURRENT_TEXTURE_COORDS", "Current texture coordinates", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_NORMAL, "GL_CURRENT_NORMAL", "Current normal", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_POSITION, "GL_CURRENT_RASTER_POSITION", "Current raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_DISTANCE, "GL_CURRENT_RASTER_DISTANCE", "Current raster distance", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_COLOR, "GL_CURRENT_RASTER_COLOR", "Color associated with raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_INDEX, "GL_CURRENT_RASTER_INDEX", "Color index associated with raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_TEXTURE_COORDS, "GL_CURRENT_RASTER_TEXTURE_COORDS", "Texture coordinates associated with raster position", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_RASTER_POSITION_VALID, "GL_CURRENT_RASTER_POSITION_VALID", "Raster position valid bit", "current", "glGetBooleanv()"), + new GLproperty(GL11.GL_EDGE_FLAG, "GL_EDGE_FLAG", "Edge flag", "current", "glGetBooleanv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY, "GL_VERTEX_ARRAY", "Vertex array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_SIZE, "GL_VERTEX_ARRAY_SIZE", "Coordinates per vertex", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_TYPE, "GL_VERTEX_ARRAY_TYPE", "Type of vertex coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_STRIDE, "GL_VERTEX_ARRAY_STRIDE", "Stride between vertices", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY_POINTER, "GL_VERTEX_ARRAY_POINTER", "Pointer to the vertex array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_NORMAL_ARRAY, "GL_NORMAL_ARRAY", "Normal array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_NORMAL_ARRAY_TYPE, "GL_NORMAL_ARRAY_TYPE", "Type of normal coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_NORMAL_ARRAY_STRIDE, "GL_NORMAL_ARRAY_STRIDE", "Stride between normals", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_NORMAL_ARRAY_POINTER, "GL_NORMAL_ARRAY_POINTER", "Pointer to the normal array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY, "GL_COLOR_ARRAY", "RGBA color array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_COLOR_ARRAY_SIZE, "GL_COLOR_ARRAY_SIZE", "Colors per vertex", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY_TYPE, "GL_COLOR_ARRAY_TYPE", "Type of color components", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY_STRIDE, "GL_COLOR_ARRAY_STRIDE", "Stride between colors", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_COLOR_ARRAY_POINTER, "GL_COLOR_ARRAY_POINTER", "Pointer to the color array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_INDEX_ARRAY, "GL_INDEX_ARRAY", "Color-index array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_INDEX_ARRAY_TYPE, "GL_INDEX_ARRAY_TYPE", "Type of color indices", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_ARRAY_STRIDE, "GL_INDEX_ARRAY_STRIDE", "Stride between color indices", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_ARRAY_POINTER, "GL_INDEX_ARRAY_POINTER", "Pointer to the index array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY, "GL_TEXTURE_COORD_ARRAY", "Texture coordinate array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_SIZE, "GL_TEXTURE_COORD_ARRAY_SIZE", "Texture coordinates per element", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_TYPE, "GL_TEXTURE_COORD_ARRAY_TYPE", "Type of texture coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_STRIDE, "GL_TEXTURE_COORD_ARRAY_STRIDE", "Stride between texture coordinates", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_POINTER, "GL_TEXTURE_COORD_ARRAY_POINTER", "Pointer to the texture coordinate array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_EDGE_FLAG_ARRAY, "GL_EDGE_FLAG_ARRAY", "Edge flag array enable", "vertex-array", "glIsEnabled()"), + new GLproperty(GL11.GL_EDGE_FLAG_ARRAY_STRIDE, "GL_EDGE_FLAG_ARRAY_STRIDE", "Stride between edge flags", "vertex-array", "glGetIntegerv()"), + new GLproperty(GL11.GL_EDGE_FLAG_ARRAY_POINTER, "GL_EDGE_FLAG_ARRAY_POINTER", "Pointer to the edge flag array", "vertex-array", "glGetPointerv()"), + new GLproperty(GL11.GL_MODELVIEW_MATRIX, "GL_MODELVIEW_MATRIX", "Modelview matrix stack", "matrix", "glGetFloatv()"), + |
