feat: big overhaul
This commit is contained in:
parent
2a8d7e9b61
commit
a83fd143d8
11
build.gradle
11
build.gradle
|
@ -21,7 +21,7 @@ apply plugin: 'maven-publish'
|
|||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
version = "1.0.2-dirty"
|
||||
version = "1.1.0"
|
||||
group= "universalelectricity"
|
||||
archivesBaseName = "basiccomponents"
|
||||
|
||||
|
@ -30,8 +30,15 @@ minecraft {
|
|||
runDir = "run"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
repositories {
|
||||
maven {
|
||||
name = "ic2"
|
||||
url = "http://maven.ic2.player.to/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'net.industrial-craft:industrialcraft-2:2.2.660-experimental:dev'
|
||||
}
|
||||
|
||||
processResources
|
||||
|
|
19
src/main/java/basiccomponents/common/BCTab.java
Normal file
19
src/main/java/basiccomponents/common/BCTab.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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,7 @@ 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.compat.CompatHandler;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.item.ElectricItemHelper;
|
||||
import universalelectricity.prefab.RecipeHelper;
|
||||
|
@ -125,6 +120,8 @@ public class BasicComponents {
|
|||
registerCircuits();
|
||||
registerMachines();
|
||||
CONFIGURATION.save();
|
||||
CompatHandler.initCompatHandlers();
|
||||
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
@ -135,14 +132,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 +208,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);
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -6,6 +6,5 @@ public class ItemIngot extends ItemBase {
|
|||
|
||||
public ItemIngot(String name) {
|
||||
super(name);
|
||||
this.setCreativeTab(CreativeTabs.tabMaterials);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,5 @@ public class ItemPlate extends ItemBase {
|
|||
|
||||
public ItemPlate(String name) {
|
||||
super(name);
|
||||
this.setCreativeTab(CreativeTabs.tabMaterials);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
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 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;
|
||||
|
@ -27,7 +26,7 @@ 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 {
|
||||
|
||||
private ItemStack[] containingItems = new ItemStack[2];
|
||||
public final Set<EntityPlayer> playersUsing = new HashSet();
|
||||
|
@ -246,4 +245,9 @@ public class TileEntityBatteryBox extends TileEntityElectricityStorage implement
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOutputTo(ForgeDirection side) {
|
||||
return side == ForgeDirection.getOrientation(this.getBlockMetadata() - 4 + 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +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;
|
||||
|
@ -58,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 {
|
||||
|
|
8
src/main/java/cofh/api/energy/IEnergyConnection.java
Normal file
8
src/main/java/cofh/api/energy/IEnergyConnection.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IEnergyConnection {
|
||||
|
||||
boolean canConnectEnergy(ForgeDirection var1);
|
||||
}
|
12
src/main/java/cofh/api/energy/IEnergyProvider.java
Normal file
12
src/main/java/cofh/api/energy/IEnergyProvider.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IEnergyProvider extends IEnergyConnection {
|
||||
|
||||
int extractEnergy(ForgeDirection var1, int var2, boolean var3);
|
||||
|
||||
int getEnergyStored(ForgeDirection var1);
|
||||
|
||||
int getMaxEnergyStored(ForgeDirection var1);
|
||||
}
|
12
src/main/java/cofh/api/energy/IEnergyReceiver.java
Normal file
12
src/main/java/cofh/api/energy/IEnergyReceiver.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IEnergyReceiver extends IEnergyConnection {
|
||||
|
||||
int receiveEnergy(ForgeDirection var1, int var2, boolean var3);
|
||||
|
||||
int getEnergyStored(ForgeDirection var1);
|
||||
|
||||
int getMaxEnergyStored(ForgeDirection var1);
|
||||
}
|
13
src/main/java/cofh/api/energy/IEnergyStorage.java
Normal file
13
src/main/java/cofh/api/energy/IEnergyStorage.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package cofh.api.energy;
|
||||
|
||||
|
||||
public interface IEnergyStorage {
|
||||
|
||||
int receiveEnergy(int var1, boolean var2);
|
||||
|
||||
int extractEnergy(int var1, boolean var2);
|
||||
|
||||
int getEnergyStored();
|
||||
|
||||
int getMaxEnergyStored();
|
||||
}
|
60
src/main/java/mekanism/api/energy/EnergizedItemManager.java
Normal file
60
src/main/java/mekanism/api/energy/EnergizedItemManager.java
Normal 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;
|
||||
}
|
||||
}
|
14
src/main/java/mekanism/api/energy/EnergyStack.java
Normal file
14
src/main/java/mekanism/api/energy/EnergyStack.java
Normal 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;
|
||||
}
|
||||
}
|
18
src/main/java/mekanism/api/energy/ICableOutputter.java
Normal file
18
src/main/java/mekanism/api/energy/ICableOutputter.java
Normal 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);
|
||||
}
|
53
src/main/java/mekanism/api/energy/IEnergizedItem.java
Normal file
53
src/main/java/mekanism/api/energy/IEnergizedItem.java
Normal 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);
|
||||
}
|
25
src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java
Normal file
25
src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java
Normal 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);
|
||||
}
|
27
src/main/java/mekanism/api/energy/IStrictEnergyStorage.java
Normal file
27
src/main/java/mekanism/api/energy/IStrictEnergyStorage.java
Normal 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();
|
||||
}
|
4
src/main/java/mekanism/api/energy/package-info.java
Normal file
4
src/main/java/mekanism/api/energy/package-info.java
Normal file
|
@ -0,0 +1,4 @@
|
|||
@API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|energy")
|
||||
package mekanism.api.energy;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
53
src/main/java/universalelectricity/compat/CompatHandler.java
Normal file
53
src/main/java/universalelectricity/compat/CompatHandler.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package universalelectricity.compat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.compat.ic2.EventHandler;
|
||||
import universalelectricity.compat.ic2.IC2CompatModule;
|
||||
import universalelectricity.compat.ic2.TickHandler;
|
||||
import universalelectricity.core.block.IConnector;
|
||||
|
||||
public class CompatHandler {
|
||||
|
||||
private static List<CompatiblityModule> modules;
|
||||
|
||||
public static void initCompatHandlers() {
|
||||
modules = new ArrayList<>();
|
||||
if (Loader.isModLoaded("IC2")) {
|
||||
modules.add(new IC2CompatModule());
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
FMLCommonHandler.instance().bus().register(new TickHandler());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerModule(CompatiblityModule module) {
|
||||
if (modules != null)
|
||||
modules.add(module);
|
||||
}
|
||||
|
||||
public static boolean canConnect(TileEntity tileEntity, ForgeDirection side) {
|
||||
if (tileEntity == null) return false;
|
||||
if (tileEntity instanceof IConnector) return ((IConnector)tileEntity).canConnect(side);
|
||||
for (CompatiblityModule module : modules) {
|
||||
if (module.canConnect(tileEntity, side)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IElectricityTileHandler getHandler(TileEntity tileEntity) {
|
||||
if (tileEntity instanceof IConnector || tileEntity == null) return null;
|
||||
for (CompatiblityModule module : modules) {
|
||||
if (module.isHandledBy(tileEntity)) {
|
||||
return module.getHandler(tileEntity);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package universalelectricity.compat;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class CompatiblityModule {
|
||||
|
||||
public abstract boolean isHandledBy(TileEntity tile);
|
||||
|
||||
public abstract boolean canConnect(TileEntity tile, ForgeDirection side);
|
||||
|
||||
public abstract IElectricityTileHandler getHandler(TileEntity tileEntity);
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package universalelectricity.compat;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
public interface IElectricityTileHandler {
|
||||
|
||||
boolean canInsert();
|
||||
|
||||
boolean canExtract();
|
||||
|
||||
boolean canInsertOn(ForgeDirection side);
|
||||
|
||||
boolean canExtractOn(ForgeDirection side);
|
||||
|
||||
void insert(ElectricityPack pack, ForgeDirection side);
|
||||
|
||||
void extract(ElectricityPack pack, ForgeDirection side);
|
||||
|
||||
ElectricityPack getDemandedJoules();
|
||||
|
||||
ElectricityPack getProvidedJoules();
|
||||
|
||||
TileEntity getTile();
|
||||
|
||||
double getVoltage();
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package universalelectricity.compat.ic2;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.compat.IElectricityTileHandler;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
public class ElectricityTileWrapper implements IElectricityTileHandler {
|
||||
|
||||
TileEntity baseTile;
|
||||
|
||||
public ElectricityTileWrapper(TileEntity baseTile) {
|
||||
this.baseTile = baseTile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert() {
|
||||
return baseTile instanceof IEnergySink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return baseTile instanceof IEnergySource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertOn(ForgeDirection side) {
|
||||
return baseTile instanceof IEnergySink && ((IEnergySink) baseTile).acceptsEnergyFrom(null, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractOn(ForgeDirection side) {
|
||||
return baseTile instanceof IEnergySource && ((IEnergySource) baseTile).emitsEnergyTo(null, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(ElectricityPack pack, ForgeDirection side) {
|
||||
if (baseTile instanceof IEnergySink) {
|
||||
IEnergySink sink = (IEnergySink) baseTile;
|
||||
sink.injectEnergy(side, IC2CompatHelper.joulesToEU(pack.getWatts()), IC2CompatHelper.voltToTier(pack.voltage));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extract(ElectricityPack pack, ForgeDirection side) {
|
||||
if (baseTile instanceof IEnergySource) {
|
||||
IEnergySource source = (IEnergySource) baseTile;
|
||||
source.drawEnergy(IC2CompatHelper.joulesToEU(pack.getWatts()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack getDemandedJoules() {
|
||||
if (baseTile instanceof IEnergySink) {
|
||||
IEnergySink sink = (IEnergySink) baseTile;
|
||||
double voltage = IC2CompatHelper.tierToVolt(sink.getSinkTier());
|
||||
return new ElectricityPack(IC2CompatHelper.EUToJoules(sink.getDemandedEnergy()) / voltage, voltage);
|
||||
}
|
||||
return new ElectricityPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack getProvidedJoules() {
|
||||
if (baseTile instanceof IEnergySource) {
|
||||
IEnergySource source = (IEnergySource) baseTile;
|
||||
double voltage = IC2CompatHelper.tierToVolt(source.getSourceTier());
|
||||
return new ElectricityPack(IC2CompatHelper.EUToJoules(source.getOfferedEnergy()) / voltage, voltage);
|
||||
}
|
||||
return new ElectricityPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTile() {
|
||||
return baseTile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getVoltage() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package universalelectricity.compat.ic2;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.core.Pair;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.tile.ElectricTileDriver;
|
||||
|
||||
public class EnergyNetCache {
|
||||
|
||||
private static Map<Pair<World, Vector3>, ElectricTileDriver> tiles = new HashMap<>();
|
||||
|
||||
public static Pair<World, Vector3> toKey(TileEntity tile) {
|
||||
return new Pair<World, Vector3>(tile.getWorldObj(), new Vector3(tile));
|
||||
}
|
||||
|
||||
public static void load(TileEntity tile) {
|
||||
tiles.put(toKey(tile), new ElectricTileDriver(new ElectricityTileWrapper(tile)));
|
||||
}
|
||||
|
||||
public static void unload(TileEntity tile) {
|
||||
ElectricTileDriver handler = tiles.get(toKey(tile));
|
||||
if (handler != null) handler.invalidate();
|
||||
tiles.remove(toKey(tile));
|
||||
}
|
||||
|
||||
public static boolean canConnect(Pair<World, Vector3> pos, ForgeDirection side) {
|
||||
ElectricTileDriver handler = tiles.get(pos);
|
||||
return handler == null ? false : handler.canConnect(side);
|
||||
}
|
||||
|
||||
public static void tickAll() {
|
||||
for (ElectricTileDriver handler : tiles.values()) {
|
||||
handler.tick();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean contains(TileEntity tile) {
|
||||
return tiles.containsKey(toKey(tile));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package universalelectricity.compat.ic2;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import mekanism.api.energy.ICableOutputter;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import universalelectricity.core.block.IConnector;
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLoadTile(EnergyTileLoadEvent event) {
|
||||
TileEntity te = (TileEntity) event.energyTile;
|
||||
if (te instanceof IConnector || te instanceof IStrictEnergyAcceptor || te instanceof ICableOutputter) return;
|
||||
if (te instanceof IEnergySink || te instanceof IEnergySource) EnergyNetCache.load(te);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onUnloadTile(EnergyTileUnloadEvent event) {
|
||||
TileEntity te = (TileEntity) event.energyTile;
|
||||
EnergyNetCache.unload(te);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package universalelectricity.compat.ic2;
|
||||
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
|
||||
public class IC2CompatHelper {
|
||||
|
||||
public static double EUToJoules(double eu) {
|
||||
return eu * UniversalElectricity.UE_IC2_RATIO;
|
||||
}
|
||||
|
||||
public static double joulesToEU(double joules) {
|
||||
return joules / UniversalElectricity.UE_IC2_RATIO;
|
||||
}
|
||||
|
||||
public static int voltToTier(double volt) {
|
||||
if (volt <= 120.0) return 1;
|
||||
if (volt <= 240.0) return 2;
|
||||
if (volt <= 480.0) return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
public static double tierToVolt(int tier) {
|
||||
switch (tier) {
|
||||
case 1: return 120.0;
|
||||
case 2: return 240.0;
|
||||
case 3: return 480.0;
|
||||
default: return 960.0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package universalelectricity.compat.ic2;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.compat.CompatiblityModule;
|
||||
import universalelectricity.compat.IElectricityTileHandler;
|
||||
|
||||
public class IC2CompatModule extends CompatiblityModule {
|
||||
|
||||
@Override
|
||||
public boolean isHandledBy(TileEntity tile) {
|
||||
return EnergyNetCache.contains(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(TileEntity tile, ForgeDirection side) {
|
||||
return EnergyNetCache.canConnect(EnergyNetCache.toKey(tile), side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElectricityTileHandler getHandler(TileEntity tileEntity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package universalelectricity.compat.ic2;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
|
||||
|
||||
public class TickHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ServerTickEvent event) {
|
||||
if (event.phase == Phase.END) {
|
||||
EnergyNetCache.tickAll();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
34
src/main/java/universalelectricity/core/Pair.java
Normal file
34
src/main/java/universalelectricity/core/Pair.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package universalelectricity.core;
|
||||
|
||||
public class Pair<L, R> {
|
||||
private final L left;
|
||||
private final R right;
|
||||
|
||||
public Pair(L left, R right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public L getKey() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public R getValue() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.left.hashCode() ^ this.right.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(o instanceof Pair)) {
|
||||
return false;
|
||||
}
|
||||
Pair<Object, Object> pairo = (Pair<Object, Object>)o;
|
||||
return this.left.equals(pairo.getKey()) && this.right.equals(pairo.getValue());
|
||||
}
|
||||
}
|
|
@ -14,10 +14,8 @@ public class UniversalElectricity {
|
|||
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 double UE_IC2_RATIO = 10.0D;
|
||||
public static double UE_RF_RATIO = 2.5D;
|
||||
public static boolean isVoltageSensitive = false;
|
||||
public static boolean isNetworkActive = false;
|
||||
public static final Material machine = new Material(MapColor.ironColor);
|
||||
|
@ -25,10 +23,6 @@ public class UniversalElectricity {
|
|||
|
||||
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();
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
package universalelectricity.core.block;
|
||||
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
|
||||
public interface IElectricityStorage {
|
||||
public interface IElectricityStorage extends IStrictEnergyStorage {
|
||||
|
||||
double getJoules();
|
||||
|
||||
void setJoules(double var1);
|
||||
|
||||
double getMaxJoules();
|
||||
|
||||
default double getEnergy() {
|
||||
return getJoules();
|
||||
}
|
||||
|
||||
default void setEnergy(double energy) {
|
||||
setJoules(energy);
|
||||
}
|
||||
|
||||
default double getMaxEnergy() {
|
||||
return getMaxJoules();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,17 +14,15 @@ 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();
|
||||
private final HashMap<TileEntity, ElectricityPack> producers = new HashMap<>();
|
||||
private final HashMap<TileEntity, ElectricityPack> consumers = new HashMap<>();
|
||||
private final Set<IConductor> conductors = new HashSet<>();
|
||||
|
||||
|
||||
public ElectricityNetwork() {}
|
||||
|
@ -172,28 +170,28 @@ public class ElectricityNetwork implements IElectricityNetwork {
|
|||
return totalElectricity;
|
||||
}
|
||||
|
||||
public HashMap getProducers() {
|
||||
public HashMap<TileEntity, ElectricityPack> getProducers() {
|
||||
return this.producers;
|
||||
}
|
||||
|
||||
public List getProviders() {
|
||||
ArrayList providers = new ArrayList();
|
||||
public List<TileEntity> getProviders() {
|
||||
ArrayList<TileEntity> providers = new ArrayList<>();
|
||||
providers.addAll(this.producers.keySet());
|
||||
return providers;
|
||||
}
|
||||
|
||||
public HashMap getConsumers() {
|
||||
public HashMap<TileEntity, ElectricityPack> getConsumers() {
|
||||
return this.consumers;
|
||||
}
|
||||
|
||||
public List getReceivers() {
|
||||
ArrayList receivers = new ArrayList();
|
||||
public List<TileEntity> getReceivers() {
|
||||
ArrayList<TileEntity> receivers = new ArrayList<>();
|
||||
receivers.addAll(this.consumers.keySet());
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public void cleanUpConductors() {
|
||||
Iterator it = this.conductors.iterator();
|
||||
Iterator<IConductor> it = this.conductors.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
IConductor conductor = (IConductor)it.next();
|
||||
|
@ -250,7 +248,7 @@ public class ElectricityNetwork implements IElectricityNetwork {
|
|||
return lowestAmp;
|
||||
}
|
||||
|
||||
public Set getConductors() {
|
||||
public Set<IConductor> getConductors() {
|
||||
return this.conductors;
|
||||
}
|
||||
|
||||
|
@ -327,4 +325,15 @@ public class ElectricityNetwork implements IElectricityNetwork {
|
|||
public String toString() {
|
||||
return "ElectricityNetwork[" + this.hashCode() + "|Wires:" + this.conductors.size() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInactive() {
|
||||
return conductors.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,11 @@ 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;
|
||||
|
||||
|
@ -30,7 +29,7 @@ public class ElectricityNetworkHelper {
|
|||
|
||||
}
|
||||
|
||||
public static EnumSet getDirections(TileEntity tileEntity) {
|
||||
public static EnumSet<ForgeDirection> getDirections(TileEntity tileEntity) {
|
||||
EnumSet possibleSides = EnumSet.noneOf(ForgeDirection.class);
|
||||
if(tileEntity instanceof IConnector) {
|
||||
for(int i = 0; i < 6; ++i) {
|
||||
|
@ -48,7 +47,7 @@ public class ElectricityNetworkHelper {
|
|||
return produceFromMultipleSides(tileEntity, getDirections(tileEntity), electricityPack);
|
||||
}
|
||||
|
||||
public static ElectricityPack produceFromMultipleSides(TileEntity tileEntity, EnumSet approachingDirection, ElectricityPack producingPack) {
|
||||
public static ElectricityPack produceFromMultipleSides(TileEntity tileEntity, EnumSet<ForgeDirection> approachingDirection, ElectricityPack producingPack) {
|
||||
ElectricityPack remainingElectricity = producingPack.clone();
|
||||
if(tileEntity != null && approachingDirection != null) {
|
||||
List connectedNetworks = getNetworksFromMultipleSides(tileEntity, approachingDirection);
|
||||
|
@ -105,7 +104,7 @@ public class ElectricityNetworkHelper {
|
|||
return consumedPack;
|
||||
}
|
||||
|
||||
public static List getNetworksFromMultipleSides(TileEntity tileEntity, EnumSet approachingDirection) {
|
||||
public static List<IElectricityNetwork> getNetworksFromMultipleSides(TileEntity tileEntity, EnumSet<ForgeDirection> approachingDirection) {
|
||||
ArrayList connectedNetworks = new ArrayList();
|
||||
|
||||
for(int i = 0; i < 6; ++i) {
|
||||
|
@ -115,7 +114,7 @@ public class ElectricityNetworkHelper {
|
|||
position.modifyPositionFromSide(direction);
|
||||
TileEntity outputConductor = position.getTileEntity(tileEntity.getWorldObj());
|
||||
IElectricityNetwork electricityNetwork = getNetworkFromTileEntity(outputConductor, direction);
|
||||
if(electricityNetwork != null && !connectedNetworks.contains(connectedNetworks)) {
|
||||
if(electricityNetwork != null && !connectedNetworks.contains(electricityNetwork)) {
|
||||
connectedNetworks.add(electricityNetwork);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.block.IConnectionProvider;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
public interface IElectricityNetwork {
|
||||
|
||||
|
@ -33,15 +33,15 @@ public interface IElectricityNetwork {
|
|||
|
||||
ElectricityPack consumeElectricity(TileEntity var1);
|
||||
|
||||
HashMap getProducers();
|
||||
HashMap<TileEntity, ElectricityPack> getProducers();
|
||||
|
||||
List getProviders();
|
||||
List<TileEntity> getProviders();
|
||||
|
||||
HashMap getConsumers();
|
||||
HashMap<TileEntity, ElectricityPack> getConsumers();
|
||||
|
||||
List getReceivers();
|
||||
List<TileEntity> getReceivers();
|
||||
|
||||
Set getConductors();
|
||||
Set<IConductor> getConductors();
|
||||
|
||||
double getTotalResistance();
|
||||
|
||||
|
@ -54,4 +54,9 @@ public interface IElectricityNetwork {
|
|||
void mergeConnection(IElectricityNetwork var1);
|
||||
|
||||
void splitNetwork(IConnectionProvider var1);
|
||||
|
||||
boolean isInactive();
|
||||
|
||||
void tick();
|
||||
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ public class Vector3 implements Cloneable {
|
|||
return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
|
||||
}
|
||||
|
||||
public List getEntitiesWithin(World worldObj, Class par1Class) {
|
||||
public List<Entity> getEntitiesWithin(World worldObj, Class<? extends Entity> 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)));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ public class VectorHelper {
|
|||
return front != ForgeDirection.UNKNOWN && side != ForgeDirection.UNKNOWN?ForgeDirection.getOrientation(RELATIVE_MATRIX[front.ordinal()][side.ordinal()]):ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
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;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package universalelectricity.prefab.modifier;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IModifier
|
||||
{
|
||||
String getType(final ItemStack p0);
|
||||
|
||||
double getEffectiveness(final ItemStack p0);
|
||||
|
||||
int getTier(final ItemStack p0);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package universalelectricity.prefab.modifier;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class SlotModifier extends Slot
|
||||
{
|
||||
public SlotModifier(final IInventory par2IInventory, final int par3, final int par4, final int par5) {
|
||||
super(par2IInventory, par3, par4, par5);
|
||||
}
|
||||
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return par1ItemStack.getItem() instanceof IModifier;
|
||||
}
|
||||
}
|
|
@ -2,26 +2,28 @@ package universalelectricity.prefab.potion;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
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);
|
||||
super(potionID, duration, amplifier);
|
||||
}
|
||||
|
||||
public CustomPotionEffect(Potion potion, int duration, int amplifier) {
|
||||
this(potion.getId(), duration, 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);
|
||||
}
|
||||
|
||||
public CustomPotionEffect(int potionID, int duration, int amplifier, List<ItemStack> curativeItems) {
|
||||
super(potionID, duration, amplifier);
|
||||
if(curativeItems == null) {
|
||||
this.setCurativeItems(new ArrayList());
|
||||
} else {
|
||||
this.setCurativeItems(curativeItems);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
package universalelectricity.prefab.tile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import scala.languageFeature.reflectiveCalls;
|
||||
import universalelectricity.compat.IElectricityTileHandler;
|
||||
import universalelectricity.core.block.IConnector;
|
||||
import universalelectricity.core.electricity.ElectricityNetworkHelper;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.electricity.IElectricityNetwork;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class ElectricTileDriver implements IConnector {
|
||||
|
||||
IElectricityTileHandler handler;
|
||||
|
||||
public ElectricTileDriver(IElectricityTileHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection side) {
|
||||
return handler.canInsertOn(side) || handler.canExtractOn(side);
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
ElectricityNetworkHelper.invalidate(handler.getTile());
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
Map<ForgeDirection, IElectricityNetwork> networks = getNetworks();
|
||||
Set<ForgeDirection> inputSides = new HashSet<>();
|
||||
if (handler.canInsert()) {
|
||||
inputSides = consume(networks);
|
||||
}
|
||||
if (handler.canExtract()) {
|
||||
produce(networks, inputSides);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<ForgeDirection> consume(Map<ForgeDirection, IElectricityNetwork> networks) {
|
||||
Set<ForgeDirection> inputSides = new HashSet<>();
|
||||
|
||||
if (networks.size() > 0) {
|
||||
ElectricityPack demand = handler.getDemandedJoules();
|
||||
double voltage = demand.voltage;
|
||||
double wattsPerSide = demand.getWatts() / networks.size();
|
||||
for (ForgeDirection side : networks.keySet()) {
|
||||
IElectricityNetwork net = networks.get(side);
|
||||
if (handler.canInsertOn(side) && wattsPerSide > 0 && demand.getWatts() > 0) {
|
||||
inputSides.add(side);
|
||||
net.startRequesting(handler.getTile(), wattsPerSide / voltage, voltage);
|
||||
ElectricityPack receivedPack = net.consumeElectricity(handler.getTile());
|
||||
handler.insert(receivedPack, side);
|
||||
} else {
|
||||
net.stopRequesting(handler.getTile());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return inputSides;
|
||||
}
|
||||
|
||||
public void produce(Map<ForgeDirection, IElectricityNetwork> networks, Set<ForgeDirection> inputSides) {
|
||||
if ((networks.size() - inputSides.size()) > 0) {
|
||||
ElectricityPack provided = handler.getProvidedJoules();
|
||||
double voltage = provided.voltage;
|
||||
double wattsPerSide = provided.getWatts() / (networks.size() - inputSides.size());
|
||||
for (ForgeDirection side : networks.keySet()) {
|
||||
IElectricityNetwork net = networks.get(side);
|
||||
if (!inputSides.contains(side) && handler.canExtractOn(side) && wattsPerSide > 0 && provided.getWatts() > 0) {
|
||||
double amperes = Math.min(wattsPerSide / voltage, net.getRequest(new TileEntity[]{handler.getTile()}).amperes);
|
||||
net.startProducing(handler.getTile(), amperes, voltage);
|
||||
handler.extract(new ElectricityPack(amperes, voltage), side);
|
||||
} else {
|
||||
net.stopProducing(handler.getTile());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<ForgeDirection, IElectricityNetwork> getNetworks() {
|
||||
Map<ForgeDirection, IElectricityNetwork> networks = new HashMap<>();
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.values()) {
|
||||
if (canConnect(dir)) {
|
||||
Vector3 position = new Vector3(handler.getTile());
|
||||
position.modifyPositionFromSide(dir);
|
||||
TileEntity outputConductor = position.getTileEntity(handler.getTile().getWorldObj());
|
||||
IElectricityNetwork electricityNetwork = ElectricityNetworkHelper.getNetworkFromTileEntity(outputConductor, dir);
|
||||
if(electricityNetwork != null && !networks.containsValue(electricityNetwork)) {
|
||||
networks.put(dir, electricityNetwork);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,23 +2,20 @@ 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.compat.CompatHandler;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.block.IConnector;
|
||||
import universalelectricity.core.block.INetworkProvider;
|
||||
import universalelectricity.core.electricity.ElectricityNetwork;
|
||||
import universalelectricity.core.electricity.ElectricityNetworkHelper;
|
||||
import universalelectricity.core.electricity.IElectricityNetwork;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
|
@ -33,7 +30,7 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements
|
|||
|
||||
public void updateConnection(TileEntity tileEntity, ForgeDirection side) {
|
||||
if(!this.worldObj.isRemote) {
|
||||
if(tileEntity instanceof IConnector && ((IConnector)tileEntity).canConnect(side.getOpposite())) {
|
||||
if(CompatHandler.canConnect(tileEntity, side.getOpposite())) {
|
||||
this.connectedBlocks[side.ordinal()] = tileEntity;
|
||||
this.visuallyConnected[side.ordinal()] = true;
|
||||
if(tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider) {
|
||||
|
@ -94,7 +91,7 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements
|
|||
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));
|
||||
this.updateConnection(VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), ForgeDirection.getOrientation(i)), ForgeDirection.getOrientation(i));
|
||||
}
|
||||
|
||||
if(!Arrays.equals(previousConnections, this.visuallyConnected)) {
|
||||
|
@ -114,7 +111,6 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements
|
|||
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() {
|
||||
|
|
|
@ -2,6 +2,7 @@ package universalelectricity.prefab.tile;
|
|||
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.electricity.ElectricityNetworkHelper;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
@ -26,7 +27,7 @@ public abstract class TileEntityElectricityRunnable extends TileEntityElectrical
|
|||
|
||||
}
|
||||
|
||||
protected EnumSet getConsumingSides() {
|
||||
protected EnumSet<ForgeDirection> getConsumingSides() {
|
||||
return ElectricityNetworkHelper.getDirections(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
package universalelectricity.prefab.tile;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
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 {
|
||||
public abstract class TileEntityElectricityStorage extends TileEntityElectrical implements IElectricityStorage, IStrictEnergyAcceptor {
|
||||
|
||||
private double joules = 0.0D;
|
||||
public double prevJoules = 0.0D;
|
||||
|
@ -29,7 +32,7 @@ public abstract class TileEntityElectricityStorage extends TileEntityElectrical
|
|||
|
||||
}
|
||||
|
||||
protected EnumSet getConsumingSides() {
|
||||
protected EnumSet<ForgeDirection> getConsumingSides() {
|
||||
return ElectricityNetworkHelper.getDirections(this);
|
||||
}
|
||||
|
||||
|
@ -64,4 +67,16 @@ public abstract class TileEntityElectricityStorage extends TileEntityElectrical
|
|||
public void setJoules(double joules) {
|
||||
this.joules = Math.max(Math.min(joules, this.getMaxJoules()), 0.0D);
|
||||
}
|
||||
|
||||
public double transferEnergyToAcceptor(ForgeDirection side, double amount) {
|
||||
if (!canReceiveEnergy(side)) return 0;
|
||||
double toUse = Math.min(getMaxEnergy()-getEnergy(), amount);
|
||||
setEnergy(toUse + getEnergy());
|
||||
return toUse;
|
||||
}
|
||||
|
||||
public boolean canReceiveEnergy(ForgeDirection side) {
|
||||
return getConsumingSides().contains(side);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,80 +15,80 @@ public class Region3 {
|
|||
|
||||
|
||||
public Region3() {
|
||||
this(new Vector3(), new Vector3());
|
||||
this(new Vector3(), new Vector3());
|
||||
}
|
||||
|
||||
public Region3(Vector3 min, Vector3 max) {
|
||||
this.min = min;
|
||||
this.max = 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);
|
||||
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);
|
||||
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());
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
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<Vector3> 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<Vector3> 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<Entity> getEntities(World world, Class<? extends Entity> entityClass) {
|
||||
return world.getEntitiesWithinAABB(entityClass, this.toAABB());
|
||||
}
|
||||
|
||||
public List getEntitiesExlude(World world, Entity entity) {
|
||||
return world.getEntitiesWithinAABBExcludingEntity(entity, this.toAABB());
|
||||
public List<Entity> getEntitiesExlude(World world, Entity entity) {
|
||||
return world.getEntitiesWithinAABBExcludingEntity(entity, this.toAABB());
|
||||
}
|
||||
|
||||
public List getEntities(World world) {
|
||||
return this.getEntities(world, Entity.class);
|
||||
public List<Entity> getEntities(World world) {
|
||||
return this.getEntities(world, Entity.class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue