Compare commits

...

12 commits

Author SHA1 Message Date
Timo Ley 9dcf9dd3bc chore: use correct license from original
All checks were successful
continuous-integration/drone/push Build is passing
2023-08-04 17:03:45 +00:00
Timo Ley 285c9bb730 chore: add README
Some checks failed
continuous-integration/drone/push Build is failing
2023-02-16 22:01:55 +00:00
Timo Ley 148b63a4e1 fix: elite circuit recipe
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-12-18 16:53:15 +01:00
Timo Ley 0849ec19ee chore: add LICENSE
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 20:34:51 +00:00
Timo Ley 1c50f43014 chore!: move UE core/API to own mod
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-12-09 23:23:32 +01:00
Timo Ley 1a532aa4dd feat: more generic approach to energy compat 2022-12-09 22:33:37 +01:00
Timo Ley 95d0145266 feat: first energy compat improvement 2022-12-09 18:17:18 +01:00
Timo Ley 7913f44840 feat: first step towards implementing new UE API 2022-12-07 19:13:56 +01:00
Timo Ley f5f664f02e fix: Mekanism loading order
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-11-25 22:28:34 +01:00
Timo Ley a83fd143d8 feat: big overhaul
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
2022-11-01 17:43:28 +01:00
Timo Ley 2a8d7e9b61 fix: wrong version number
All checks were successful
continuous-integration/drone/tag Build is passing
2022-10-26 15:56:04 +00:00
Timo Ley f5e073f5cc fix: more random fixes
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
2022-10-26 17:42:13 +02:00
85 changed files with 503 additions and 3422 deletions

165
LICENSE Normal file
View file

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

6
README.md Normal file
View file

@ -0,0 +1,6 @@
# Basic Components
Basic Components is a modification for Minecraft that adds in several new blocks and items, as well as providing a framework for electricity generation between mods coded with the Universal Electricity API
## Dependencies
- [Universal Electricity](https://git.tilera.org/Anvilcraft/universal-electricity)

View file

@ -11,7 +11,9 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {
changing = true
}
}
}
@ -21,33 +23,43 @@ apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "1.0.1-dirty"
version = "2.0.1"
group= "universalelectricity"
archivesBaseName = "basiccomponents"
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "run"
replaceIn "basiccomponents/common/BasicComponents.java"
replace "{VERSION}", project.version
}
repositories {
maven {
url = "https://maven.tilera.xyz/"
}
maven {
name = "ic2"
url = "https://maven.ic2.player.to/"
metadataSources {
artifact()
}
}
}
dependencies {
implementation 'universalelectricity:universalelectricity:5.0.0:deobf'
implementation 'net.industrial-craft:industrialcraft-2:2.2.660-experimental:dev'
}
processResources
{
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
filesMatching('mcmod.info') {
expand 'version':project.version, 'mcversion':project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
task deobfJar(type: Jar) {

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip

View file

@ -8,8 +8,9 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import universalelectricity.api.energy.UnitDisplay;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
@SideOnly(Side.CLIENT)
public class GuiBatteryBox extends GuiContainer {
@ -27,8 +28,8 @@ public class GuiBatteryBox extends GuiContainer {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRendererObj.drawString(this.tileEntity.getInventoryName(), 65, 6, 4210752);
String displayJoules = ElectricityDisplay.getDisplayShort(this.tileEntity.getJoules(), ElectricityDisplay.ElectricUnit.JOULES);
String displayMaxJoules = ElectricityDisplay.getDisplay(this.tileEntity.getMaxJoules(), ElectricityDisplay.ElectricUnit.JOULES);
String displayJoules = UnitDisplay.getDisplayShort(this.tileEntity.getJoules(), UnitDisplay.Unit.JOULES);
String displayMaxJoules = UnitDisplay.getDisplay(this.tileEntity.getMaxJoules(), UnitDisplay.Unit.JOULES);
if(this.tileEntity.isDisabled()) {
displayMaxJoules = "Disabled";
}

View file

@ -8,8 +8,9 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import universalelectricity.api.energy.UnitDisplay;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
@SideOnly(Side.CLIENT)
public class GuiCoalGenerator extends GuiContainer {
@ -36,7 +37,7 @@ public class GuiCoalGenerator extends GuiContainer {
} else if(this.tileEntity.generateWatts < 100.0D) {
displayText = "Hull Heat: " + (int)(this.tileEntity.generateWatts / 100.0D * 100.0D) + "%";
} else {
displayText = ElectricityDisplay.getDisplay(this.tileEntity.generateWatts, ElectricityDisplay.ElectricUnit.WATT);
displayText = UnitDisplay.getDisplay(this.tileEntity.generateWatts, UnitDisplay.Unit.WATT);
}
this.fontRendererObj.drawString(displayText, (int)(100.0D - (double)displayText.length() * 1.25D), 45, 4210752);

View file

@ -8,8 +8,9 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import universalelectricity.api.energy.UnitDisplay;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
@SideOnly(Side.CLIENT)
public class GuiElectricFurnace extends GuiContainer {
@ -39,8 +40,8 @@ public class GuiElectricFurnace extends GuiContainer {
}
this.fontRendererObj.drawString("Status: " + displayText, 82, 45, 4210752);
this.fontRendererObj.drawString(ElectricityDisplay.getDisplay(10000.0D, ElectricityDisplay.ElectricUnit.WATT), 82, 56, 4210752);
this.fontRendererObj.drawString(ElectricityDisplay.getDisplay(this.tileEntity.getVoltage(), ElectricityDisplay.ElectricUnit.VOLTAGE), 82, 68, 4210752);
this.fontRendererObj.drawString(UnitDisplay.getDisplay(10000.0D, UnitDisplay.Unit.WATT), 82, 56, 4210752);
this.fontRendererObj.drawString(UnitDisplay.getDisplay(this.tileEntity.getVoltage(), UnitDisplay.Unit.VOLTAGE), 82, 68, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}

View file

@ -0,0 +1,19 @@
package basiccomponents.common;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class BCTab extends CreativeTabs {
public static final BCTab INSTANCE = new BCTab();
public BCTab() {
super("BasicComponents");
}
@Override
public Item getTabIconItem() {
return Item.getItemFromBlock(BasicComponents.blockCopperWire);
}
}

View file

@ -1,8 +1,6 @@
package basiccomponents.common;
import basiccomponents.client.RenderCopperWire;
import basiccomponents.common.BCGuiHandler;
import basiccomponents.common.CommonProxy;
import basiccomponents.common.block.BlockBase;
import basiccomponents.common.block.BlockBasicMachine;
import basiccomponents.common.block.BlockCopperWire;
@ -29,14 +27,11 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@ -45,7 +40,6 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.item.ElectricItemHelper;
import universalelectricity.prefab.RecipeHelper;
@ -54,12 +48,12 @@ import universalelectricity.prefab.ore.OreGenBase;
import universalelectricity.prefab.ore.OreGenReplaceStone;
import universalelectricity.prefab.ore.OreGenerator;
@Mod(modid = BasicComponents.MODID, name = BasicComponents.NAME, version = BasicComponents.VERSION)
@Mod(modid = BasicComponents.MODID, name = BasicComponents.NAME, version = BasicComponents.VERSION, dependencies = "required-after:universalelectricity")
public class BasicComponents {
public static final String NAME = "Basic Components";
public static final String MODID = "basiccomponents";
public static final String VERSION = "1.0.0-dirty";
public static final String VERSION = "{VERSION}";
public static String CHANNEL = "";
public static final String RESOURCE_PATH = "/mods/basiccomponents/";
public static CommonProxy proxy;
@ -135,14 +129,12 @@ public class BasicComponents {
public static void registerDusts() {
if (OreDictionary.getOres("dustBronze").isEmpty()) {
itemDustBronze = new ItemBase("dustBronze");
itemDustBronze.setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(itemDustBronze, "dustBronze");
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemDustBronze), new Object[]{"!#!", Character.valueOf('!'), "ingotCopper", Character.valueOf('#'), "ingotTin"}), CONFIGURATION, true);
GameRegistry.addSmelting(itemDustBronze, (ItemStack)OreDictionary.getOres("ingotBronze").get(0), 0.6F);
}
if (OreDictionary.getOres("dustSteel").isEmpty()) {
itemDustSteel = new ItemBase("dustSteel");
itemDustSteel.setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(itemDustSteel, "dustSteel");
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemDustSteel), new Object[]{" C ", "CIC", " C ", Character.valueOf('I'), Items.iron_ingot, Character.valueOf('C'), Items.coal}), CONFIGURATION, true);
GameRegistry.addSmelting(itemDustSteel, (ItemStack)OreDictionary.getOres("ingotSteel").get(0), 0.6F);
@ -213,23 +205,19 @@ public class BasicComponents {
public static void registerCircuits() {
itemCircuitBasic = new ItemBase("circuitBasic");
itemCircuitBasic.setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(itemCircuitBasic, "circuitBasic");
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemCircuitBasic), new Object[]{"!#!", "#@#", "!#!", Character.valueOf('@'), "plateBronze", Character.valueOf('#'), Items.redstone, Character.valueOf('!'), "copperWire"}), CONFIGURATION, true);
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemCircuitBasic), new Object[]{"!#!", "#@#", "!#!", Character.valueOf('@'), "plateSteel", Character.valueOf('#'), Items.redstone, Character.valueOf('!'), "copperWire"}), CONFIGURATION, true);
OreDictionary.registerOre("circuitBasic", itemCircuitBasic);
itemCircuitAdvanced = new ItemBase("circuitAdvanced");
itemCircuitAdvanced.setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(itemCircuitAdvanced, "circuitAdvanced");
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemCircuitAdvanced), new Object[]{"@@@", "#?#", "@@@", Character.valueOf('@'), Items.redstone, Character.valueOf('?'), Items.diamond, Character.valueOf('#'), "circuitBasic"}), CONFIGURATION, true);
OreDictionary.registerOre("circuitAdvanced", itemCircuitAdvanced);
itemCircuitElite = new ItemBase("circuitElite");
itemCircuitElite.setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(itemCircuitElite, "circuitElite");
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemCircuitAdvanced), new Object[]{"@@@", "?#?", "@@@", Character.valueOf('@'), Items.gold_ingot, Character.valueOf('?'), "circuitAdvanced", Character.valueOf('#'), Blocks.lapis_block}), CONFIGURATION, true);
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemCircuitElite), new Object[]{"@@@", "?#?", "@@@", Character.valueOf('@'), Items.gold_ingot, Character.valueOf('?'), "circuitAdvanced", Character.valueOf('#'), Blocks.lapis_block}), CONFIGURATION, true);
OreDictionary.registerOre("circuitElite", itemCircuitElite);
itemMotor = new ItemBase("motor");
itemMotor.setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(itemMotor, "motor");
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(itemMotor), new Object[]{"@!@", "!#!", "@!@", Character.valueOf('!'), "ingotSteel", Character.valueOf('#'), Items.iron_ingot, Character.valueOf('@'), "copperWire"}), CONFIGURATION, true);
OreDictionary.registerOre("motor", itemMotor);

View file

@ -1,5 +1,6 @@
package basiccomponents.common.block;
import basiccomponents.common.BCTab;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
@ -8,7 +9,7 @@ public class BlockBase extends Block {
public BlockBase(String name) {
super(Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setCreativeTab(BCTab.INSTANCE);
this.setBlockName("basiccomponents:" + name);
this.setHardness(2.0F);
this.setBlockTextureName("basiccomponents:" + name);

View file

@ -1,5 +1,6 @@
package basiccomponents.common.block;
import basiccomponents.common.BCTab;
import basiccomponents.common.BasicComponents;
import basiccomponents.common.tileentity.TileEntityBatteryBox;
import basiccomponents.common.tileentity.TileEntityCoalGenerator;
@ -38,7 +39,7 @@ public class BlockBasicMachine extends BlockAdvanced {
public BlockBasicMachine(int textureIndex) {
super(UniversalElectricity.machine);
this.setBlockName("basiccomponents:bcMachine");
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setCreativeTab(BCTab.INSTANCE);
this.setStepSound(soundTypeMetal); //TODO Metal Footstep
}

View file

@ -1,5 +1,6 @@
package basiccomponents.common.block;
import basiccomponents.common.BCTab;
import basiccomponents.common.BasicComponents;
import basiccomponents.common.tileentity.TileEntityCopperWire;
import net.minecraft.block.Block;
@ -18,7 +19,7 @@ public class BlockCopperWire extends BlockConductor {
this.setResistance(0.2F);
this.setHardness(0.1F);
this.setBlockBounds(0.3F, 0.3F, 0.3F, 0.7F, 0.7F, 0.7F);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setCreativeTab(BCTab.INSTANCE);
//TODO this
//Block.setBurnProperties(this.field_71990_ca, 30, 60);
}

View file

@ -1,5 +1,6 @@
package basiccomponents.common.item;
import basiccomponents.common.BCTab;
import basiccomponents.common.BasicComponents;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
@ -13,5 +14,6 @@ public class ItemBase extends Item {
this.setUnlocalizedName("basiccomponents:" + name);
this.setTextureName("basiccomponents:" + name);
this.setNoRepair();
this.setCreativeTab(BCTab.INSTANCE);
}
}

View file

@ -1,5 +1,6 @@
package basiccomponents.common.item;
import basiccomponents.common.BCTab;
import basiccomponents.common.BasicComponents;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -13,7 +14,7 @@ public class ItemBattery extends ItemElectric {
public ItemBattery(String name) {
super();
this.setUnlocalizedName("basiccomponents:" + name);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setCreativeTab(BCTab.INSTANCE);
}
@SideOnly(Side.CLIENT)

View file

@ -12,7 +12,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.api.energy.UnitDisplay;
public class ItemBlockCopperWire extends ItemBlock {
@ -38,7 +38,7 @@ public class ItemBlockCopperWire extends ItemBlock {
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
par3List.add("Resistance: " + ElectricityDisplay.getDisplay(TileEntityCopperWire.RESISTANCE, ElectricityDisplay.ElectricUnit.RESISTANCE));
par3List.add("Max Amps: " + ElectricityDisplay.getDisplay(TileEntityCopperWire.MAX_AMPS, ElectricityDisplay.ElectricUnit.AMPERE));
par3List.add("Resistance: " + UnitDisplay.getDisplay(TileEntityCopperWire.RESISTANCE, UnitDisplay.Unit.RESISTANCE));
par3List.add("Max Amps: " + UnitDisplay.getDisplay(TileEntityCopperWire.MAX_AMPS, UnitDisplay.Unit.AMPERE));
}
}

View file

@ -14,7 +14,6 @@ public class ItemInfiniteBattery extends ItemBase implements IItemElectric {
super(name);
this.setMaxStackSize(1);
this.setNoRepair();
this.setCreativeTab(CreativeTabs.tabRedstone);
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {

View file

@ -6,6 +6,5 @@ public class ItemIngot extends ItemBase {
public ItemIngot(String name) {
super(name);
this.setCreativeTab(CreativeTabs.tabMaterials);
}
}

View file

@ -6,6 +6,5 @@ public class ItemPlate extends ItemBase {
public ItemPlate(String name) {
super(name);
this.setCreativeTab(CreativeTabs.tabMaterials);
}
}

View file

@ -15,7 +15,6 @@ public class ItemWrench extends ItemBase implements IToolConfigurator {
public ItemWrench() {
super("wrench");
this.setMaxStackSize(1);
this.setCreativeTab(CreativeTabs.tabTools);
}
public boolean canWrench(EntityPlayer entityPlayer, int x, int y, int z) {
@ -24,6 +23,7 @@ public class ItemWrench extends ItemBase implements IToolConfigurator {
public void wrenchUsed(EntityPlayer entityPlayer, int x, int y, int z) {}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer entityPlayer, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if(block != Blocks.furnace && block != Blocks.lit_furnace && block != Blocks.dropper && block != Blocks.hopper && block != Blocks.dispenser && block != Blocks.piston && block != Blocks.sticky_piston) {
@ -41,11 +41,13 @@ public class ItemWrench extends ItemBase implements IToolConfigurator {
}
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
public boolean shouldPassSneakingClickToBlock(World world, int x, int y, int z) {
@Override
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) {
return true;
}
}

View file

@ -1,13 +1,15 @@
package basiccomponents.common.tileentity;
import basiccomponents.common.BasicComponents;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.registry.LanguageRegistry;
import mekanism.api.energy.ICableOutputter;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -26,10 +28,10 @@ import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import universalelectricity.prefab.tile.TileEntityElectricityStorage;
public class TileEntityBatteryBox extends TileEntityElectricityStorage implements IElectricityStorage, ISidedInventory {
public class TileEntityBatteryBox extends TileEntityElectricityStorage implements IElectricityStorage, ISidedInventory, ICableOutputter, IStrictEnergyStorage, IStrictEnergyAcceptor {
private ItemStack[] containingItems = new ItemStack[2];
public final Set playersUsing = new HashSet();
public final Set<EntityPlayer> playersUsing = new HashSet();
@Override
@ -56,14 +58,11 @@ public class TileEntityBatteryBox extends TileEntityElectricityStorage implement
this.setJoules(this.getJoules() - 5.0E-5D);
if(!this.worldObj.isRemote && super.ticks % 3L == 0L) {
/*Iterator i$1 = this.playersUsing.iterator();
while(i$1.hasNext()) {
EntityPlayer player1 = (EntityPlayer)i$1.next();
PacketDispatcher.sendPacketToPlayer(this.func_70319_e(), (Player)player1);
}*/
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
for (EntityPlayer player : this.playersUsing) {
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(getDescriptionPacket());
}
}
}
}
@ -248,4 +247,37 @@ public class TileEntityBatteryBox extends TileEntityElectricityStorage implement
return false;
}
@Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount) {
if (!canReceiveEnergy(side)) return 0;
double toUse = Math.min(getMaxEnergy()-getEnergy(), amount);
setEnergy(toUse + getEnergy());
return toUse;
}
@Override
public boolean canReceiveEnergy(ForgeDirection side) {
return getConsumingSides().contains(side);
}
@Override
public double getEnergy() {
return getJoules();
}
@Override
public void setEnergy(double energy) {
setJoules(energy);
}
@Override
public double getMaxEnergy() {
return getMaxJoules();
}
@Override
public boolean canOutputTo(ForgeDirection side) {
return side == ForgeDirection.getOrientation(this.getBlockMetadata() - 4 + 2);
}
}

View file

@ -1,18 +1,13 @@
package basiccomponents.common.tileentity;
import basiccomponents.common.BasicComponents;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.registry.LanguageRegistry;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@ -38,7 +33,7 @@ public class TileEntityCoalGenerator extends TileEntityElectrical implements IIn
public IConductor connectedElectricUnit = null;
public int itemCookTime = 0;
private ItemStack[] containingItems = new ItemStack[1];
public final Set playersUsing = new HashSet();
public final Set<EntityPlayer> playersUsing = new HashSet();
public boolean canConnect(ForgeDirection direction) {
@ -57,6 +52,7 @@ public class TileEntityCoalGenerator extends TileEntityElectrical implements IIn
if(network.getRequest(new TileEntity[0]).getWatts() > 0.0D) {
this.connectedElectricUnit = (IConductor)outputTile;
} else {
network.stopProducing(this);
this.connectedElectricUnit = null;
}
} else {
@ -90,13 +86,11 @@ public class TileEntityCoalGenerator extends TileEntityElectrical implements IIn
}
if(super.ticks % 3L == 0L) {
/*Iterator i$ = this.playersUsing.iterator();
while(i$.hasNext()) {
EntityPlayer player = (EntityPlayer)i$.next();
PacketDispatcher.sendPacketToPlayer(this.func_70319_e(), (Player)player);
}*/
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
for (EntityPlayer player : this.playersUsing) {
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(getDescriptionPacket());
}
}
}
if(this.prevGenerateWatts <= 0.0D && this.generateWatts > 0.0D || this.prevGenerateWatts > 0.0D && this.generateWatts <= 0.0D) {

View file

@ -7,6 +7,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
@ -28,7 +29,7 @@ public class TileEntityElectricFurnace extends TileEntityElectricityRunnable imp
public static final int PROCESS_TIME_REQUIRED = 130;
public int processTicks = 0;
private ItemStack[] containingItems = new ItemStack[3];
public final Set playersUsing = new HashSet();
public final Set<EntityPlayer> playersUsing = new HashSet();
@Override
public void updateEntity() {
@ -58,13 +59,11 @@ public class TileEntityElectricFurnace extends TileEntityElectricityRunnable imp
}
if(super.ticks % 3L == 0L) {
/*Iterator i$ = this.playersUsing.iterator();
while(i$.hasNext()) {
EntityPlayer player = (EntityPlayer)i$.next();
PacketDispatcher.sendPacketToPlayer(this.func_70319_e(), (Player)player);
}*/
for (EntityPlayer player : this.playersUsing) {
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(getDescriptionPacket());
}
}
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}

View file

@ -0,0 +1,60 @@
package mekanism.api.energy;
import net.minecraft.item.ItemStack;
public class EnergizedItemManager
{
/**
* Discharges an IEnergizedItem with the defined amount of energy.
* @param itemStack - ItemStack to discharge
* @param amount - amount of energy to discharge from the item, usually the total amount of energy needed in a TileEntity
* @return amount of energy discharged
*/
public static double discharge(ItemStack itemStack, double amount)
{
if(itemStack != null)
{
if(itemStack.getItem() instanceof IEnergizedItem)
{
IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem();
if(energizedItem.canSend(itemStack))
{
double energyToUse = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getEnergy(itemStack), amount));
energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) - energyToUse);
return energyToUse;
}
}
}
return 0;
}
/**
* Charges an IEnergizedItem with the defined amount of energy.
* @param itemStack - ItemStack to charge
* @param amount - amount of energy to charge the item with, usually the total amount of energy stored in a TileEntity
* @return amount of energy charged
*/
public static double charge(ItemStack itemStack, double amount)
{
if(itemStack != null)
{
if(itemStack.getItem() instanceof IEnergizedItem)
{
IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem();
if(energizedItem.canReceive(itemStack))
{
double energyToSend = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getMaxEnergy(itemStack) - energizedItem.getEnergy(itemStack), amount));
energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToSend);
return energyToSend;
}
}
}
return 0;
}
}

View file

@ -0,0 +1,14 @@
package mekanism.api.energy;
/**
* Created by ben on 27/03/15.
*/
public class EnergyStack
{
public double amount;
public EnergyStack(double newAmount)
{
amount = newAmount;
}
}

View file

@ -0,0 +1,18 @@
package mekanism.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this if your TileEntity is capable of outputting energy to cables, overriding Mekanism's default implementation.
* @author AidanBrady
*
*/
public interface ICableOutputter
{
/**
* Whether or not this block can output to a cable on a specific side.
* @param side - side to check
* @return if the block can output
*/
public boolean canOutputTo(ForgeDirection side);
}

View file

@ -0,0 +1,53 @@
package mekanism.api.energy;
import net.minecraft.item.ItemStack;
/**
* Implement this in an item's class if it should be able to store electricity.
* @author aidancbrady
*
*/
public interface IEnergizedItem
{
/**
* Gets and returns the amount of energy stored in this item.
* @param itemStack - the ItemStack to check
* @return energy stored
*/
public double getEnergy(ItemStack itemStack);
/**
* Sets this item's stored energy value to a new amount.
* @param itemStack - the ItemStack who's energy value is to be change
* @param amount - new amount of energy
*/
public void setEnergy(ItemStack itemStack, double amount);
/**
* Gets and returns this item's maximum amount of energy that can be stored.
* @param itemStack - the ItemStack to check
* @return maximum energy
*/
public double getMaxEnergy(ItemStack itemStack);
/**
* Gets and returns how much energy this item can transfer to and from charging slots.
* @param itemStack - the ItemStack to check
* @return transfer amount
*/
public double getMaxTransfer(ItemStack itemStack);
/**
* Gets and returns whether or not this item can receive energy from a charging slot.
* @param itemStack - the ItemStack to check
* @return if the item can receive energy
*/
public boolean canReceive(ItemStack itemStack);
/**
* Gets and returns whether or not this item can send energy to a charging slot.
* @param itemStack - the ItemStack to check
* @return if the item can send energy
*/
public boolean canSend(ItemStack itemStack);
}

View file

@ -0,0 +1,25 @@
package mekanism.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this if your TileEntity can accept energy at a floating-point double value from Universal Cables.
* @author AidanBrady
*
*/
public interface IStrictEnergyAcceptor extends IStrictEnergyStorage
{
/**
* Transfer a certain amount of energy to this acceptor.
* @param amount - amount to transfer
* @return energy used
*/
public double transferEnergyToAcceptor(ForgeDirection side, double amount);
/**
* Whether or not this tile entity accepts energy from a certain side.
* @param side - side to check
* @return if tile entity accepts energy
*/
public boolean canReceiveEnergy(ForgeDirection side);
}

View file

@ -0,0 +1,27 @@
package mekanism.api.energy;
/**
* Mekanism-specific energy storage for TileEntities, already implemented in IStrictEnergyAcceptor.
* @author aidancbrady
*
*/
public interface IStrictEnergyStorage
{
/**
* Gets the amount of energy this TileEntity is currently storing.
* @return stored energy
*/
public double getEnergy();
/**
* Sets the amount of stored energy of this TileEntity to a new amount.
* @param energy - new energy value
*/
public void setEnergy(double energy);
/**
* Gets the maximum amount of energy this TileEntity can store.
* @return maximum energy
*/
public double getMaxEnergy();
}

View file

@ -1,36 +0,0 @@
package universalelectricity.core;
import cpw.mods.fml.common.Loader;
import java.io.File;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.config.Configuration;
public class UniversalElectricity {
public static final String MAJOR_VERSION = "0";
public static final String MINOR_VERSION = "6";
public static final String REVISION_VERSION = "2";
public static final String BUILD_VERSION = "117";
public static final String VERSION = "0.6.2";
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "UniversalElectricity.cfg"));
public static double IC2_RATIO = 40.0D;
public static double BC3_RATIO = 100.0D;
public static double TO_IC2_RATIO = 1.0D / IC2_RATIO;
public static double TO_BC_RATIO = 1.0D / BC3_RATIO;
public static boolean isVoltageSensitive = false;
public static boolean isNetworkActive = false;
public static final Material machine = new Material(MapColor.ironColor);
static {
CONFIGURATION.load();
IC2_RATIO = CONFIGURATION.get("Compatiblity", "IndustrialCraft Conversion Ratio", IC2_RATIO).getDouble(IC2_RATIO);
BC3_RATIO = CONFIGURATION.get("Compatiblity", "BuildCraft Conversion Ratio", BC3_RATIO).getDouble(BC3_RATIO);
TO_IC2_RATIO = 1.0D / IC2_RATIO;
TO_BC_RATIO = 1.0D / BC3_RATIO;
isVoltageSensitive = CONFIGURATION.get("Compatiblity", "Is Voltage Sensitive", isVoltageSensitive).getBoolean(isVoltageSensitive);
isNetworkActive = CONFIGURATION.get("Compatiblity", "Is Network Active", isNetworkActive).getBoolean(isNetworkActive);
CONFIGURATION.save();
}
}

View file

@ -1,11 +0,0 @@
package universalelectricity.core.block;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.block.INetworkProvider;
public interface IConductor extends INetworkProvider, IConnectionProvider {
double getResistance();
double getCurrentCapcity();
}

View file

@ -1,11 +0,0 @@
package universalelectricity.core.block;
import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.block.IConnector;
public interface IConnectionProvider extends IConnector {
TileEntity[] getAdjacentConnections();
void updateAdjacentConnections();
}

View file

@ -1,8 +0,0 @@
package universalelectricity.core.block;
import net.minecraftforge.common.util.ForgeDirection;
public interface IConnector {
boolean canConnect(ForgeDirection var1);
}

View file

@ -1,11 +0,0 @@
package universalelectricity.core.block;
public interface IElectricityStorage {
double getJoules();
void setJoules(double var1);
double getMaxJoules();
}

View file

@ -1,10 +0,0 @@
package universalelectricity.core.block;
import universalelectricity.core.electricity.IElectricityNetwork;
public interface INetworkProvider {
IElectricityNetwork getNetwork();
void setNetwork(IElectricityNetwork var1);
}

View file

@ -1,7 +0,0 @@
package universalelectricity.core.block;
public interface IVoltage {
double getVoltage();
}

View file

@ -1,97 +0,0 @@
package universalelectricity.core.electricity;
public class ElectricityDisplay {
public static String getDisplay(double value, ElectricityDisplay.ElectricUnit unit, int decimalPlaces, boolean isShort) {
String unitName = unit.name;
if(isShort) {
unitName = unit.symbol;
} else if(value > 1.0D) {
unitName = unit.getPlural();
}
return value == 0.0D?value + " " + unitName:(value <= ElectricityDisplay.MeasurementUnit.MILLI.value?roundDecimals(ElectricityDisplay.MeasurementUnit.MICRO.process(value), decimalPlaces) + " " + ElectricityDisplay.MeasurementUnit.MICRO.getName(isShort) + unitName:(value < 1.0D?roundDecimals(ElectricityDisplay.MeasurementUnit.MILLI.process(value), decimalPlaces) + " " + ElectricityDisplay.MeasurementUnit.MILLI.getName(isShort) + unitName:(value > ElectricityDisplay.MeasurementUnit.MEGA.value?roundDecimals(ElectricityDisplay.MeasurementUnit.MEGA.process(value), decimalPlaces) + " " + ElectricityDisplay.MeasurementUnit.MEGA.getName(isShort) + unitName:(value > ElectricityDisplay.MeasurementUnit.KILO.value?roundDecimals(ElectricityDisplay.MeasurementUnit.KILO.process(value), decimalPlaces) + " " + ElectricityDisplay.MeasurementUnit.KILO.getName(isShort) + unitName:roundDecimals(value, decimalPlaces) + " " + unitName))));
}
public static String getDisplay(double value, ElectricityDisplay.ElectricUnit unit) {
return getDisplay(value, unit, 2, false);
}
public static String getDisplayShort(double value, ElectricityDisplay.ElectricUnit unit) {
return getDisplay(value, unit, 2, true);
}
public static String getDisplayShort(double value, ElectricityDisplay.ElectricUnit unit, int decimalPlaces) {
return getDisplay(value, unit, decimalPlaces, true);
}
public static String getDisplaySimple(double value, ElectricityDisplay.ElectricUnit unit, int decimalPlaces) {
return value > 1.0D?(decimalPlaces < 1?(int)value + " " + unit.getPlural():roundDecimals(value, decimalPlaces) + " " + unit.getPlural()):(decimalPlaces < 1?(int)value + " " + unit.name:roundDecimals(value, decimalPlaces) + " " + unit.name);
}
public static double roundDecimals(double d, int decimalPlaces) {
int j = (int)(d * Math.pow(10.0D, (double)decimalPlaces));
return (double)j / Math.pow(10.0D, (double)decimalPlaces);
}
public static double roundDecimals(double d) {
return roundDecimals(d, 2);
}
public static enum ElectricUnit {
AMPERE("AMPERE", 0, "Amp", "I"),
AMP_HOUR("AMP_HOUR", 1, "Amp Hour", "Ah"),
VOLTAGE("VOLTAGE", 2, "Volt", "V"),
WATT("WATT", 3, "Watt", "W"),
WATT_HOUR("WATT_HOUR", 4, "Watt Hour", "Wh"),
RESISTANCE("RESISTANCE", 5, "Ohm", "R"),
CONDUCTANCE("CONDUCTANCE", 6, "Siemen", "S"),
JOULES("JOULES", 7, "Joule", "J");
public String name;
public String symbol;
// $FF: synthetic field
private static final ElectricityDisplay.ElectricUnit[] $VALUES = new ElectricityDisplay.ElectricUnit[]{AMPERE, AMP_HOUR, VOLTAGE, WATT, WATT_HOUR, RESISTANCE, CONDUCTANCE, JOULES};
private ElectricUnit(String var1, int var2, String name, String symbol) {
this.name = name;
this.symbol = symbol;
}
public String getPlural() {
return this.name + "s";
}
}
public static enum MeasurementUnit {
MICRO("MICRO", 0, "Micro", "mi", 1.0E-6D),
MILLI("MILLI", 1, "Milli", "m", 0.001D),
KILO("KILO", 2, "Kilo", "k", 1000.0D),
MEGA("MEGA", 3, "Mega", "M", 1000000.0D);
public String name;
public String symbol;
public double value;
// $FF: synthetic field
private static final ElectricityDisplay.MeasurementUnit[] $VALUES = new ElectricityDisplay.MeasurementUnit[]{MICRO, MILLI, KILO, MEGA};
private MeasurementUnit(String var1, int var2, String name, String symbol, double value) {
this.name = name;
this.symbol = symbol;
this.value = value;
}
public String getName(boolean isSymbol) {
return isSymbol?this.symbol:this.name;
}
public double process(double value) {
return value / this.value;
}
}
}

View file

@ -1,330 +0,0 @@
package universalelectricity.core.electricity;
import cpw.mods.fml.common.FMLLog;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Map.Entry;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.block.INetworkProvider;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.electricity.IElectricityNetwork;
import universalelectricity.core.path.PathfinderChecker;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
public class ElectricityNetwork implements IElectricityNetwork {
private final HashMap producers = new HashMap();
private final HashMap consumers = new HashMap();
private final Set conductors = new HashSet();
public ElectricityNetwork() {}
public ElectricityNetwork(IConductor ... conductors) {
this.conductors.addAll(Arrays.asList(conductors));
}
public void startProducing(TileEntity tileEntity, ElectricityPack electricityPack) {
if(tileEntity != null && electricityPack.getWatts() > 0.0D) {
this.producers.put(tileEntity, electricityPack);
}
}
public void startProducing(TileEntity tileEntity, double amperes, double voltage) {
this.startProducing(tileEntity, new ElectricityPack(amperes, voltage));
}
public boolean isProducing(TileEntity tileEntity) {
return this.producers.containsKey(tileEntity);
}
public void stopProducing(TileEntity tileEntity) {
this.producers.remove(tileEntity);
}
public void startRequesting(TileEntity tileEntity, ElectricityPack electricityPack) {
if(tileEntity != null && electricityPack.getWatts() > 0.0D) {
this.consumers.put(tileEntity, electricityPack);
}
}
public void startRequesting(TileEntity tileEntity, double amperes, double voltage) {
this.startRequesting(tileEntity, new ElectricityPack(amperes, voltage));
}
public boolean isRequesting(TileEntity tileEntity) {
return this.consumers.containsKey(tileEntity);
}
public void stopRequesting(TileEntity tileEntity) {
this.consumers.remove(tileEntity);
}
public ElectricityPack getProduced(TileEntity ... ignoreTiles) {
ElectricityPack totalElectricity = new ElectricityPack(0.0D, 0.0D);
Iterator it = this.producers.entrySet().iterator();
label47:
while(it.hasNext()) {
Entry pairs = (Entry)it.next();
if(pairs != null) {
TileEntity tileEntity = (TileEntity)pairs.getKey();
if(tileEntity == null) {
it.remove();
} else if(tileEntity.isInvalid()) {
it.remove();
} else if(tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity) {
it.remove();
} else {
if(ignoreTiles != null) {
TileEntity[] pack = ignoreTiles;
int newWatts = ignoreTiles.length;
for(int i$ = 0; i$ < newWatts; ++i$) {
TileEntity newVoltage = pack[i$];
if(tileEntity == newVoltage) {
continue label47;
}
}
}
ElectricityPack var11 = (ElectricityPack)pairs.getValue();
if(pairs.getKey() != null && pairs.getValue() != null && var11 != null) {
double var12 = totalElectricity.getWatts() + var11.getWatts();
double var13 = Math.max(totalElectricity.voltage, var11.voltage);
totalElectricity.amperes = var12 / var13;
totalElectricity.voltage = var13;
}
}
}
}
return totalElectricity;
}
public ElectricityPack getRequest(TileEntity ... ignoreTiles) {
ElectricityPack totalElectricity = this.getRequestWithoutReduction();
totalElectricity.amperes = Math.max(totalElectricity.amperes - this.getProduced(ignoreTiles).amperes, 0.0D);
return totalElectricity;
}
public ElectricityPack getRequestWithoutReduction() {
ElectricityPack totalElectricity = new ElectricityPack(0.0D, 0.0D);
Iterator it = this.consumers.entrySet().iterator();
while(it.hasNext()) {
Entry pairs = (Entry)it.next();
if(pairs != null) {
TileEntity tileEntity = (TileEntity)pairs.getKey();
if(tileEntity == null) {
it.remove();
} else if(tileEntity.isInvalid()) {
it.remove();
} else if(tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity) {
it.remove();
} else {
ElectricityPack pack = (ElectricityPack)pairs.getValue();
if(pack != null) {
totalElectricity.amperes += pack.amperes;
totalElectricity.voltage = Math.max(totalElectricity.voltage, pack.voltage);
}
}
}
}
return totalElectricity;
}
public ElectricityPack consumeElectricity(TileEntity tileEntity) {
ElectricityPack totalElectricity = new ElectricityPack(0.0D, 0.0D);
try {
ElectricityPack e = (ElectricityPack)this.consumers.get(tileEntity);
if(this.consumers.containsKey(tileEntity) && e != null) {
totalElectricity = this.getProduced(new TileEntity[0]);
if(totalElectricity.getWatts() > 0.0D) {
ElectricityPack totalRequest = this.getRequestWithoutReduction();
totalElectricity.amperes *= e.amperes / totalRequest.amperes;
int distance = this.conductors.size();
double ampsReceived = totalElectricity.amperes - totalElectricity.amperes * totalElectricity.amperes * this.getTotalResistance() / totalElectricity.voltage;
double voltsReceived = totalElectricity.voltage - totalElectricity.amperes * this.getTotalResistance();
totalElectricity.amperes = ampsReceived;
totalElectricity.voltage = voltsReceived;
return totalElectricity;
}
}
} catch (Exception var10) {
FMLLog.severe("Failed to consume electricity!", new Object[0]);
var10.printStackTrace();
}
return totalElectricity;
}
public HashMap getProducers() {
return this.producers;
}
public List getProviders() {
ArrayList providers = new ArrayList();
providers.addAll(this.producers.keySet());
return providers;
}
public HashMap getConsumers() {
return this.consumers;
}
public List getReceivers() {
ArrayList receivers = new ArrayList();
receivers.addAll(this.consumers.keySet());
return receivers;
}
public void cleanUpConductors() {
Iterator it = this.conductors.iterator();
while(it.hasNext()) {
IConductor conductor = (IConductor)it.next();
if(conductor == null) {
it.remove();
} else if(((TileEntity)conductor).isInvalid()) {
it.remove();
} else {
conductor.setNetwork(this);
}
}
}
public void refreshConductors() {
this.cleanUpConductors();
try {
Iterator e = this.conductors.iterator();
while(e.hasNext()) {
IConductor conductor = (IConductor)e.next();
conductor.updateAdjacentConnections();
}
} catch (Exception var3) {
FMLLog.severe("Universal Electricity: Failed to refresh conductor.", new Object[0]);
var3.printStackTrace();
}
}
public double getTotalResistance() {
double resistance = 0.0D;
IConductor conductor;
for(Iterator i$ = this.conductors.iterator(); i$.hasNext(); resistance += conductor.getResistance()) {
conductor = (IConductor)i$.next();
}
return resistance;
}
public double getLowestCurrentCapacity() {
double lowestAmp = 0.0D;
Iterator i$ = this.conductors.iterator();
while(i$.hasNext()) {
IConductor conductor = (IConductor)i$.next();
if(lowestAmp == 0.0D || conductor.getCurrentCapcity() < lowestAmp) {
lowestAmp = conductor.getCurrentCapcity();
}
}
return lowestAmp;
}
public Set getConductors() {
return this.conductors;
}
public void mergeConnection(IElectricityNetwork network) {
if(network != null && network != this) {
ElectricityNetwork newNetwork = new ElectricityNetwork();
newNetwork.getConductors().addAll(this.getConductors());
newNetwork.getConductors().addAll(network.getConductors());
newNetwork.cleanUpConductors();
}
}
public void splitNetwork(IConnectionProvider splitPoint) {
if(splitPoint instanceof TileEntity) {
this.getConductors().remove(splitPoint);
ForgeDirection[] connectedBlocks = ForgeDirection.values();
int i = connectedBlocks.length;
for(int connectedBlockA = 0; connectedBlockA < i; ++connectedBlockA) {
ForgeDirection ii = connectedBlocks[connectedBlockA];
if(ii != ForgeDirection.UNKNOWN) {
Vector3 connectedBlockB = new Vector3((TileEntity)splitPoint);
TileEntity finder = VectorHelper.getTileEntityFromSide(((TileEntity)splitPoint).getWorldObj(), connectedBlockB, ii);
if(this.producers.containsKey(finder)) {
this.stopProducing(finder);
this.stopRequesting(finder);
}
}
}
TileEntity[] var12 = splitPoint.getAdjacentConnections();
for(i = 0; i < var12.length; ++i) {
TileEntity var13 = var12[i];
if(var13 instanceof IConnectionProvider) {
for(int var14 = 0; var14 < var12.length; ++var14) {
TileEntity var15 = var12[var14];
if(var13 != var15 && var15 instanceof IConnectionProvider) {
PathfinderChecker var16 = new PathfinderChecker(((TileEntity)splitPoint).getWorldObj(), (IConnectionProvider)var15, new IConnectionProvider[]{splitPoint});
var16.init(new Vector3(var13));
if(var16.results.size() > 0) {
Iterator newNetwork = var16.closedSet.iterator();
while(newNetwork.hasNext()) {
Vector3 i$ = (Vector3)newNetwork.next();
TileEntity node = i$.getTileEntity(((TileEntity)splitPoint).getWorldObj());
if(node instanceof INetworkProvider && node != splitPoint) {
((INetworkProvider)node).setNetwork(this);
}
}
} else {
ElectricityNetwork var17 = new ElectricityNetwork();
Iterator var18 = var16.closedSet.iterator();
while(var18.hasNext()) {
Vector3 var19 = (Vector3)var18.next();
TileEntity nodeTile = var19.getTileEntity(((TileEntity)splitPoint).getWorldObj());
if(nodeTile instanceof INetworkProvider && nodeTile != splitPoint) {
var17.getConductors().add((IConductor)nodeTile);
}
}
var17.cleanUpConductors();
}
}
}
}
}
}
}
public String toString() {
return "ElectricityNetwork[" + this.hashCode() + "|Wires:" + this.conductors.size() + "]";
}
}

View file

@ -1,140 +0,0 @@
package universalelectricity.core.electricity;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.INetworkProvider;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.electricity.IElectricityNetwork;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
public class ElectricityNetworkHelper {
public static void invalidate(TileEntity tileEntity) {
for(int i = 0; i < 6; ++i) {
ForgeDirection direction = ForgeDirection.getOrientation(i);
TileEntity checkTile = VectorHelper.getConnectorFromSide(tileEntity.getWorldObj(), new Vector3(tileEntity), direction);
if(checkTile instanceof INetworkProvider) {
IElectricityNetwork network = ((INetworkProvider)checkTile).getNetwork();
if(network != null) {
network.stopRequesting(tileEntity);
network.stopProducing(tileEntity);
}
}
}
}
public static EnumSet getDirections(TileEntity tileEntity) {
EnumSet possibleSides = EnumSet.noneOf(ForgeDirection.class);
if(tileEntity instanceof IConnector) {
for(int i = 0; i < 6; ++i) {
ForgeDirection direction = ForgeDirection.getOrientation(i);
if(((IConnector)tileEntity).canConnect(direction)) {
possibleSides.add(direction);
}
}
}
return possibleSides;
}
public static ElectricityPack produceFromMultipleSides(TileEntity tileEntity, ElectricityPack electricityPack) {
return produceFromMultipleSides(tileEntity, getDirections(tileEntity), electricityPack);
}
public static ElectricityPack produceFromMultipleSides(TileEntity tileEntity, EnumSet approachingDirection, ElectricityPack producingPack) {
ElectricityPack remainingElectricity = producingPack.clone();
if(tileEntity != null && approachingDirection != null) {
List connectedNetworks = getNetworksFromMultipleSides(tileEntity, approachingDirection);
if(connectedNetworks.size() > 0) {
double wattsPerSide = producingPack.getWatts() / (double)connectedNetworks.size();
double voltage = producingPack.voltage;
Iterator i$ = connectedNetworks.iterator();
while(i$.hasNext()) {
IElectricityNetwork network = (IElectricityNetwork)i$.next();
if(wattsPerSide > 0.0D && producingPack.getWatts() > 0.0D) {
double amperes = Math.min(wattsPerSide / voltage, network.getRequest(new TileEntity[]{tileEntity}).amperes);
if(amperes > 0.0D) {
network.startProducing(tileEntity, amperes, voltage);
remainingElectricity.amperes -= amperes;
}
} else {
network.stopProducing(tileEntity);
}
}
}
}
return remainingElectricity;
}
public static ElectricityPack consumeFromMultipleSides(TileEntity tileEntity, ElectricityPack electricityPack) {
return consumeFromMultipleSides(tileEntity, getDirections(tileEntity), electricityPack);
}
public static ElectricityPack consumeFromMultipleSides(TileEntity tileEntity, EnumSet approachingDirection, ElectricityPack requestPack) {
ElectricityPack consumedPack = new ElectricityPack();
if(tileEntity != null && approachingDirection != null) {
List connectedNetworks = getNetworksFromMultipleSides(tileEntity, approachingDirection);
if(connectedNetworks.size() > 0) {
double wattsPerSide = requestPack.getWatts() / (double)connectedNetworks.size();
double voltage = requestPack.voltage;
Iterator i$ = connectedNetworks.iterator();
while(i$.hasNext()) {
IElectricityNetwork network = (IElectricityNetwork)i$.next();
if(wattsPerSide > 0.0D && requestPack.getWatts() > 0.0D) {
network.startRequesting(tileEntity, wattsPerSide / voltage, voltage);
ElectricityPack receivedPack = network.consumeElectricity(tileEntity);
consumedPack.amperes += receivedPack.amperes;
consumedPack.voltage = Math.max(consumedPack.voltage, receivedPack.voltage);
} else {
network.stopRequesting(tileEntity);
}
}
}
}
return consumedPack;
}
public static List getNetworksFromMultipleSides(TileEntity tileEntity, EnumSet approachingDirection) {
ArrayList connectedNetworks = new ArrayList();
for(int i = 0; i < 6; ++i) {
ForgeDirection direction = ForgeDirection.getOrientation(i);
if(approachingDirection.contains(direction)) {
Vector3 position = new Vector3(tileEntity);
position.modifyPositionFromSide(direction);
TileEntity outputConductor = position.getTileEntity(tileEntity.getWorldObj());
IElectricityNetwork electricityNetwork = getNetworkFromTileEntity(outputConductor, direction);
if(electricityNetwork != null && !connectedNetworks.contains(connectedNetworks)) {
connectedNetworks.add(electricityNetwork);
}
}
}
return connectedNetworks;
}
public static IElectricityNetwork getNetworkFromTileEntity(TileEntity tileEntity, ForgeDirection approachDirection) {
if(tileEntity != null && tileEntity instanceof INetworkProvider) {
if(!(tileEntity instanceof IConnector)) {
return ((INetworkProvider)tileEntity).getNetwork();
}
if(((IConnector)tileEntity).canConnect(approachDirection.getOpposite())) {
return ((INetworkProvider)tileEntity).getNetwork();
}
}
return null;
}
}

View file

@ -1,102 +0,0 @@
package universalelectricity.core.electricity;
public class ElectricityPack implements Cloneable {
public double amperes;
public double voltage;
public ElectricityPack(double amperes, double voltage) {
this.amperes = amperes;
this.voltage = voltage;
}
public ElectricityPack() {
this(0.0D, 0.0D);
}
public static ElectricityPack getFromWatts(double watts, double voltage) {
return new ElectricityPack(watts / voltage, voltage);
}
public double getWatts() {
return getWatts(this.amperes, this.voltage);
}
public double getConductance() {
return getConductance(this.amperes, this.voltage);
}
public double getResistance() {
return getResistance(this.amperes, this.voltage);
}
public static double getJoules(double watts, double seconds) {
return watts * seconds;
}
public static double getJoules(double amps, double voltage, double seconds) {
return amps * voltage * seconds;
}
public static double getWattsFromJoules(double joules, double seconds) {
return joules / seconds;
}
public static double getAmps(double watts, double voltage) {
return watts / voltage;
}
public static double getAmps(double ampHours) {
return ampHours * 3600.0D;
}
public static double getAmpsFromWattHours(double wattHours, double voltage) {
return getWatts(wattHours) / voltage;
}
public static double getWattHoursFromAmpHours(double ampHours, double voltage) {
return ampHours * voltage;
}
public static double getAmpHours(double amps) {
return amps / 3600.0D;
}
public static double getWatts(double amps, double voltage) {
return amps * voltage;
}
public static double getWatts(double wattHours) {
return wattHours * 3600.0D;
}
public static double getWattHours(double watts) {
return watts / 3600.0D;
}
public static double getWattHours(double amps, double voltage) {
return getWattHours(getWatts(amps, voltage));
}
public static double getResistance(double amps, double voltage) {
return voltage / amps;
}
public static double getConductance(double amps, double voltage) {
return amps / voltage;
}
public String toString() {
return "ElectricityPack [Amps:" + this.amperes + " Volts:" + this.voltage + "]";
}
public ElectricityPack clone() {
return new ElectricityPack(this.amperes, this.voltage);
}
public boolean isEqual(ElectricityPack electricityPack) {
return this.amperes == electricityPack.amperes && this.voltage == electricityPack.voltage;
}
}

View file

@ -1,15 +0,0 @@
package universalelectricity.core.electricity;
import java.util.List;
import universalelectricity.core.block.IConductor;
public interface IConductorRegistry {
void register(IConductor var1);
void cleanConductors();
void resetAllConnections();
List getConductors();
}

View file

@ -1,57 +0,0 @@
package universalelectricity.core.electricity;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.electricity.ElectricityPack;
public interface IElectricityNetwork {
void startProducing(TileEntity var1, ElectricityPack var2);
void startProducing(TileEntity var1, double var2, double var4);
boolean isProducing(TileEntity var1);
void stopProducing(TileEntity var1);
void startRequesting(TileEntity var1, ElectricityPack var2);
void startRequesting(TileEntity var1, double var2, double var4);
boolean isRequesting(TileEntity var1);
void stopRequesting(TileEntity var1);
ElectricityPack getProduced(TileEntity ... var1);
ElectricityPack getRequest(TileEntity ... var1);
ElectricityPack getRequestWithoutReduction();
ElectricityPack consumeElectricity(TileEntity var1);
HashMap getProducers();
List getProviders();
HashMap getConsumers();
List getReceivers();
Set getConductors();
double getTotalResistance();
double getLowestCurrentCapacity();
void cleanUpConductors();
void refreshConductors();
void mergeConnection(IElectricityNetwork var1);
void splitNetwork(IConnectionProvider var1);
}

View file

@ -1,60 +0,0 @@
package universalelectricity.core.item;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.item.IItemElectric;
public class ElectricItemHelper {
public static double chargeItem(ItemStack itemStack, double joules, double voltage) {
if(itemStack != null && itemStack.getItem() instanceof IItemElectric) {
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
double providingWatts = Math.min(joules, electricItem.getReceiveRequest(itemStack).getWatts());
if(providingWatts > 0.0D) {
ElectricityPack providedElectricity = electricItem.onReceive(ElectricityPack.getFromWatts(providingWatts, voltage), itemStack);
return providedElectricity.getWatts();
}
}
return 0.0D;
}
public static double dechargeItem(ItemStack itemStack, double joules, double voltage) {
if(itemStack != null && itemStack.getItem() instanceof IItemElectric) {
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
double requestingWatts = Math.min(joules, electricItem.getProvideRequest(itemStack).getWatts());
if(requestingWatts > 0.0D) {
ElectricityPack receivedElectricity = electricItem.onProvide(ElectricityPack.getFromWatts(requestingWatts, voltage), itemStack);
return receivedElectricity.getWatts();
}
}
return 0.0D;
}
public static ItemStack getWithCharge(ItemStack itemStack, double joules) {
if(itemStack != null && itemStack.getItem() instanceof IItemElectric) {
((IItemElectric)itemStack.getItem()).setJoules(joules, itemStack);
return itemStack;
} else {
return itemStack;
}
}
public static ItemStack getWithCharge(Item item, double joules) {
return getWithCharge(new ItemStack(item), joules);
}
public static ItemStack getCloneWithCharge(ItemStack itemStack, double joules) {
return getWithCharge(itemStack.copy(), joules);
}
public static ItemStack getUncharged(ItemStack itemStack) {
return getWithCharge(itemStack, 0.0D);
}
public static ItemStack getUncharged(Item item) {
return getUncharged(new ItemStack(item));
}
}

View file

@ -1,17 +0,0 @@
package universalelectricity.core.item;
import net.minecraft.item.ItemStack;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.item.IItemElectricityStorage;
import universalelectricity.core.item.IItemVoltage;
public interface IItemElectric extends IItemElectricityStorage, IItemVoltage {
ElectricityPack onReceive(ElectricityPack var1, ItemStack var2);
ElectricityPack onProvide(ElectricityPack var1, ItemStack var2);
ElectricityPack getReceiveRequest(ItemStack var1);
ElectricityPack getProvideRequest(ItemStack var1);
}

View file

@ -1,12 +0,0 @@
package universalelectricity.core.item;
import net.minecraft.item.ItemStack;
public interface IItemElectricityStorage {
double getJoules(ItemStack var1);
void setJoules(double var1, ItemStack var3);
double getMaxJoules(ItemStack var1);
}

View file

@ -1,8 +0,0 @@
package universalelectricity.core.item;
import net.minecraft.item.ItemStack;
public interface IItemVoltage {
double getVoltage(ItemStack var1);
}

View file

@ -1,93 +0,0 @@
package universalelectricity.core.item;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.item.ElectricItemHelper;
import universalelectricity.core.item.IItemElectric;
public abstract class ItemElectric extends Item implements IItemElectric {
public ItemElectric() {
super();
this.setMaxStackSize(1);
this.setMaxDamage(100);
this.setNoRepair();
}
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean par4) {
String color = "";
double joules = this.getJoules(itemStack);
if(joules <= this.getMaxJoules(itemStack) / 3.0D) {
color = "§4";
} else if(joules > this.getMaxJoules(itemStack) * 2.0D / 3.0D) {
color = "§2";
} else {
color = "§6";
}
list.add(color + ElectricityDisplay.getDisplay(joules, ElectricityDisplay.ElectricUnit.JOULES) + "/" + ElectricityDisplay.getDisplay(this.getMaxJoules(itemStack), ElectricityDisplay.ElectricUnit.JOULES));
}
public void onCreated(ItemStack itemStack, World par2World, EntityPlayer par3EntityPlayer) {
this.setJoules(0.0D, itemStack);
}
public ElectricityPack onReceive(ElectricityPack electricityPack, ItemStack itemStack) {
double rejectedElectricity = Math.max(this.getJoules(itemStack) + electricityPack.getWatts() - this.getMaxJoules(itemStack), 0.0D);
double joulesToStore = electricityPack.getWatts() - rejectedElectricity;
this.setJoules(this.getJoules(itemStack) + joulesToStore, itemStack);
return ElectricityPack.getFromWatts(joulesToStore, this.getVoltage(itemStack));
}
public ElectricityPack onProvide(ElectricityPack electricityPack, ItemStack itemStack) {
double electricityToUse = Math.min(this.getJoules(itemStack), electricityPack.getWatts());
this.setJoules(this.getJoules(itemStack) - electricityToUse, itemStack);
return ElectricityPack.getFromWatts(electricityToUse, this.getVoltage(itemStack));
}
public ElectricityPack getReceiveRequest(ItemStack itemStack) {
return ElectricityPack.getFromWatts(Math.min(this.getMaxJoules(itemStack) - this.getJoules(itemStack), this.getTransferRate(itemStack)), this.getVoltage(itemStack));
}
public ElectricityPack getProvideRequest(ItemStack itemStack) {
return ElectricityPack.getFromWatts(Math.min(this.getJoules(itemStack), this.getTransferRate(itemStack)), this.getVoltage(itemStack));
}
public double getTransferRate(ItemStack itemStack) {
return this.getMaxJoules(itemStack) * 0.01D;
}
public void setJoules(double joules, ItemStack itemStack) {
if(itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
double electricityStored = Math.max(Math.min(joules, this.getMaxJoules(itemStack)), 0.0D);
itemStack.getTagCompound().setDouble("electricity", electricityStored);
itemStack.setItemDamage((int)(100.0D - electricityStored / this.getMaxJoules(itemStack) * 100.0D));
}
public double getJoules(ItemStack itemStack) {
if(itemStack.getTagCompound() == null) {
return 0.0D;
} else {
double electricityStored = itemStack.getTagCompound().getDouble("electricity");
itemStack.setItemDamage((int)(100.0D - electricityStored / this.getMaxJoules(itemStack) * 100.0D));
return electricityStored;
}
}
@Override
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(ElectricItemHelper.getUncharged(new ItemStack(this)));
ItemStack chargedItem = new ItemStack(this);
par3List.add(ElectricItemHelper.getWithCharge(chargedItem, this.getMaxJoules(chargedItem)));
}
}

View file

@ -1,12 +0,0 @@
package universalelectricity.core.path;
import java.util.Set;
import universalelectricity.core.path.Pathfinder;
import universalelectricity.core.vector.Vector3;
public interface IPathCallBack {
Set getConnectedNodes(Pathfinder var1, Vector3 var2);
boolean onSearch(Pathfinder var1, Vector3 var2);
}

View file

@ -1,51 +0,0 @@
package universalelectricity.core.path;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import universalelectricity.core.path.IPathCallBack;
import universalelectricity.core.vector.Vector3;
public class Pathfinder {
public IPathCallBack callBackCheck;
public Set closedSet;
public Set results;
public Pathfinder(IPathCallBack callBack) {
this.callBackCheck = callBack;
this.reset();
}
public boolean findNodes(Vector3 currentNode) {
this.closedSet.add(currentNode);
if(this.callBackCheck.onSearch(this, currentNode)) {
return false;
} else {
Iterator i$ = this.callBackCheck.getConnectedNodes(this, currentNode).iterator();
Vector3 node;
do {
if(!i$.hasNext()) {
return false;
}
node = (Vector3)i$.next();
} while(this.closedSet.contains(node) || !this.findNodes(node));
return true;
}
}
public Pathfinder init(Vector3 startNode) {
this.findNodes(startNode);
return this;
}
public Pathfinder reset() {
this.closedSet = new HashSet();
this.results = new HashSet();
return this;
}
}

View file

@ -1,112 +0,0 @@
package universalelectricity.core.path;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.path.IPathCallBack;
import universalelectricity.core.path.Pathfinder;
import universalelectricity.core.vector.Vector3;
public class PathfinderAStar extends Pathfinder {
public IPathCallBack callBackCheck;
public Set openSet;
public HashMap navigationMap;
public HashMap gScore;
public HashMap fScore;
public Vector3 goal;
public PathfinderAStar(IPathCallBack callBack, Vector3 goal) {
super(callBack);
this.goal = goal;
}
public boolean findNodes(Vector3 start) {
this.openSet.add(start);
this.gScore.put(start, Double.valueOf(0.0D));
this.fScore.put(start, Double.valueOf(((Double)this.gScore.get(start)).doubleValue() + this.getHeuristicEstimatedCost(start, this.goal)));
while(!this.openSet.isEmpty()) {
Vector3 currentNode = null;
double lowestFScore = 0.0D;
Iterator i$ = this.openSet.iterator();
Vector3 neighbor;
while(i$.hasNext()) {
neighbor = (Vector3)i$.next();
if(currentNode == null || ((Double)this.fScore.get(neighbor)).doubleValue() < lowestFScore) {
currentNode = neighbor;
lowestFScore = ((Double)this.fScore.get(neighbor)).doubleValue();
}
}
if(currentNode == null) {
break;
}
if(this.callBackCheck.onSearch(this, currentNode)) {
return false;
}
if(currentNode.equals(this.goal)) {
super.results = this.reconstructPath(this.navigationMap, this.goal);
return true;
}
this.openSet.remove(currentNode);
super.closedSet.add(currentNode);
i$ = this.getNeighborNodes(currentNode).iterator();
while(i$.hasNext()) {
neighbor = (Vector3)i$.next();
double tentativeGScore = ((Double)this.gScore.get(currentNode)).doubleValue() + currentNode.distanceTo(neighbor);
if((!super.closedSet.contains(neighbor) || tentativeGScore < ((Double)this.gScore.get(neighbor)).doubleValue()) && (!this.openSet.contains(neighbor) || tentativeGScore < ((Double)this.gScore.get(neighbor)).doubleValue())) {
this.navigationMap.put(neighbor, currentNode);
this.gScore.put(neighbor, Double.valueOf(tentativeGScore));
this.fScore.put(neighbor, Double.valueOf(((Double)this.gScore.get(neighbor)).doubleValue() + this.getHeuristicEstimatedCost(neighbor, this.goal)));
this.openSet.add(neighbor);
}
}
}
return false;
}
public Pathfinder reset() {
this.openSet = new HashSet();
this.navigationMap = new HashMap();
return super.reset();
}
public Set reconstructPath(HashMap nagivationMap, Vector3 current_node) {
HashSet path = new HashSet();
path.add(current_node);
if(nagivationMap.containsKey(current_node)) {
path.addAll(this.reconstructPath(nagivationMap, (Vector3)nagivationMap.get(current_node)));
return path;
} else {
return path;
}
}
public double getHeuristicEstimatedCost(Vector3 start, Vector3 goal) {
return start.distanceTo(goal);
}
public Set getNeighborNodes(Vector3 vector) {
if(this.callBackCheck != null) {
return this.callBackCheck.getConnectedNodes(this, vector);
} else {
HashSet neighbors = new HashSet();
for(int i = 0; i < 6; ++i) {
neighbors.add(vector.clone().modifyPositionFromSide(ForgeDirection.getOrientation(i)));
}
return neighbors;
}
}
}

View file

@ -1,43 +0,0 @@
package universalelectricity.core.path;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.path.IPathCallBack;
import universalelectricity.core.path.Pathfinder;
import universalelectricity.core.vector.Vector3;
public class PathfinderChecker extends Pathfinder {
public PathfinderChecker(final World world, final IConnectionProvider targetConnector, final IConnectionProvider ... ignoreConnector) {
super(new IPathCallBack() {
public Set getConnectedNodes(Pathfinder finder, Vector3 currentNode) {
HashSet neighbors = new HashSet();
for(int i = 0; i < 6; ++i) {
ForgeDirection direction = ForgeDirection.getOrientation(i);
Vector3 position = currentNode.clone().modifyPositionFromSide(direction);
TileEntity connectedBlock = position.getTileEntity(world);
if(connectedBlock instanceof IConductor && !Arrays.asList(ignoreConnector).contains(connectedBlock) && ((IConductor)connectedBlock).canConnect(direction.getOpposite())) {
neighbors.add(position);
}
}
return neighbors;
}
public boolean onSearch(Pathfinder finder, Vector3 node) {
if(node.getTileEntity(world) == targetConnector) {
finder.results.add(node);
return true;
} else {
return false;
}
}
});
}
}

View file

@ -1,101 +0,0 @@
package universalelectricity.core.vector;
import net.minecraft.util.MathHelper;
public class Vector2 implements Cloneable {
public double x;
public double y;
public Vector2() {
this(0.0D, 0.0D);
}
public Vector2(double x, double y) {
this.x = x;
this.y = y;
}
public int intX() {
return (int)Math.floor(this.x);
}
public int intY() {
return (int)Math.floor(this.y);
}
public Vector2 clone() {
return new Vector2(this.x, this.y);
}
public static double distance(Vector2 point1, Vector2 point2) {
double xDifference = point1.x - point2.x;
double yDiference = point1.y - point2.y;
return (double)MathHelper.sqrt_double(xDifference * xDifference + yDiference * yDiference);
}
public static double slope(Vector2 point1, Vector2 point2) {
double xDifference = point1.x - point2.x;
double yDiference = point1.y - point2.y;
return yDiference / xDifference;
}
public double distanceTo(Vector2 target) {
double xDifference = this.x - target.x;
double yDifference = this.y - target.y;
return (double)MathHelper.sqrt_double(xDifference * xDifference + yDifference * yDifference);
}
public Vector2 add(Vector2 par1) {
this.x += par1.x;
this.y += par1.y;
return this;
}
public Vector2 add(double par1) {
this.x += par1;
this.y += par1;
return this;
}
public Vector2 invert() {
this.multiply(-1.0D);
return this;
}
public Vector2 multiply(double amount) {
this.x *= amount;
this.y *= amount;
return this;
}
public Vector2 round() {
return new Vector2((double)Math.round(this.x), (double)Math.round(this.y));
}
public Vector2 ceil() {
return new Vector2(Math.ceil(this.x), Math.ceil(this.y));
}
public Vector2 floor() {
return new Vector2(Math.floor(this.x), Math.floor(this.y));
}
public int hashCode() {
return ("X:" + this.x + "Y:" + this.y).hashCode();
}
public boolean equals(Object o) {
if(!(o instanceof Vector2)) {
return false;
} else {
Vector2 vector = (Vector2)o;
return this.x == vector.x && this.y == vector.y;
}
}
public String toString() {
return "Vector2 [" + this.x + "," + this.y + "]";
}
}

View file

@ -1,286 +0,0 @@
package universalelectricity.core.vector;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class Vector3 implements Cloneable {
public double x;
public double y;
public double z;
public Vector3() {
this(0.0D, 0.0D, 0.0D);
}
public Vector3(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vector3(Entity par1) {
this.x = par1.posX;
this.y = par1.posY;
this.z = par1.posZ;
}
public Vector3(TileEntity par1) {
this.x = (double)par1.xCoord;
this.y = (double)par1.yCoord;
this.z = (double)par1.zCoord;
}
public Vector3(Vec3 par1) {
this.x = par1.xCoord;
this.y = par1.yCoord;
this.z = par1.zCoord;
}
public Vector3(MovingObjectPosition par1) {
this.x = (double)par1.blockX;
this.y = (double)par1.blockY;
this.z = (double)par1.blockZ;
}
public Vector3(ChunkCoordinates par1) {
this.x = (double)par1.posX;
this.y = (double)par1.posY;
this.z = (double)par1.posZ;
}
public Vector3(ForgeDirection direction) {
this.x = (double)direction.offsetX;
this.y = (double)direction.offsetY;
this.z = (double)direction.offsetZ;
}
public int intX() {
return (int)Math.floor(this.x);
}
public int intY() {
return (int)Math.floor(this.y);
}
public int intZ() {
return (int)Math.floor(this.z);
}
public Vector3 clone() {
return new Vector3(this.x, this.y, this.z);
}
public Block getBlock(IBlockAccess world) {
return world.getBlock(this.intX(), this.intY(), this.intZ());
}
public int getBlockMetadata(IBlockAccess world) {
return world.getBlockMetadata(this.intX(), this.intY(), this.intZ());
}
public TileEntity getTileEntity(IBlockAccess world) {
return world.getTileEntity(this.intX(), this.intY(), this.intZ());
}
public boolean setBlock(World world, Block block, int metadata, int notify) {
return world.setBlock(this.intX(), this.intY(), this.intZ(), block, metadata, notify);
}
public boolean setBlock(World world, Block block, int metadata) {
return this.setBlock(world, block, metadata, 3);
}
public boolean setBlock(World world, Block block) {
return this.setBlock(world, block, 0);
}
public Vector2 toVector2() {
return new Vector2(this.x, this.z);
}
public Vec3 toVec3() {
return Vec3.createVectorHelper(this.x, this.y, this.z);
}
public double getMagnitude() {
return Math.sqrt(this.getMagnitudeSquared());
}
public double getMagnitudeSquared() {
return this.x * this.x + this.y * this.y + this.z * this.z;
}
public Vector3 normalize() {
double d = this.getMagnitude();
if(d != 0.0D) {
this.multiply(1.0D / d);
}
return this;
}
public static double distance(Vector3 par1, Vector3 par2) {
double var2 = par1.x - par2.x;
double var4 = par1.y - par2.y;
double var6 = par1.z - par2.z;
return (double)MathHelper.sqrt_double(var2 * var2 + var4 * var4 + var6 * var6);
}
public double distanceTo(Vector3 vector3) {
double var2 = vector3.x - this.x;
double var4 = vector3.y - this.y;
double var6 = vector3.z - this.z;
return (double)MathHelper.sqrt_double(var2 * var2 + var4 * var4 + var6 * var6);
}
public Vector3 add(Vector3 par1) {
this.x += par1.x;
this.y += par1.y;
this.z += par1.z;
return this;
}
public Vector3 add(double par1) {
this.x += par1;
this.y += par1;
this.z += par1;
return this;
}
public Vector3 subtract(Vector3 amount) {
this.x -= amount.x;
this.y -= amount.y;
this.z -= amount.z;
return this;
}
public Vector3 invert() {
this.multiply(-1.0D);
return this;
}
public Vector3 multiply(double amount) {
this.x *= amount;
this.y *= amount;
this.z *= amount;
return this;
}
public Vector3 multiply(Vector3 vec) {
this.x *= vec.x;
this.y *= vec.y;
this.z *= vec.z;
return this;
}
public static Vector3 subtract(Vector3 par1, Vector3 par2) {
return new Vector3(par1.x - par2.x, par1.y - par2.y, par1.z - par2.z);
}
public static Vector3 add(Vector3 par1, Vector3 par2) {
return new Vector3(par1.x + par2.x, par1.y + par2.y, par1.z + par2.z);
}
public static Vector3 add(Vector3 par1, double par2) {
return new Vector3(par1.x + par2, par1.y + par2, par1.z + par2);
}
public static Vector3 multiply(Vector3 vec1, Vector3 vec2) {
return new Vector3(vec1.x * vec2.x, vec1.y * vec2.y, vec1.z * vec2.z);
}
public static Vector3 multiply(Vector3 vec1, double vec2) {
return new Vector3(vec1.x * vec2, vec1.y * vec2, vec1.z * vec2);
}
public Vector3 round() {
return new Vector3((double)Math.round(this.x), (double)Math.round(this.y), (double)Math.round(this.z));
}
public Vector3 ceil() {
return new Vector3(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z));
}
public Vector3 floor() {
return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
}
public List getEntitiesWithin(World worldObj, Class par1Class) {
return worldObj.getEntitiesWithinAABB(par1Class, AxisAlignedBB.getBoundingBox((double)this.intX(), (double)this.intY(), (double)this.intZ(), (double)(this.intX() + 1), (double)(this.intY() + 1), (double)(this.intZ() + 1)));
}
public Vector3 modifyPositionFromSide(ForgeDirection side, double amount) {
switch(side.ordinal()) {
case 0:
this.y -= amount;
break;
case 1:
this.y += amount;
break;
case 2:
this.z -= amount;
break;
case 3:
this.z += amount;
break;
case 4:
this.x -= amount;
break;
case 5:
this.x += amount;
}
return this;
}
public Vector3 modifyPositionFromSide(ForgeDirection side) {
this.modifyPositionFromSide(side, 1.0D);
return this;
}
public static Vector3 readFromNBT(NBTTagCompound nbtCompound) {
Vector3 tempVector = new Vector3();
tempVector.x = nbtCompound.getDouble("x");
tempVector.y = nbtCompound.getDouble("y");
tempVector.z = nbtCompound.getDouble("z");
return tempVector;
}
public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound) {
par1NBTTagCompound.setDouble("x", this.x);
par1NBTTagCompound.setDouble("y", this.y);
par1NBTTagCompound.setDouble("z", this.z);
return par1NBTTagCompound;
}
public int hashCode() {
return ("X:" + this.x + "Y:" + this.y + "Z:" + this.z).hashCode();
}
public boolean equals(Object o) {
if(!(o instanceof Vector3)) {
return false;
} else {
Vector3 vector3 = (Vector3)o;
return this.x == vector3.x && this.y == vector3.y && this.z == vector3.z;
}
}
public String toString() {
return "Vector3 [" + this.x + "," + this.y + "," + this.z + "]";
}
}

View file

@ -1,26 +0,0 @@
package universalelectricity.core.vector;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IConnector;
public class VectorHelper {
public static final int[][] RELATIVE_MATRIX = new int[][]{{3, 2, 1, 0, 5, 4}, {4, 5, 0, 1, 2, 3}, {0, 1, 3, 2, 4, 5}, {0, 1, 2, 3, 5, 4}, {0, 1, 5, 4, 3, 2}, {0, 1, 4, 5, 2, 3}};
public static ForgeDirection getOrientationFromSide(ForgeDirection front, ForgeDirection side) {
return front != ForgeDirection.UNKNOWN && side != ForgeDirection.UNKNOWN?ForgeDirection.getOrientation(RELATIVE_MATRIX[front.ordinal()][side.ordinal()]):ForgeDirection.UNKNOWN;
}
public static TileEntity getConnectorFromSide(World world, Vector3 position, ForgeDirection side) {
TileEntity tileEntity = getTileEntityFromSide(world, position, side);
return tileEntity instanceof IConnector && ((IConnector)tileEntity).canConnect(getOrientationFromSide(side, ForgeDirection.NORTH))?tileEntity:null;
}
public static TileEntity getTileEntityFromSide(World world, Vector3 position, ForgeDirection side) {
return position.clone().modifyPositionFromSide(side).getTileEntity(world);
}
}

View file

@ -1,32 +0,0 @@
package universalelectricity.prefab;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.util.DamageSource;
public class CustomDamageSource extends DamageSource {
public static final CustomDamageSource electrocution = ((CustomDamageSource)(new CustomDamageSource("electrocution")).setDamageBypassesArmor()).setDeathMessage("%1$s got electrocuted!");
public CustomDamageSource(String damageType) {
super(damageType);
}
public CustomDamageSource setDeathMessage(String deathMessage) {
LanguageRegistry.instance().addStringLocalization("death.attack." + super.damageType, deathMessage);
return this;
}
public DamageSource setDamageBypassesArmor() {
return super.setDamageBypassesArmor();
}
public DamageSource setDamageAllowedInCreativeMode() {
return super.setDamageAllowedInCreativeMode();
}
public DamageSource setFireDamage() {
return super.setFireDamage();
}
}

View file

@ -1,131 +0,0 @@
package universalelectricity.prefab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public abstract class GuiBase extends GuiScreen {
protected int xSize = 176;
protected int ySize = 166;
protected int guiLeft;
protected int guiTop;
public void initGui() {
super.initGui();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
int var4 = this.guiLeft;
int var5 = this.guiTop;
this.drawBackgroundLayer(par1, par2, par3);
GL11.glPushMatrix();
GL11.glTranslatef((float)var4, (float)var5, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable('\u803a');
short var7 = 240;
short var8 = 240;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var7 / 1.0F, (float)var8 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawForegroundLayer(par1, par2, par3);
GL11.glDisable('\u803a');
GL11.glDisable(2896);
GL11.glDisable(2929);
GL11.glPopMatrix();
super.drawScreen(par1, par2, par3);
GL11.glEnable(2896);
GL11.glEnable(2929);
}
protected abstract void drawForegroundLayer(int var1, int var2, float var3);
protected abstract void drawBackgroundLayer(int var1, int var2, float var3);
protected void keyTyped(char x, int y) {
if(y == 1 || y == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
this.mc.thePlayer.closeScreen();
}
}
public boolean doesGuiPauseGame() {
return false;
}
public void updateScreen() {
super.updateScreen();
if(!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead) {
this.mc.thePlayer.closeScreen();
}
}
public void drawTooltip(int x, int y, String ... toolTips) {
GL11.glDisable('\u803a');
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2896);
GL11.glDisable(2929);
if(toolTips != null) {
int var5 = 0;
int var6;
int var7;
for(var6 = 0; var6 < toolTips.length; ++var6) {
var7 = this.fontRendererObj.getStringWidth(toolTips[var6]);
if(var7 > var5) {
var5 = var7;
}
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if(toolTips.length > 1) {
var9 += 2 + (toolTips.length - 1) * 10;
}
if(this.guiTop + var7 + var9 + 6 > this.height) {
var7 = this.height - var9 - this.guiTop - 6;
}
super.zLevel = 300.0F;
int var10 = -267386864;
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10);
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10);
int var11 = 1347420415;
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11);
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
for(int var13 = 0; var13 < toolTips.length; ++var13) {
String var14 = toolTips[var13];
this.fontRendererObj.drawStringWithShadow(var14, var6, var7, -1);
if(var13 == 0) {
var7 += 2;
}
var7 += 10;
}
super.zLevel = 0.0F;
}
GL11.glEnable(2929);
GL11.glEnable(2896);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable('\u803a');
}
}

View file

@ -1,131 +0,0 @@
package universalelectricity.prefab;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.config.Configuration;
public class RecipeHelper {
public static List getRecipesByOutput(ItemStack output) {
ArrayList list = new ArrayList();
Iterator i$ = CraftingManager.getInstance().getRecipeList().iterator();
while(i$.hasNext()) {
Object obj = i$.next();
if(obj instanceof IRecipe && ((IRecipe)obj).getRecipeOutput() == output) {
list.add((IRecipe)obj);
}
}
return list;
}
public static boolean replaceRecipe(IRecipe recipe, IRecipe newRecipe) {
Iterator i$ = CraftingManager.getInstance().getRecipeList().iterator();
Object obj;
do {
do {
if(!i$.hasNext()) {
return false;
}
obj = i$.next();
} while(!(obj instanceof IRecipe));
} while(!((IRecipe)obj).equals(recipe) && obj != recipe);
CraftingManager.getInstance().getRecipeList().remove(obj);
CraftingManager.getInstance().getRecipeList().add(newRecipe);
return true;
}
public static boolean replaceRecipe(ItemStack recipe, IRecipe newRecipe) {
if(removeRecipe(recipe)) {
CraftingManager.getInstance().getRecipeList().add(newRecipe);
return true;
} else {
return false;
}
}
public static boolean removeRecipe(IRecipe recipe) {
Iterator i$ = CraftingManager.getInstance().getRecipeList().iterator();
Object obj;
do {
do {
do {
if(!i$.hasNext()) {
return false;
}
obj = i$.next();
} while(obj == null);
} while(!(obj instanceof IRecipe));
} while(!((IRecipe)obj).equals(recipe) && obj != recipe);
CraftingManager.getInstance().getRecipeList().remove(obj);
return true;
}
public static boolean removeRecipe(ItemStack stack) {
Iterator i$ = CraftingManager.getInstance().getRecipeList().iterator();
Object obj;
do {
if(!i$.hasNext()) {
return false;
}
obj = i$.next();
} while(obj == null || !(obj instanceof IRecipe) || ((IRecipe)obj).getRecipeOutput() == null || !((IRecipe)obj).getRecipeOutput().isItemEqual(stack));
CraftingManager.getInstance().getRecipeList().remove(obj);
return true;
}
public static boolean removeRecipes(ItemStack ... itemStacks) {
boolean didRemove = false;
Iterator itr = CraftingManager.getInstance().getRecipeList().iterator();
while(itr.hasNext()) {
Object obj = itr.next();
if(obj != null && obj instanceof IRecipe && ((IRecipe)obj).getRecipeOutput() != null) {
ItemStack[] arr$ = itemStacks;
int len$ = itemStacks.length;
for(int i$ = 0; i$ < len$; ++i$) {
ItemStack itemStack = arr$[i$];
if(((IRecipe)obj).getRecipeOutput().isItemEqual(itemStack)) {
itr.remove();
didRemove = true;
break;
}
}
}
}
return didRemove;
}
public static void addRecipe(IRecipe recipe, String name, Configuration configuration, boolean defaultBoolean) {
if(configuration != null) {
configuration.load();
if(configuration.get("Crafting", "Allow " + name + " Crafting", defaultBoolean).getBoolean(defaultBoolean)) {
GameRegistry.addRecipe(recipe);
}
configuration.save();
}
}
public static void addRecipe(IRecipe recipe, Configuration config, boolean defaultBoolean) {
addRecipe(recipe, recipe.getRecipeOutput().getUnlocalizedName(), config, defaultBoolean);
}
}

View file

@ -1,74 +0,0 @@
package universalelectricity.prefab;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotSpecific extends Slot {
public ItemStack[] validItemStacks = new ItemStack[0];
public Class[] validClasses = new Class[0];
public boolean isInverted = false;
public boolean isMetadataSensitive = false;
public SlotSpecific(IInventory par2IInventory, int par3, int par4, int par5, ItemStack ... itemStacks) {
super(par2IInventory, par3, par4, par5);
this.setItemStacks(itemStacks);
}
public SlotSpecific(IInventory par2IInventory, int par3, int par4, int par5, Class ... validClasses) {
super(par2IInventory, par3, par4, par5);
this.setClasses(validClasses);
}
public SlotSpecific setMetadataSensitive() {
this.isMetadataSensitive = true;
return this;
}
public SlotSpecific setItemStacks(ItemStack ... validItemStacks) {
this.validItemStacks = validItemStacks;
return this;
}
public SlotSpecific setClasses(Class ... validClasses) {
this.validClasses = validClasses;
return this;
}
public SlotSpecific toggleInverted() {
this.isInverted = !this.isInverted;
return this;
}
public boolean isItemValid(ItemStack compareStack) {
boolean returnValue = false;
ItemStack[] arr$ = this.validItemStacks;
int len$ = arr$.length;
int i$;
for(i$ = 0; i$ < len$; ++i$) {
ItemStack clazz = arr$[i$];
if(compareStack.isItemEqual(clazz) || !this.isMetadataSensitive && compareStack.getItem() == clazz.getItem()) {
returnValue = true;
break;
}
}
if(!returnValue) {
Class[] var7 = this.validClasses;
len$ = var7.length;
for(i$ = 0; i$ < len$; ++i$) {
Class var8 = var7[i$];
if(var8.equals(compareStack.getItem().getClass()) || var8.isInstance(compareStack.getItem())) {
returnValue = true;
break;
}
}
}
return this.isInverted?!returnValue:returnValue;
}
}

View file

@ -1,49 +0,0 @@
package universalelectricity.prefab;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class TranslationHelper {
public static int loadLanguages(String languagePath, String[] languageSupported) {
int languages = 0;
String[] arr$ = languageSupported;
int len$ = languageSupported.length;
for(int i$ = 0; i$ < len$; ++i$) {
String language = arr$[i$];
LanguageRegistry.instance().loadLocalization(languagePath + language + ".properties", language, false);
if(LanguageRegistry.instance().getStringLocalization("children", language) != "") {
try {
String[] e = LanguageRegistry.instance().getStringLocalization("children", language).split(",");
String[] arr$1 = e;
int len$1 = e.length;
for(int i$1 = 0; i$1 < len$1; ++i$1) {
String child = arr$1[i$1];
if(child != "" || child != null) {
LanguageRegistry.instance().loadLocalization(languagePath + language + ".properties", child, false);
++languages;
}
}
} catch (Exception var12) {
FMLLog.severe("Failed to load a child language file.", new Object[0]);
var12.printStackTrace();
}
}
++languages;
}
return languages;
}
public static String getLocal(String key) {
String text = LanguageRegistry.instance().getStringLocalization(key);
if(text == null || text == "") {
text = LanguageRegistry.instance().getStringLocalization(key, "en_US");
}
return text;
}
}

View file

@ -1,149 +0,0 @@
package universalelectricity.prefab.block;
import java.lang.reflect.Method;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public abstract class BlockAdvanced extends BlockContainer {
public BlockAdvanced(Material material) {
super(material);
this.setHardness(0.6F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
world.getBlockMetadata(x, y, z);
if(this.isUsableWrench(entityPlayer, entityPlayer.inventory.getCurrentItem(), x, y, z)) {
this.damageWrench(entityPlayer, entityPlayer.inventory.getCurrentItem(), x, y, z);
if(entityPlayer.isSneaking() && this.onSneakUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ)) {
return true;
}
if(this.onUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ)) {
return true;
}
}
return entityPlayer.isSneaking() && this.onSneakMachineActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ)?true:this.onMachineActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ);
}
public boolean isUsableWrench(EntityPlayer entityPlayer, ItemStack itemStack, int x, int y, int z) {
if(entityPlayer != null && itemStack != null) {
Class wrenchClass = itemStack.getItem().getClass();
try {
Method e = wrenchClass.getMethod("canWrench", new Class[]{EntityPlayer.class, Integer.TYPE, Integer.TYPE, Integer.TYPE});
return ((Boolean)e.invoke(itemStack.getItem(), new Object[]{entityPlayer, Integer.valueOf(x), Integer.valueOf(y), Integer.valueOf(z)})).booleanValue();
} catch (NoClassDefFoundError var8) {
;
} catch (Exception var9) {
;
}
try {
if(wrenchClass == Class.forName("ic2.core.item.tool.ItemToolWrench") || wrenchClass == Class.forName("ic2.core.item.tool.ItemToolWrenchElectric")) {
return itemStack.getItemDamage() < itemStack.getMaxDamage();
}
} catch (Exception var10) {
;
}
}
return false;
}
public boolean damageWrench(EntityPlayer entityPlayer, ItemStack itemStack, int x, int y, int z) {
if(this.isUsableWrench(entityPlayer, itemStack, x, y, z)) {
Class wrenchClass = itemStack.getItem().getClass();
Method e;
try {
e = wrenchClass.getMethod("wrenchUsed", new Class[]{EntityPlayer.class, Integer.TYPE, Integer.TYPE, Integer.TYPE});
e.invoke(itemStack.getItem(), new Object[]{entityPlayer, Integer.valueOf(x), Integer.valueOf(y), Integer.valueOf(z)});
return true;
} catch (Exception var9) {
try {
if(wrenchClass == Class.forName("ic2.core.item.tool.ItemToolWrench") || wrenchClass == Class.forName("ic2.core.item.tool.ItemToolWrenchElectric")) {
e = wrenchClass.getMethod("damage", new Class[]{ItemStack.class, Integer.TYPE, EntityPlayer.class});
e.invoke(itemStack.getItem(), new Object[]{itemStack, Integer.valueOf(1), entityPlayer});
return true;
}
} catch (Exception var8) {
;
}
}
}
return false;
}
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
return false;
}
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
return false;
}
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
return false;
}
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
return this.onUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
this.dropEntireInventory(world, x, y, z, par5, par6);
super.breakBlock(world, x, y, z, par5, par6);
}
public void dropEntireInventory(World world, int x, int y, int z, Block par5, int par6) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if(tileEntity != null && tileEntity instanceof IInventory) {
IInventory inventory = (IInventory)tileEntity;
for(int var6 = 0; var6 < inventory.getSizeInventory(); ++var6) {
ItemStack var7 = inventory.getStackInSlot(var6);
if(var7 != null) {
Random random = new Random();
float var8 = random.nextFloat() * 0.8F + 0.1F;
float var9 = random.nextFloat() * 0.8F + 0.1F;
float var10 = random.nextFloat() * 0.8F + 0.1F;
while(var7.stackSize > 0) {
int var11 = random.nextInt(21) + 10;
if(var11 > var7.stackSize) {
var11 = var7.stackSize;
}
var7.stackSize -= var11;
EntityItem var12 = new EntityItem(world, (double)((float)x + var8), (double)((float)y + var9), (double)((float)z + var10), new ItemStack(var7.getItem(), var11, var7.getItemDamage()));
if(var7.hasTagCompound()) {
var12.getEntityItem().setTagCompound((NBTTagCompound)var7.getTagCompound().copy());
}
float var13 = 0.05F;
var12.motionX = (double)((float)random.nextGaussian() * var13);
var12.motionY = (double)((float)random.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)random.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
}
}
}
}

View file

@ -1,34 +0,0 @@
package universalelectricity.prefab.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.block.IConductor;
public abstract class BlockConductor extends BlockContainer {
public BlockConductor(Material material) {
super(material);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
TileEntity tileEntity = world.getTileEntity(x, y, z);
if(tileEntity instanceof IConductor) {
((IConductor)tileEntity).updateAdjacentConnections();
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block blockID) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if(tileEntity instanceof IConductor) {
((IConductor)tileEntity).updateAdjacentConnections();
}
}
}

View file

@ -1,52 +0,0 @@
package universalelectricity.prefab.block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRotatable;
public abstract class BlockRotatable extends BlockAdvanced implements IRotatable {
public BlockRotatable(Material material) {
super(material);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
int angle = MathHelper.floor_double((double)(entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
byte change = 3;
switch(angle) {
case 0:
change = 2;
break;
case 1:
change = 5;
break;
case 2:
change = 3;
break;
case 3:
change = 4;
}
this.setDirection(world, x, y, z, ForgeDirection.getOrientation(change));
}
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
this.setDirection(world, x, y, z, ForgeDirection.getOrientation(ForgeDirection.ROTATION_MATRIX[0][this.getDirection(world, x, y, z).ordinal()]));
return true;
}
public ForgeDirection getDirection(IBlockAccess world, int x, int y, int z) {
return ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
}
public void setDirection(World world, int x, int y, int z, ForgeDirection facingDirection) {
world.setBlockMetadataWithNotify(x, y, z, facingDirection.ordinal(), 3);
}
}

View file

@ -1,9 +0,0 @@
package universalelectricity.prefab.implement;
public interface IDisableable {
void onDisable(int var1);
boolean isDisabled();
}

View file

@ -1,10 +0,0 @@
package universalelectricity.prefab.implement;
import net.minecraftforge.common.util.ForgeDirection;
public interface IRedstoneProvider {
boolean isPoweringTo(ForgeDirection var1);
boolean isIndirectlyPoweringTo(ForgeDirection var1);
}

View file

@ -1,9 +0,0 @@
package universalelectricity.prefab.implement;
public interface IRedstoneReceptor {
void onPowerOn();
void onPowerOff();
}

View file

@ -1,12 +0,0 @@
package universalelectricity.prefab.implement;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IRotatable {
ForgeDirection getDirection(IBlockAccess var1, int var2, int var3, int var4);
void setDirection(World var1, int var2, int var3, int var4, ForgeDirection var5);
}

View file

@ -1,9 +0,0 @@
package universalelectricity.prefab.implement;
public interface ITier {
int getTier();
void setTier(int var1);
}

View file

@ -1,10 +0,0 @@
package universalelectricity.prefab.implement;
import net.minecraft.entity.player.EntityPlayer;
public interface IToolConfigurator {
boolean canWrench(EntityPlayer var1, int var2, int var3, int var4);
void wrenchUsed(EntityPlayer var1, int var2, int var3, int var4);
}

View file

@ -1,109 +0,0 @@
package universalelectricity.prefab.multiblock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.vector.Vector3;
public class BlockMulti extends BlockContainer {
public String textureName = null;
public String channel = "";
public BlockMulti() {
super(UniversalElectricity.machine);
this.setHardness(0.8F);
this.setBlockName("multiBlock");
}
public BlockMulti setChannel(String channel) {
this.channel = channel;
return this;
}
public BlockMulti setTextureName(String name) {
this.textureName = name;
return this;
}
public void makeFakeBlock(World worldObj, Vector3 position, Vector3 mainBlock) {
worldObj.setBlock(position.intX(), position.intY(), position.intZ(), this);
((TileEntityMulti)worldObj.getTileEntity(position.intX(), position.intY(), position.intZ())).setMainBlock(mainBlock);
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
if(this.textureName != null) {
this.blockIcon = iconRegister.registerIcon(this.textureName);
} else {
super.registerBlockIcons(iconRegister);
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if(tileEntity instanceof TileEntityMulti) {
((TileEntityMulti)tileEntity).onBlockRemoval();
}
super.breakBlock(world, x, y, z, par5, par6);
}
@Override
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
TileEntityMulti tileEntity = (TileEntityMulti)par1World.getTileEntity(x, y, z);
return tileEntity.onBlockActivated(par1World, x, y, z, par5EntityPlayer);
}
@Override
public int quantityDropped(Random par1Random) {
return 0;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(World var1, int meta) {
return new TileEntityMulti(this.channel);
}
public ItemStack getPickBlock(MovingObjectPosition target, World par1World, int x, int y, int z) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
Vector3 mainBlockPosition = ((TileEntityMulti)tileEntity).mainBlockPosition;
if(mainBlockPosition != null) {
Block mainBlockID = par1World.getBlock(mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
if(mainBlockID != Blocks.air) {
return mainBlockID.getPickBlock(target, par1World, mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
}
}
return null;
}
}

View file

@ -1,8 +0,0 @@
package universalelectricity.prefab.multiblock;
import net.minecraft.entity.player.EntityPlayer;
public interface IBlockActivate {
boolean onActivated(EntityPlayer var1);
}

View file

@ -1,12 +0,0 @@
package universalelectricity.prefab.multiblock;
import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.IBlockActivate;
public interface IMultiBlock extends IBlockActivate {
void onCreate(Vector3 var1);
void onDestroy(TileEntity var1);
}

View file

@ -1,91 +0,0 @@
package universalelectricity.prefab.multiblock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
public class TileEntityMulti extends TileEntity {
public Vector3 mainBlockPosition;
public String channel;
public TileEntityMulti() {}
public TileEntityMulti(String channel) {
this.channel = channel;
}
public void setMainBlock(Vector3 mainBlock) {
this.mainBlockPosition = mainBlock;
if(!this.worldObj.isRemote) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
}
@Override
public Packet getDescriptionPacket() {
if(this.mainBlockPosition == null) {
return null;
} else {
NBTTagCompound nbt = this.mainBlockPosition.writeToNBT(new NBTTagCompound());
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(),nbt);
}
}
public void onBlockRemoval() {
if(this.mainBlockPosition != null) {
TileEntity tileEntity = this.worldObj.getTileEntity(this.mainBlockPosition.intX(), this.mainBlockPosition.intY(), this.mainBlockPosition.intZ());
if(tileEntity != null && tileEntity instanceof IMultiBlock) {
IMultiBlock mainBlock = (IMultiBlock)tileEntity;
if(mainBlock != null) {
mainBlock.onDestroy(this);
}
}
}
}
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer) {
if(this.mainBlockPosition != null) {
TileEntity tileEntity = this.worldObj.getTileEntity(this.mainBlockPosition.intX(), this.mainBlockPosition.intY(), this.mainBlockPosition.intZ());
if(tileEntity != null && tileEntity instanceof IMultiBlock) {
return ((IMultiBlock)tileEntity).onActivated(par5EntityPlayer);
}
}
return false;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.mainBlockPosition = Vector3.readFromNBT(nbt.getCompoundTag("mainBlockPosition"));
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
if(this.mainBlockPosition != null) {
nbt.setTag("mainBlockPosition", this.mainBlockPosition.writeToNBT(new NBTTagCompound()));
}
}
public boolean canUpdate() {
return false;
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbt = pkt.func_148857_g();
this.mainBlockPosition = Vector3.readFromNBT(nbt);
}
}

View file

@ -1,60 +0,0 @@
package universalelectricity.prefab.ore;
import cpw.mods.fml.common.FMLLog;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.oredict.OreDictionary;
public abstract class OreGenBase {
public String name;
public String oreDictionaryName;
public boolean shouldGenerate = false;
public int blockIndexTexture;
public ItemStack oreStack;
public Block oreID;
public int oreMeta;
public int harvestLevel;
public String harvestTool;
public OreGenBase(String name, String oreDiectionaryName, ItemStack stack, String harvestTool, int harvestLevel) {
if(stack != null) {
this.name = name;
this.harvestTool = harvestTool;
this.harvestLevel = harvestLevel;
this.oreDictionaryName = oreDiectionaryName;
this.oreStack = stack;
this.oreID = Block.getBlockFromItem(stack.getItem());
this.oreMeta = stack.getItemDamage();
OreDictionary.registerOre(this.oreDictionaryName, stack);
oreID.setHarvestLevel(harvestTool, harvestLevel, stack.getItemDamage());
} else {
FMLLog.severe("ItemStack is null while registering ore generation!", new Object[0]);
}
}
public OreGenBase enable(Configuration config) {
this.shouldGenerate = shouldGenerateOre(config, this.name);
return this;
}
private static boolean shouldGenerateOre(Configuration configuration, String oreName) {
configuration.load();
boolean shouldGenerate = configuration.get("Ore_Generation", "Generate " + oreName, true).getBoolean(true);
configuration.save();
return shouldGenerate;
}
public abstract void generate(World var1, Random var2, int var3, int var4);
public abstract boolean isOreGeneratedInWorld(World var1, IChunkProvider var2);
}

View file

@ -1,99 +0,0 @@
package universalelectricity.prefab.ore;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderEnd;
import net.minecraft.world.gen.ChunkProviderGenerate;
import net.minecraft.world.gen.ChunkProviderHell;
public class OreGenReplace extends OreGenBase {
public int minGenerateLevel;
public int maxGenerateLevel;
public int amountPerChunk;
public int amountPerBranch;
public Block replaceID;
public boolean ignoreSurface = false;
public boolean ignoreNether = true;
public boolean ignoreEnd = true;
public OreGenReplace(String name, String oreDiectionaryName, ItemStack stack, Block replaceID, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel) {
super(name, oreDiectionaryName, stack, harvestTool, harvestLevel);
this.minGenerateLevel = minGenerateLevel;
this.maxGenerateLevel = maxGenerateLevel;
this.amountPerChunk = amountPerChunk;
this.amountPerBranch = amountPerBranch;
this.replaceID = replaceID;
}
public void generate(World world, Random random, int varX, int varZ) {
try {
for(int e = 0; e < this.amountPerChunk; ++e) {
int x = varX + random.nextInt(16);
int z = varZ + random.nextInt(16);
int y = random.nextInt(Math.max(this.maxGenerateLevel - this.minGenerateLevel, 0)) + this.minGenerateLevel;
this.generateReplace(world, random, x, y, z);
}
} catch (Exception var9) {
System.out.println("Error generating ore: " + super.name);
var9.printStackTrace();
}
}
public boolean generateReplace(World par1World, Random par2Random, int par3, int par4, int par5) {
float var6 = par2Random.nextFloat() * 3.1415927F;
double var7 = (double)((float)(par3 + 8) + MathHelper.sin(var6) * (float)this.amountPerBranch / 8.0F);
double var9 = (double)((float)(par3 + 8) - MathHelper.sin(var6) * (float)this.amountPerBranch / 8.0F);
double var11 = (double)((float)(par5 + 8) + MathHelper.cos(var6) * (float)this.amountPerBranch / 8.0F);
double var13 = (double)((float)(par5 + 8) - MathHelper.cos(var6) * (float)this.amountPerBranch / 8.0F);
double var15 = (double)(par4 + par2Random.nextInt(3) - 2);
double var17 = (double)(par4 + par2Random.nextInt(3) - 2);
for(int var19 = 0; var19 <= this.amountPerBranch; ++var19) {
double var20 = var7 + (var9 - var7) * (double)var19 / (double)this.amountPerBranch;
double var22 = var15 + (var17 - var15) * (double)var19 / (double)this.amountPerBranch;
double var24 = var11 + (var13 - var11) * (double)var19 / (double)this.amountPerBranch;
double var26 = par2Random.nextDouble() * (double)this.amountPerBranch / 16.0D;
double var28 = (double)(MathHelper.sin((float)var19 * 3.1415927F / (float)this.amountPerBranch) + 1.0F) * var26 + 1.0D;
double var30 = (double)(MathHelper.sin((float)var19 * 3.1415927F / (float)this.amountPerBranch) + 1.0F) * var26 + 1.0D;
int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
for(int var38 = var32; var38 <= var35; ++var38) {
double var39 = ((double)var38 + 0.5D - var20) / (var28 / 2.0D);
if(var39 * var39 < 1.0D) {
for(int var41 = var33; var41 <= var36; ++var41) {
double var42 = ((double)var41 + 0.5D - var22) / (var30 / 2.0D);
if(var39 * var39 + var42 * var42 < 1.0D) {
for(int var44 = var34; var44 <= var37; ++var44) {
double var45 = ((double)var44 + 0.5D - var24) / (var28 / 2.0D);
Block block = par1World.getBlock(var38, var41, var44);
if(var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (this.replaceID == Blocks.air || block == this.replaceID)) {
par1World.setBlock(var38, var41, var44, super.oreID, super.oreMeta, 2);
}
}
}
}
}
}
}
return true;
}
public boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator) {
return !super.shouldGenerate?false:(this.ignoreSurface && chunkGenerator instanceof ChunkProviderGenerate?false:(this.ignoreNether && chunkGenerator instanceof ChunkProviderHell?false:!this.ignoreEnd || !(chunkGenerator instanceof ChunkProviderEnd)));
}
}

View file

@ -1,16 +0,0 @@
package universalelectricity.prefab.ore;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import universalelectricity.prefab.ore.OreGenReplace;
public class OreGenReplaceStone extends OreGenReplace {
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel) {
super(name, oreDiectionaryName, stack, Blocks.stone, minGenerateLevel, maxGenerateLevel, amountPerChunk, amountPerBranch, harvestTool, harvestLevel);
}
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int maxGenerateLevel, int amountPerChunk, int amountPerBranch) {
this(name, oreDiectionaryName, stack, 0, maxGenerateLevel, amountPerChunk, amountPerBranch, "pickaxe", 1);
}
}

View file

@ -1,60 +0,0 @@
package universalelectricity.prefab.ore;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import universalelectricity.prefab.ore.OreGenBase;
public class OreGenerator implements IWorldGenerator {
public static boolean isInitiated = false;
private static final List ORES_TO_GENERATE = new ArrayList();
public static void addOre(OreGenBase data) {
if(!isInitiated) {
GameRegistry.registerWorldGenerator(new OreGenerator(), 10); //TODO figure out the right value instead of 10
}
ORES_TO_GENERATE.add(data);
}
public static boolean oreExists(String oreName) {
Iterator i$ = ORES_TO_GENERATE.iterator();
OreGenBase ore;
do {
if(!i$.hasNext()) {
return false;
}
ore = (OreGenBase)i$.next();
} while(ore.oreDictionaryName != oreName);
return true;
}
public static void removeOre(OreGenBase data) {
ORES_TO_GENERATE.remove(data);
}
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
chunkX <<= 4;
chunkZ <<= 4;
Iterator i$ = ORES_TO_GENERATE.iterator();
while(i$.hasNext()) {
OreGenBase oreData = (OreGenBase)i$.next();
if(oreData.shouldGenerate && oreData.isOreGeneratedInWorld(world, chunkGenerator)) {
oreData.generate(world, rand, chunkX, chunkZ);
}
}
}
}

View file

@ -1,22 +0,0 @@
package universalelectricity.prefab.potion;
import net.minecraft.potion.Potion;
public abstract class CustomPotion extends Potion {
public CustomPotion(int id, boolean isBadEffect, int color, String name) {
super(id, isBadEffect, color);
this.setPotionName("potion." + name);
Potion.potionTypes[this.getId()] = this;
}
public Potion setIconIndex(int par1, int par2) {
super.setIconIndex(par1, par2);
return this;
}
protected Potion setEffectiveness(double par1) {
super.setEffectiveness(par1);
return this;
}
}

View file

@ -1,27 +0,0 @@
package universalelectricity.prefab.potion;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
public class CustomPotionEffect extends PotionEffect {
public CustomPotionEffect(int potionID, int duration, int amplifier) {
super(potionID, duration, amplifier);
}
public CustomPotionEffect(Potion potion, int duration, int amplifier) {
this(potion.getId(), duration, amplifier);
}
public CustomPotionEffect(int potionID, int duration, int amplifier, List curativeItems) {
super(potionID, duration, amplifier);
if(curativeItems == null) {
this.setCurativeItems(new ArrayList());
} else {
this.setCurativeItems(curativeItems);
}
}
}

View file

@ -1,42 +0,0 @@
package universalelectricity.prefab.tile;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
public abstract class TileEntityAdvanced extends TileEntity {
protected long ticks = 0L;
@Override
public void updateEntity() {
if(this.ticks == 0L) {
this.initiate();
}
if(this.ticks >= Long.MAX_VALUE) {
this.ticks = 1L;
}
++this.ticks;
}
public void initiate() {}
@Override
public int getBlockMetadata() {
if(this.blockMetadata == -1) {
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
}
return this.blockMetadata;
}
@Override
public Block getBlockType() {
if(this.blockType == null) {
this.blockType = this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord);
}
return this.blockType;
}
}

View file

@ -1,144 +0,0 @@
package universalelectricity.prefab.tile;
import java.util.Arrays;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.network.play.server.S3FPacketCustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.INetworkProvider;
import universalelectricity.core.electricity.ElectricityNetwork;
import universalelectricity.core.electricity.IElectricityNetwork;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
public abstract class TileEntityConductor extends TileEntityAdvanced implements IConductor {
private IElectricityNetwork network;
public boolean[] visuallyConnected = new boolean[]{false, false, false, false, false, false};
public TileEntity[] connectedBlocks = new TileEntity[]{null, null, null, null, null, null};
protected String channel = "";
public void updateConnection(TileEntity tileEntity, ForgeDirection side) {
if(!this.worldObj.isRemote) {
if(tileEntity instanceof IConnector && ((IConnector)tileEntity).canConnect(side.getOpposite())) {
this.connectedBlocks[side.ordinal()] = tileEntity;
this.visuallyConnected[side.ordinal()] = true;
if(tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider) {
this.getNetwork().mergeConnection(((INetworkProvider)tileEntity).getNetwork());
}
return;
}
if(this.connectedBlocks[side.ordinal()] != null) {
this.getNetwork().stopProducing(this.connectedBlocks[side.ordinal()]);
this.getNetwork().stopRequesting(this.connectedBlocks[side.ordinal()]);
}
this.connectedBlocks[side.ordinal()] = null;
this.visuallyConnected[side.ordinal()] = false;
}
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
if(this.worldObj.isRemote) {
NBTTagCompound nbt = pkt.func_148857_g();
this.visuallyConnected[0] = nbt.getBoolean("bottom");
this.visuallyConnected[1] = nbt.getBoolean("top");
this.visuallyConnected[2] = nbt.getBoolean("back");
this.visuallyConnected[3] = nbt.getBoolean("front");
this.visuallyConnected[4] = nbt.getBoolean("left");
this.visuallyConnected[5] = nbt.getBoolean("right");
}
}
public void initiate() {
this.updateAdjacentConnections();
}
@Override
public void invalidate() {
if(!this.worldObj.isRemote) {
this.getNetwork().splitNetwork(this);
}
super.invalidate();
}
@Override
public void updateEntity() {
super.updateEntity();
if(!this.worldObj.isRemote && super.ticks % 300L == 0L) {
this.updateAdjacentConnections();
}
}
public void updateAdjacentConnections() {
if(this.worldObj != null && !this.worldObj.isRemote) {
boolean[] previousConnections = (boolean[])this.visuallyConnected.clone();
for(byte i = 0; i < 6; ++i) {
this.updateConnection(VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), ForgeDirection.getOrientation(i)), ForgeDirection.getOrientation(i));
}
if(!Arrays.equals(previousConnections, this.visuallyConnected)) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
}
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("bottom", this.visuallyConnected[0]);
nbt.setBoolean("top", this.visuallyConnected[1]);
nbt.setBoolean("back", this.visuallyConnected[2]);
nbt.setBoolean("front", this.visuallyConnected[3]);
nbt.setBoolean("left", this.visuallyConnected[4]);
nbt.setBoolean("right", this.visuallyConnected[5]);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt);
//return PacketManager.getPacket(this.channel, this, new Object[]{Boolean.valueOf(this.visuallyConnected[0]), Boolean.valueOf(this.visuallyConnected[1]), Boolean.valueOf(this.visuallyConnected[2]), Boolean.valueOf(this.visuallyConnected[3]), Boolean.valueOf(this.visuallyConnected[4]), Boolean.valueOf(this.visuallyConnected[5])});
}
public IElectricityNetwork getNetwork() {
if(this.network == null) {
this.setNetwork(new ElectricityNetwork(new IConductor[]{this}));
}
return this.network;
}
public void setNetwork(IElectricityNetwork network) {
this.network = network;
}
public TileEntity[] getAdjacentConnections() {
return this.connectedBlocks;
}
public boolean canConnect(ForgeDirection direction) {
return true;
}
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1));
}
}

View file

@ -1,27 +0,0 @@
package universalelectricity.prefab.tile;
import universalelectricity.prefab.implement.IDisableable;
public abstract class TileEntityDisableable extends TileEntityAdvanced implements IDisableable {
protected int disabledTicks = 0;
@Override
public void updateEntity() {
super.updateEntity();
if(this.disabledTicks > 0) {
--this.disabledTicks;
this.whileDisable();
}
}
protected void whileDisable() {}
public void onDisable(int duration) {
this.disabledTicks = duration;
}
public boolean isDisabled() {
return this.disabledTicks > 0;
}
}

View file

@ -1,19 +0,0 @@
package universalelectricity.prefab.tile;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.IVoltage;
import universalelectricity.core.electricity.ElectricityNetworkHelper;
import universalelectricity.prefab.tile.TileEntityDisableable;
public abstract class TileEntityElectrical extends TileEntityDisableable implements IConnector, IVoltage {
public double getVoltage() {
return 120.0D;
}
@Override
public void invalidate() {
ElectricityNetworkHelper.invalidate(this);
super.invalidate();
}
}

View file

@ -1,48 +0,0 @@
package universalelectricity.prefab.tile;
import java.util.EnumSet;
import net.minecraft.entity.Entity;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.electricity.ElectricityNetworkHelper;
import universalelectricity.core.electricity.ElectricityPack;
public abstract class TileEntityElectricityRunnable extends TileEntityElectrical {
public double prevWatts;
public double wattsReceived = 0.0D;
@Override
public void updateEntity() {
super.updateEntity();
this.prevWatts = this.wattsReceived;
if(!this.worldObj.isRemote) {
if(!this.isDisabled()) {
ElectricityPack electricityPack = ElectricityNetworkHelper.consumeFromMultipleSides(this, this.getConsumingSides(), this.getRequest());
this.onReceive(electricityPack);
} else {
ElectricityNetworkHelper.consumeFromMultipleSides(this, new ElectricityPack());
}
}
}
protected EnumSet getConsumingSides() {
return ElectricityNetworkHelper.getDirections(this);
}
public ElectricityPack getRequest() {
return new ElectricityPack();
}
public void onReceive(ElectricityPack electricityPack) {
if(UniversalElectricity.isVoltageSensitive && electricityPack.voltage > this.getVoltage()) {
this.worldObj.createExplosion((Entity)null, (double)this.xCoord, (double)this.yCoord, (double)this.zCoord, 1.5F, true);
} else {
this.wattsReceived = Math.min(this.wattsReceived + electricityPack.getWatts(), this.getWattBuffer());
}
}
public double getWattBuffer() {
return this.getRequest().getWatts() * 2.0D;
}
}

View file

@ -1,67 +0,0 @@
package universalelectricity.prefab.tile;
import java.util.EnumSet;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.block.IElectricityStorage;
import universalelectricity.core.electricity.ElectricityNetworkHelper;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.prefab.tile.TileEntityElectrical;
public abstract class TileEntityElectricityStorage extends TileEntityElectrical implements IElectricityStorage {
private double joules = 0.0D;
public double prevJoules = 0.0D;
@Override
public void updateEntity() {
super.updateEntity();
this.prevJoules = this.joules;
if(!this.worldObj.isRemote) {
if(!this.isDisabled()) {
ElectricityPack electricityPack = ElectricityNetworkHelper.consumeFromMultipleSides(this, this.getConsumingSides(), this.getRequest());
this.onReceive(electricityPack);
} else {
ElectricityNetworkHelper.consumeFromMultipleSides(this, new ElectricityPack());
}
}
}
protected EnumSet getConsumingSides() {
return ElectricityNetworkHelper.getDirections(this);
}
public ElectricityPack getRequest() {
return new ElectricityPack((this.getMaxJoules() - this.getJoules()) / this.getVoltage(), this.getVoltage());
}
public void onReceive(ElectricityPack electricityPack) {
if(UniversalElectricity.isVoltageSensitive && electricityPack.voltage > this.getVoltage()) {
this.worldObj.createExplosion((Entity)null, (double)this.xCoord, (double)this.yCoord, (double)this.zCoord, 1.5F, true);
} else {
this.setJoules(this.getJoules() + electricityPack.getWatts());
}
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readFromNBT(par1NBTTagCompound);
this.joules = par1NBTTagCompound.getDouble("joules");
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setDouble("joules", this.joules);
}
public double getJoules() {
return this.joules;
}
public void setJoules(double joules) {
this.joules = Math.max(Math.min(joules, this.getMaxJoules()), 0.0D);
}
}

View file

@ -1,27 +0,0 @@
package universalelectricity.prefab.vector;
import universalelectricity.core.vector.Vector2;
public class Region2 {
public Vector2 min;
public Vector2 max;
public Region2() {
this(new Vector2(), new Vector2());
}
public Region2(Vector2 min, Vector2 max) {
this.min = min;
this.max = max;
}
public boolean isIn(Vector2 point) {
return point.x > this.min.x && point.x < this.max.x && point.y > this.min.y && point.y < this.max.y;
}
public boolean isIn(Region2 region) {
return region.max.x > this.min.x && region.min.x < this.max.x?region.max.y > this.min.y && region.min.y < this.max.y:false;
}
}

View file

@ -1,94 +0,0 @@
package universalelectricity.prefab.vector;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.vector.Region2;
public class Region3 {
public Vector3 min;
public Vector3 max;
public Region3() {
this(new Vector3(), new Vector3());
}
public Region3(Vector3 min, Vector3 max) {
this.min = min;
this.max = max;
}
public Region3(AxisAlignedBB aabb) {
this.min = new Vector3(aabb.minX, aabb.minY, aabb.minZ);
this.max = new Vector3(aabb.maxX, aabb.maxY, aabb.maxZ);
}
public AxisAlignedBB toAABB() {
return AxisAlignedBB.getBoundingBox(this.min.x, this.min.y, this.min.z, this.max.x, this.max.y, this.max.z);
}
public Region2 toRegion2() {
return new Region2(this.min.toVector2(), this.max.toVector2());
}
public boolean isIn(Vector3 point) {
return point.x > this.min.x && point.x < this.max.x && point.y > this.min.y && point.y < this.max.y && point.z > this.min.z && point.z < this.max.z;
}
public boolean isIn(Region3 region) {
return region.max.x > this.min.x && region.min.x < this.max.x?(region.max.y > this.min.y && region.min.y < this.max.y?region.max.z > this.min.z && region.min.z < this.max.z:false):false;
}
public void expand(Vector3 difference) {
this.min.subtract(difference);
this.max.add(difference);
}
public List getVectors() {
ArrayList vectors = new ArrayList();
for(int x = this.min.intX(); x < this.max.intX(); ++x) {
for(int y = this.min.intY(); x < this.max.intY(); ++y) {
for(int z = this.min.intZ(); x < this.max.intZ(); ++z) {
vectors.add(new Vector3((double)x, (double)y, (double)z));
}
}
}
return vectors;
}
public List getVectors(Vector3 center, int radius) {
ArrayList vectors = new ArrayList();
for(int x = this.min.intX(); x < this.max.intX(); ++x) {
for(int y = this.min.intY(); x < this.max.intY(); ++y) {
for(int z = this.min.intZ(); x < this.max.intZ(); ++z) {
Vector3 vector3 = new Vector3((double)x, (double)y, (double)z);
if(center.distanceTo(vector3) <= (double)radius) {
vectors.add(vector3);
}
}
}
}
return vectors;
}
public List getEntities(World world, Class entityClass) {
return world.getEntitiesWithinAABB(entityClass, this.toAABB());
}
public List getEntitiesExlude(World world, Entity entity) {
return world.getEntitiesWithinAABBExcludingEntity(entity, this.toAABB());
}
public List getEntities(World world) {
return this.getEntities(world, Entity.class);
}
}