Switched to UE Vector3 and IItemElectric

This commit is contained in:
Calclavia 2013-08-06 18:47:34 -04:00
parent 4324901ee4
commit b4cc4cc925
32 changed files with 597 additions and 1040 deletions

@ -1 +1 @@
Subproject commit 21c943dc1b2bbf864af208790338d68ca7912fea Subproject commit ca595286ebfe50a12300ba8490266aadce44c86d

View file

@ -30,6 +30,5 @@ package org.modstats;
public interface IModstatsReporter public interface IModstatsReporter
{ {
public void registerMod(Object mod); public void registerMod(Object mod);
public void doManualCheck(); public void doManualCheck();
} }

View file

@ -40,6 +40,7 @@ public class ModVersionData
public Map<String, String> extraFields; public Map<String, String> extraFields;
public ModVersionData() public ModVersionData()
{ {
extraFields = new HashMap<String, String>(); extraFields = new HashMap<String, String>();
@ -80,38 +81,34 @@ public class ModVersionData
{ {
if (other.changeLogUrl != null) if (other.changeLogUrl != null)
return false; return false;
} } else if (!changeLogUrl.equals(other.changeLogUrl))
else if (!changeLogUrl.equals(other.changeLogUrl))
return false; return false;
if (downloadUrl == null) if (downloadUrl == null)
{ {
if (other.downloadUrl != null) if (other.downloadUrl != null)
return false; return false;
} } else if (!downloadUrl.equals(other.downloadUrl))
else if (!downloadUrl.equals(other.downloadUrl))
return false; return false;
if (name == null) if (name == null)
{ {
if (other.name != null) if (other.name != null)
return false; return false;
} } else if (!name.equals(other.name))
else if (!name.equals(other.name))
return false; return false;
if (prefix == null) if (prefix == null)
{ {
if (other.prefix != null) if (other.prefix != null)
return false; return false;
} } else if (!prefix.equals(other.prefix))
else if (!prefix.equals(other.prefix))
return false; return false;
if (version == null) if (version == null)
{ {
if (other.version != null) if (other.version != null)
return false; return false;
} } else if (!version.equals(other.version))
else if (!version.equals(other.version))
return false; return false;
return true; return true;
} }
} }

View file

@ -46,7 +46,7 @@ public class ModsUpdateEvent extends Event
public void add(ModVersionData data) public void add(ModVersionData data)
{ {
if (!updatedMods.contains(data)) if(!updatedMods.contains(data))
{ {
updatedMods.add(data); updatedMods.add(data);
} }

View file

@ -38,21 +38,18 @@ public @interface ModstatInfo
{ {
/** /**
* Modstats mod prefix. * Modstats mod prefix.
*
* @return * @return
*/ */
public String prefix(); public String prefix();
/** /**
* Mod name. Use this if your mod doesn't have @Mod annotation * Mod name. Use this if your mod doesn't have @Mod annotation
*
* @return * @return
*/ */
public String name() default ""; public String name() default "";
/** /**
* Mod version. Use this if your mod doesn't have @Mod annotation * Mod version. Use this if your mod doesn't have @Mod annotation
*
* @return * @return
*/ */
public String version() default ""; public String version() default "";

View file

@ -47,25 +47,24 @@ public class Modstats
private IModstatsReporter locateReporter() private IModstatsReporter locateReporter()
{ {
int i = 1; int i=1;
Class<?> latest = null; Class<?> latest = null;
while (i < 100) while(i<100)
{ {
try try
{ {
Class<?> candidate = Class.forName(String.format(CLASS_TEMPLATE, i)); Class<?> candidate = Class.forName(String.format(CLASS_TEMPLATE, i));
if (IModstatsReporter.class.isAssignableFrom(candidate)) if(IModstatsReporter.class.isAssignableFrom(candidate))
{ {
latest = candidate; latest = candidate;
} }
} }
catch (Exception e) catch (Exception e) {
{
break; break;
} }
i++; i++;
} }
if (latest == null) if(latest == null)
{ {
FMLLog.warning("Modstats reporter class not found."); FMLLog.warning("Modstats reporter class not found.");
} }
@ -73,9 +72,8 @@ public class Modstats
{ {
try try
{ {
return (IModstatsReporter) latest.newInstance(); return (IModstatsReporter)latest.newInstance();
} } catch (Exception e)
catch (Exception e)
{ {
FMLLog.warning("Modstats reporter class can't be instantiated."); FMLLog.warning("Modstats reporter class can't be instantiated.");
} }

View file

@ -78,16 +78,14 @@ class DataSender extends Thread
this.manual = manual; this.manual = manual;
} }
private String toHexString(byte[] bytes) private String toHexString(byte[] bytes) {
{ char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
char[] hexArray = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
char[] hexChars = new char[bytes.length * 2]; char[] hexChars = new char[bytes.length * 2];
int v; int v;
for (int j = 0; j < bytes.length; j++) for ( int j = 0; j < bytes.length; j++ ) {
{
v = bytes[j] & 0xFF; v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v / 16]; hexChars[j*2] = hexArray[v/16];
hexChars[j * 2 + 1] = hexArray[v % 16]; hexChars[j*2 + 1] = hexArray[v%16];
} }
return new String(hexChars); return new String(hexChars);
} }
@ -95,7 +93,7 @@ class DataSender extends Thread
private String getPlayerId() throws IOException private String getPlayerId() throws IOException
{ {
File statDir = new File(FMLClientHandler.instance().getClient().mcDataDir, "stats"); File statDir = new File(FMLClientHandler.instance().getClient().mcDataDir, "stats");
if (!statDir.exists()) if(!statDir.exists())
{ {
statDir.mkdirs(); statDir.mkdirs();
} }
@ -105,28 +103,28 @@ class DataSender extends Thread
InetAddress address = InetAddress.getLocalHost(); InetAddress address = InetAddress.getLocalHost();
NetworkInterface ni = NetworkInterface.getByInetAddress(address); NetworkInterface ni = NetworkInterface.getByInetAddress(address);
byte[] macArray = ni.getHardwareAddress(); byte[] macArray = ni.getHardwareAddress();
if (macArray != null) if(macArray != null)
{ {
mac = toHexString(macArray); mac = toHexString(macArray);
} }
} }
catch (Exception ex) catch(Exception ex)
{ {
} }
File uidFile = new File(statDir, "player.uid"); File uidFile = new File(statDir, "player.uid");
if (uidFile.exists() && uidFile.canRead() && uidFile.length() == 32 + mac.length()) if(uidFile.exists() && uidFile.canRead() && uidFile.length() == 32+mac.length())
{ {
String data = Files.toString(uidFile, Charsets.US_ASCII); String data = Files.toString(uidFile, Charsets.US_ASCII);
String storedMac = data.substring(32); String storedMac = data.substring(32);
if (storedMac.equalsIgnoreCase(mac)) if(storedMac.equalsIgnoreCase(mac))
return data.substring(0, 32); return data.substring(0, 32);
} }
uidFile.createNewFile(); uidFile.createNewFile();
if (uidFile.canWrite()) if(uidFile.canWrite())
{ {
String uid = UUID.randomUUID().toString().replace("-", ""); String uid = UUID.randomUUID().toString().replace("-", "");
FileOutputStream output = new FileOutputStream(uidFile); FileOutputStream output = new FileOutputStream(uidFile);
output.write((uid + mac).getBytes()); output.write((uid+mac).getBytes());
output.close(); output.close();
return uid; return uid;
} }
@ -153,13 +151,14 @@ class DataSender extends Thread
return new ComparableVersion(received).compareTo(new ComparableVersion(current)) > 0; return new ComparableVersion(received).compareTo(new ComparableVersion(current)) > 0;
} }
private void parseResponse(String response) private void parseResponse(String response)
{ {
try try
{ {
JsonRootNode json = (new JdomParser()).parse(response); JsonRootNode json = (new JdomParser()).parse(response);
// empty result //empty result
if (!json.isNode("mods")) if(!json.isNode("mods"))
{ {
FMLLog.info("[Modstats] Empty result"); FMLLog.info("[Modstats] Empty result");
return; return;
@ -169,36 +168,36 @@ class DataSender extends Thread
for (JsonNode modObject : modList) for (JsonNode modObject : modList)
{ {
String prefix = modObject.getStringValue("code"); String prefix = modObject.getStringValue("code");
if (!reporter.registeredMods.containsKey(prefix)) if(!reporter.registeredMods.containsKey(prefix))
{ {
FMLLog.warning("[Modstats] Extra mod '%s' in service response", prefix); FMLLog.warning("[Modstats] Extra mod '%s' in service response", prefix);
continue; continue;
} }
String version = modObject.getStringValue("ver"); String version = modObject.getStringValue("ver");
if (version == null || version.equals(reporter.registeredMods.get(prefix).version)) if(version==null || version.equals(reporter.registeredMods.get(prefix).version))
{ {
continue; continue;
} }
if (checkIsNewer(reporter.registeredMods.get(prefix).version, version)) if(checkIsNewer(reporter.registeredMods.get(prefix).version, version))
{ {
ModVersionData data = new ModVersionData(prefix, reporter.registeredMods.get(prefix).name, version); ModVersionData data = new ModVersionData(prefix, reporter.registeredMods.get(prefix).name, version);
Map<JsonStringNode, JsonNode> fields = modObject.getFields(); Map<JsonStringNode, JsonNode> fields = modObject.getFields();
for (Map.Entry<JsonStringNode, JsonNode> entry : fields.entrySet()) for (Map.Entry<JsonStringNode, JsonNode> entry : fields.entrySet())
{ {
String fieldName = entry.getKey().getText(); String fieldName = entry.getKey().getText();
if (fieldName.equals("code") || fieldName.equals("ver")) if(fieldName.equals("code") || fieldName.equals("ver"))
continue; continue;
if (!(entry.getValue() instanceof JsonStringNode)) if(!(entry.getValue() instanceof JsonStringNode))
{ {
FMLLog.warning(String.format("[Modstats] Too complex data in response for field '%s'.", fieldName)); FMLLog.warning(String.format("[Modstats] Too complex data in response for field '%s'.", fieldName));
continue; continue;
} }
String value = ((JsonStringNode) entry.getValue()).getText(); String value = ((JsonStringNode)entry.getValue()).getText();
if (fieldName.equals("chlog")) if(fieldName.equals("chlog"))
{ {
data.changeLogUrl = value; data.changeLogUrl = value;
} }
else if (fieldName.equals("link")) else if(fieldName.equals("link"))
{ {
data.downloadUrl = value; data.downloadUrl = value;
} }
@ -211,50 +210,53 @@ class DataSender extends Thread
} }
} }
if (event.getUpdatedMods().size() > 0) if(event.getUpdatedMods().size() > 0)
{ {
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
} }
if (!event.isCanceled() && event.getUpdatedMods().size() > 0) if(!event.isCanceled() && event.getUpdatedMods().size() > 0)
{ {
List<ModVersionData> updatedModsToOutput = event.getUpdatedMods(); List<ModVersionData> updatedModsToOutput = event.getUpdatedMods();
StringBuilder builder = new StringBuilder("Updates found: "); StringBuilder builder = new StringBuilder("Updates found: ");
Iterator<ModVersionData> iterator = updatedModsToOutput.iterator(); Iterator<ModVersionData> iterator = updatedModsToOutput.iterator();
while (iterator.hasNext()) while(iterator.hasNext())
{ {
ModVersionData modVersionData = iterator.next(); ModVersionData modVersionData = iterator.next();
builder.append(modVersionData.name).append(" (").append(modVersionData.version).append(")").append(iterator.hasNext() ? "," : "."); builder.append(modVersionData.name)
.append(" (")
.append(modVersionData.version)
.append(")")
.append(iterator.hasNext()?",":".");
} }
FMLLog.info("[Modstats] %s", builder.toString()); FMLLog.info("[Modstats] %s", builder.toString());
if (!reporter.config.logOnly && FMLCommonHandler.instance().getSide().isClient()) if(!reporter.config.logOnly && FMLCommonHandler.instance().getSide().isClient())
{ {
Minecraft mc = FMLClientHandler.instance().getClient(); Minecraft mc = FMLClientHandler.instance().getClient();
int maxTries = 30; int maxTries = 30;
while (mc.thePlayer == null && maxTries > 0) while(mc.thePlayer==null && maxTries>0)
{ {
try try
{ {
sleep(1000); sleep(1000);
} } catch (InterruptedException e)
catch (InterruptedException e)
{ {
} }
maxTries--; maxTries--;
} }
if (mc.thePlayer != null) if(mc.thePlayer != null)
{ {
mc.thePlayer.addChatMessage(builder.toString()); mc.thePlayer.addChatMessage(builder.toString());
} }
} }
} }
} } catch (InvalidSyntaxException e)
catch (InvalidSyntaxException e)
{ {
FMLLog.warning("[Modstats] Can't parse response: '%s'.", e.getMessage()); FMLLog.warning("[Modstats] Can't parse response: '%s'.", e.getMessage());
} }
} }
@Override @Override
public void run() public void run()
{ {
@ -262,8 +264,8 @@ class DataSender extends Thread
{ {
String data = getData(); String data = getData();
String playerId = getPlayerId(); String playerId = getPlayerId();
String hash = getSignature(playerId + "!" + data); String hash = getSignature(playerId+"!"+data);
String template = manual ? urlManualTemplate : urlAutoTemplate; String template = manual?urlManualTemplate:urlAutoTemplate;
String mcVersion = new CallableMinecraftVersion(null).minecraftVersion(); String mcVersion = new CallableMinecraftVersion(null).minecraftVersion();
URL url = new URL(String.format(template, mcVersion, playerId, data, hash, reporter.config.betaNotifications, reporter.config.forCurrentMinecraftVersion)); URL url = new URL(String.format(template, mcVersion, playerId, data, hash, reporter.config.betaNotifications, reporter.config.forCurrentMinecraftVersion));
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
@ -272,25 +274,21 @@ class DataSender extends Thread
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line; String line;
String out = ""; String out = "";
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null) {
{ //in most cases it will contain just one line
// in most cases it will contain just one line
out += line; out += line;
} }
reader.close(); reader.close();
parseResponse(out); parseResponse(out);
} } catch (MalformedURLException e)
catch (MalformedURLException e)
{ {
FMLLog.warning("[Modstats] Invalid stat report url"); FMLLog.warning("[Modstats] Invalid stat report url");
} } catch (IOException e)
catch (IOException e)
{ {
FMLLog.info("[Modstats] Stat wasn't reported '" + e.getMessage() + "'"); FMLLog.info("[Modstats] Stat wasn't reported '"+e.getMessage()+"'");
} } catch(Exception e)
catch (Exception e)
{ {
FMLLog.warning("[Modstats] Something wrong: " + e.toString()); FMLLog.warning("[Modstats] Something wrong: "+e.toString());
} }
} }
} }

View file

@ -42,6 +42,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
public class Reporter implements IModstatsReporter public class Reporter implements IModstatsReporter
{ {
@ -62,19 +63,20 @@ public class Reporter implements IModstatsReporter
config = new Config(); config = new Config();
} }
private void startCheck(boolean manual) private void startCheck(boolean manual)
{ {
if (!config.allowUpdates) if(!config.allowUpdates)
return; return;
// only manual check is allowed on servers //only manual check is allowed on servers
if (!FMLCommonHandler.instance().getSide().isClient() && !manual) if(!FMLCommonHandler.instance().getSide().isClient() && !manual)
return; return;
if (registeredMods.isEmpty()) if(registeredMods.isEmpty())
return; return;
DataSender currentSender = sender; DataSender currentSender = sender;
if (!manual && checkedAuto) if(!manual && checkedAuto)
return; return;
if (currentSender != null && (currentSender.manual == false || manual)) if(currentSender!=null && (currentSender.manual == false || manual))
return; return;
currentSender = new DataSender(this, manual); currentSender = new DataSender(this, manual);
currentSender.start(); currentSender.start();
@ -88,38 +90,39 @@ public class Reporter implements IModstatsReporter
startCheck(false); startCheck(false);
} }
@Override @Override
public void registerMod(Object mod) public void registerMod(Object mod)
{ {
if (!config.allowUpdates) if(!config.allowUpdates)
return; return;
if (mod == null) if(mod == null)
{ {
FMLLog.warning("[Modstats] Can't register null mod."); FMLLog.warning("[Modstats] Can't register null mod.");
return; return;
} }
ModstatInfo info = mod.getClass().getAnnotation(ModstatInfo.class); ModstatInfo info = mod.getClass().getAnnotation(ModstatInfo.class);
if (info == null) if(info == null)
{ {
FMLLog.warning("[Modstats] ModstatsInfo annotation not found for given mod."); FMLLog.warning("[Modstats] ModstatsInfo annotation not found for given mod.");
return; return;
} }
if (info.prefix() == null || info.prefix().equals("")) if(info.prefix() == null || info.prefix().equals(""))
{ {
FMLLog.warning("[Modstats] Mod prefix can't be empty."); FMLLog.warning("[Modstats] Mod prefix can't be empty.");
return; return;
} }
Mod modData = mod.getClass().getAnnotation(Mod.class); Mod modData = mod.getClass().getAnnotation(Mod.class);
ModVersionData data; ModVersionData data;
if (modData == null) if(modData == null)
{ {
if (info.name() == null || info.name().equals("")) if(info.name() == null || info.name().equals(""))
{ {
FMLLog.warning("[Modstats] Mod name can't be empty."); FMLLog.warning("[Modstats] Mod name can't be empty.");
return; return;
} }
if (info.version() == null || info.version().equals("")) if(info.version() == null || info.version().equals(""))
{ {
FMLLog.warning("[Modstats] Mod version can't be empty."); FMLLog.warning("[Modstats] Mod version can't be empty.");
return; return;

View file

@ -5,7 +5,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import resonantinduction.base.Vector3;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
import resonantinduction.contractor.TileEntityEMContractor; import resonantinduction.contractor.TileEntityEMContractor;
import resonantinduction.fx.FXElectricBolt; import resonantinduction.fx.FXElectricBolt;
@ -18,6 +17,7 @@ import resonantinduction.render.RenderEMContractor;
import resonantinduction.render.RenderMultimeter; import resonantinduction.render.RenderMultimeter;
import resonantinduction.render.RenderTesla; import resonantinduction.render.RenderTesla;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;

View file

@ -6,11 +6,11 @@ package resonantinduction;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.base.Vector3;
import resonantinduction.battery.ContainerBattery; import resonantinduction.battery.ContainerBattery;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
import resonantinduction.multimeter.ContainerMultimeter; import resonantinduction.multimeter.ContainerMultimeter;
import resonantinduction.multimeter.TileEntityMultimeter; import resonantinduction.multimeter.TileEntityMultimeter;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IGuiHandler;
/** /**

View file

@ -4,15 +4,15 @@ import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.modstats.ModstatInfo;
import org.modstats.Modstats;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import resonantinduction.api.IBattery;
import org.modstats.ModstatInfo;
import org.modstats.Modstats;
import resonantinduction.battery.BlockBattery; import resonantinduction.battery.BlockBattery;
import resonantinduction.battery.ItemCapacitor; import resonantinduction.battery.ItemCapacitor;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
@ -26,6 +26,7 @@ import resonantinduction.multimeter.ItemBlockMultimeter;
import resonantinduction.multimeter.TileEntityMultimeter; import resonantinduction.multimeter.TileEntityMultimeter;
import resonantinduction.tesla.BlockTesla; import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import universalelectricity.core.item.IItemElectric;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
@ -201,7 +202,7 @@ public class ResonantInduction
* Recipes * Recipes
*/ */
ItemStack emptyCapacitor = new ItemStack(itemCapacitor); ItemStack emptyCapacitor = new ItemStack(itemCapacitor);
((IBattery) itemCapacitor).setEnergyStored(emptyCapacitor, 0); ((IItemElectric) itemCapacitor).setElectricity(emptyCapacitor, 0);
/** Capacitor **/ /** Capacitor **/
GameRegistry.addRecipe(new ShapedOreRecipe(emptyCapacitor, "RRR", "RIR", "RRR", 'R', Item.redstone, 'I', Item.ingotIron)); GameRegistry.addRecipe(new ShapedOreRecipe(emptyCapacitor, "RRR", "RIR", "RRR", 'R', Item.redstone, 'I', Item.ingotIron));

View file

@ -1,27 +0,0 @@
/**
*
*/
package resonantinduction.api;
import net.minecraft.item.ItemStack;
/**
* TODO: Use UE interface after ModJAm
*
* @author Calclavia
*
*/
public interface IBattery
{
public float getEnergyStored(ItemStack itemStack);
public float getMaxEnergyStored(ItemStack itemStack);
public float getTransfer(ItemStack itemStack);
/**
* @param itemStack
* @param amount
*/
public void setEnergyStored(ItemStack itemStack, float amount);
}

View file

@ -1,365 +0,0 @@
/**
*
*/
package resonantinduction.base;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/**
* @author Calclavia
*
*/
public class Vector3
{
public double x, y, z;
public Vector3(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
public Vector3()
{
this(0, 0, 0);
}
public Vector3(double amount)
{
this(amount, amount, amount);
}
public Vector3(Vector3 clone)
{
this(clone.x, clone.y, clone.z);
}
public Vector3(TileEntity tileEntity)
{
this(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
}
public Vector3(Entity entity)
{
this(entity.posX, entity.posY, entity.posZ);
}
public Vector3(ForgeDirection direction)
{
this(direction.offsetX, direction.offsetY, direction.offsetZ);
}
public Vector3 scale(double amount)
{
return this.scale(new Vector3(amount));
}
public Vector3 scale(Vector3 amount)
{
return new Vector3(this.x * amount.x, this.y * amount.y, this.z * amount.z);
}
public Vector3 difference(Vector3 compare)
{
return new Vector3(this.x - compare.x, this.y - compare.y, this.z - compare.z);
}
public double getMagnitudeSquared()
{
return this.x * this.x + this.y * this.y + this.z * this.z;
}
public double getMagnitude()
{
return Math.sqrt(this.getMagnitudeSquared());
}
public double distance(Vector3 compare)
{
Vector3 difference = this.difference(compare);
return difference.getMagnitude();
}
/**
* Cross product functions
*
* @return The cross product between this vector and another.
*/
public Vector3 crossProduct(Vector3 compare)
{
return new Vector3(this.y * compare.z - this.z * compare.y, this.z * compare.x - this.x * compare.z, this.x * compare.y - this.y * compare.x);
}
public Vector3 xCrossProduct()
{
return new Vector3(0.0D, this.z, -this.y);
}
public Vector3 zCrossProduct()
{
return new Vector3(-this.y, this.x, 0.0D);
}
public double dotProduct(Vector3 vec2)
{
return this.x * vec2.x + this.y * vec2.y + this.z * vec2.z;
}
public Vector3 getFromSide(ForgeDirection side)
{
return new Vector3(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
}
/**
* @return The perpendicular vector.
*/
public Vector3 getPerpendicular()
{
if (this.z == 0.0F)
{
return this.zCrossProduct();
}
return this.xCrossProduct();
}
/**
* @return True if this Vector3 is zero.
*/
public boolean isZero()
{
return (this.x == 0.0F) && (this.y == 0.0F) && (this.z == 0.0F);
}
public Vector3 translate(Vector3 offset)
{
return new Vector3(this.x + offset.x, this.y + offset.y, this.z + offset.z);
}
public Vector3 translate(double offset)
{
return new Vector3(this.x + offset, this.y + offset, this.z + offset);
}
public Vector3 normalize()
{
double d = getMagnitude();
if (d != 0)
{
return scale(1 / d);
}
return this;
}
/**
* Rotate by a this vector around an axis.
*
* @return The new Vector3 rotation.
*/
public Vector3 rotate(float angle, Vector3 axis)
{
return translateMatrix(getRotationMatrix(angle, axis), this.clone());
}
public double[] getRotationMatrix(float angle)
{
double[] matrix = new double[16];
Vector3 axis = this.clone().normalize();
double x = axis.x;
double y = axis.y;
double z = axis.z;
angle *= 0.0174532925D;
float cos = (float) Math.cos(angle);
float ocos = 1.0F - cos;
float sin = (float) Math.sin(angle);
matrix[0] = (x * x * ocos + cos);
matrix[1] = (y * x * ocos + z * sin);
matrix[2] = (x * z * ocos - y * sin);
matrix[4] = (x * y * ocos - z * sin);
matrix[5] = (y * y * ocos + cos);
matrix[6] = (y * z * ocos + x * sin);
matrix[8] = (x * z * ocos + y * sin);
matrix[9] = (y * z * ocos - x * sin);
matrix[10] = (z * z * ocos + cos);
matrix[15] = 1.0F;
return matrix;
}
public static Vector3 translateMatrix(double[] matrix, Vector3 translation)
{
double x = translation.x * matrix[0] + translation.y * matrix[1] + translation.z * matrix[2] + matrix[3];
double y = translation.x * matrix[4] + translation.y * matrix[5] + translation.z * matrix[6] + matrix[7];
double z = translation.x * matrix[8] + translation.y * matrix[9] + translation.z * matrix[10] + matrix[11];
translation.x = x;
translation.y = y;
translation.z = z;
return translation;
}
public static double[] getRotationMatrix(float angle, Vector3 axis)
{
return axis.getRotationMatrix(angle);
}
public static Vector3 getDeltaPositionFromRotation(double rotationYaw, double rotationPitch)
{
rotationYaw = rotationYaw + 90;
rotationPitch = -rotationPitch;
return new Vector3(Math.cos(Math.toRadians(rotationYaw)), Math.sin(Math.toRadians(rotationPitch)), Math.sin(Math.toRadians(rotationYaw)));
}
public double[] getDeltaRotationFromPosition()
{
double rotationPitch = Math.toDegrees(Math.asin(this.y));
double rotationYaw = Math.toDegrees(Math.atan2(this.z, this.x));
rotationYaw = rotationYaw - 90;
rotationPitch = -rotationPitch;
return new double[] { MathHelper.wrapAngleTo180_double(rotationYaw), MathHelper.wrapAngleTo180_double(rotationPitch) };
}
public double getAngle(Vector3 vector)
{
return this.getAnglePreNorm(vector.clone().normalize());
}
public double getAnglePreNorm(Vector3 vector)
{
return Math.acos(this.dotProduct(vector));
}
public TileEntity getTileEntity(World world)
{
return world.getBlockTileEntity((int) this.x, (int) this.y, (int) this.z);
}
public MovingObjectPosition rayTraceEntities(World world, Vector3 target)
{
MovingObjectPosition pickedEntity = null;
Vec3 startingPosition = this.toVec3();
Vec3 look = target.clone().difference(this).normalize().toVec3();
double reachDistance = this.distance(target);
Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);
double checkBorder = 1.1 * reachDistance;
AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z);
@SuppressWarnings("unchecked")
List<Entity> entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan);
double closestEntity = reachDistance;
if (entitiesHit == null || entitiesHit.isEmpty())
{
return null;
}
for (Entity entityHit : entitiesHit)
{
if (entityHit != null && entityHit.canBeCollidedWith() && entityHit.boundingBox != null)
{
float border = entityHit.getCollisionBorderSize();
AxisAlignedBB aabb = entityHit.boundingBox.expand(border, border, border);
MovingObjectPosition hitMOP = aabb.calculateIntercept(startingPosition, reachPoint);
if (hitMOP != null)
{
if (aabb.isVecInside(startingPosition))
{
if (0.0D < closestEntity || closestEntity == 0.0D)
{
pickedEntity = new MovingObjectPosition(entityHit);
if (pickedEntity != null)
{
pickedEntity.hitVec = hitMOP.hitVec;
closestEntity = 0.0D;
}
}
}
else
{
double distance = startingPosition.distanceTo(hitMOP.hitVec);
if (distance < closestEntity || closestEntity == 0.0D)
{
pickedEntity = new MovingObjectPosition(entityHit);
pickedEntity.hitVec = hitMOP.hitVec;
closestEntity = distance;
}
}
}
}
}
return pickedEntity;
}
private Vec3 toVec3()
{
return Vec3.createVectorHelper(this.x, this.y, this.z);
}
@Override
public Vector3 clone()
{
return new Vector3(this.x, this.y, this.z);
}
@Override
public int hashCode()
{
int code = 1;
code = 31 * new Double(x).hashCode();
code = 31 * new Double(y).hashCode();
code = 31 * new Double(z).hashCode();
return code;
}
@Override
public boolean equals(Object o)
{
if (o instanceof Vector3)
{
Vector3 vector3 = (Vector3) o;
return this.x == vector3.x && this.y == vector3.y && this.z == vector3.z;
}
return false;
}
@Override
public String toString()
{
return "Vector3 [" + this.x + "," + this.y + "," + this.z + "]";
}
/**
* @param world
* @return
*/
public int getBlockID(World world)
{
return world.getBlockId((int) this.x, (int) this.y, (int) this.z);
}
public ForgeDirection toForgeDirection()
{
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
if (this.x == direction.offsetX && this.y == direction.offsetY && this.z == direction.offsetZ)
{
return direction;
}
}
return ForgeDirection.UNKNOWN;
}
}

View file

@ -3,7 +3,7 @@ package resonantinduction.battery;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import resonantinduction.api.IBattery; import universalelectricity.core.item.IItemElectric;
public class BatteryManager public class BatteryManager
{ {
@ -33,7 +33,7 @@ public class BatteryManager
@Override @Override
public boolean isItemValid(ItemStack itemstack) public boolean isItemValid(ItemStack itemstack)
{ {
return itemstack.getItem() instanceof IBattery; return itemstack.getItem() instanceof IItemElectric;
} }
} }
} }

View file

@ -11,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.base.ListUtil; import resonantinduction.base.ListUtil;
import resonantinduction.base.Vector3; import universalelectricity.core.vector.Vector3;
public class BatteryUpdateProtocol public class BatteryUpdateProtocol
{ {
@ -179,7 +179,7 @@ public class BatteryUpdateProtocol
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
TileEntity tileEntity = new Vector3(tile).getFromSide(side).getTileEntity(tile.worldObj); TileEntity tileEntity = new Vector3(tile).modifyPositionFromSide(side).getTileEntity(tile.worldObj);
if (tileEntity instanceof TileEntityBattery) if (tileEntity instanceof TileEntityBattery)
{ {

View file

@ -12,10 +12,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.api.IBattery;
import resonantinduction.base.BlockBase; import resonantinduction.base.BlockBase;
import resonantinduction.base.ListUtil; import resonantinduction.base.ListUtil;
import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.BlockRenderingHandler;
import universalelectricity.core.item.IItemElectric;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -63,7 +63,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
{ {
if (entityPlayer.getCurrentEquippedItem() != null) if (entityPlayer.getCurrentEquippedItem() != null)
{ {
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IBattery) if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IItemElectric)
{ {
if (side != 0 && side != 1) if (side != 0 && side != 1)
{ {

View file

@ -6,9 +6,9 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import resonantinduction.api.IBattery;
import resonantinduction.battery.BatteryManager.SlotBattery; import resonantinduction.battery.BatteryManager.SlotBattery;
import resonantinduction.battery.BatteryManager.SlotOut; import resonantinduction.battery.BatteryManager.SlotOut;
import universalelectricity.core.item.IItemElectric;
public class ContainerBattery extends Container public class ContainerBattery extends Container
{ {
@ -100,7 +100,7 @@ public class ContainerBattery extends Container
return null; return null;
} }
} }
else if (slotStack.getItem() instanceof IBattery) else if (slotStack.getItem() instanceof IItemElectric)
{ {
if (!mergeItemStack(slotStack, 0, 1, false)) if (!mergeItemStack(slotStack, 0, 1, false))
{ {

View file

@ -3,15 +3,13 @@
*/ */
package resonantinduction.battery; package resonantinduction.battery;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.api.IBattery; import net.minecraftforge.common.Configuration;
import resonantinduction.base.ItemBase; import resonantinduction.ResonantInduction;
import resonantinduction.TabRI;
import universalelectricity.compatibility.ItemUniversalElectric;
/** /**
* Stores power. * Stores power.
@ -19,52 +17,22 @@ import resonantinduction.base.ItemBase;
* @author Calclavia * @author Calclavia
* *
*/ */
public class ItemCapacitor extends ItemBase implements IBattery public class ItemCapacitor extends ItemUniversalElectric
{ {
public ItemCapacitor(int id) public ItemCapacitor(int id)
{ {
super("capacitor", id); super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "capacitor", id).getInt(id));
this.setCreativeTab(TabRI.INSTANCE);
this.setUnlocalizedName(ResonantInduction.PREFIX + "capacitor");
this.func_111206_d(ResonantInduction.PREFIX + "capacitor");
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setMaxDamage(100); this.setMaxDamage(100);
} }
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
double energyStored = this.getEnergyStored(itemStack);
par3List.add("Energy: " + (int) energyStored + "/" + (int) this.getMaxEnergyStored(itemStack) + " KJ");
}
@Override @Override
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{ {
this.setEnergyStored(par1ItemStack, 0); this.setElectricity(par1ItemStack, 0);
}
@Override
public void setEnergyStored(ItemStack itemStack, float amount)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.getTagCompound().setFloat("energyStored", amount);
itemStack.setItemDamage((int) (100 - (amount / getMaxEnergyStored(itemStack)) * 100));
}
@Override
public float getEnergyStored(ItemStack itemStack)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
float amount = itemStack.getTagCompound().getFloat("energyStored");
itemStack.setItemDamage((int) (100 - (amount / getMaxEnergyStored(itemStack)) * 100));
return amount;
} }
@Override @Override
@ -74,20 +42,9 @@ public class ItemCapacitor extends ItemBase implements IBattery
} }
@Override @Override
public float getMaxEnergyStored(ItemStack itemStack) public float getMaxElectricityStored(ItemStack theItem)
{ {
return 20; return 25;
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
ItemStack chargedStack = new ItemStack(par1, 1, 0);
this.setEnergyStored(chargedStack, this.getMaxEnergyStored(chargedStack));
par3List.add(chargedStack);
ItemStack unchargedStack = new ItemStack(par1, 1, 0);
this.setEnergyStored(unchargedStack, 0);
par3List.add(unchargedStack);
} }
} }

View file

@ -6,9 +6,9 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import resonantinduction.api.IBattery;
import resonantinduction.base.ListUtil; import resonantinduction.base.ListUtil;
import resonantinduction.base.Vector3; import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
public class SynchronizedBatteryData public class SynchronizedBatteryData
{ {
@ -65,7 +65,7 @@ public class SynchronizedBatteryData
for (int i = 0; i < toSort.length - 1; i++) for (int i = 0; i < toSort.length - 1; i++)
{ {
if (((IBattery) toSort[i].getItem()).getEnergyStored(toSort[i]) < ((IBattery) toSort[i + 1].getItem()).getEnergyStored(toSort[i + 1])) if (((IItemElectric) toSort[i].getItem()).getElectricityStored(toSort[i]) < ((IItemElectric) toSort[i + 1].getItem()).getElectricityStored(toSort[i + 1]))
{ {
temp = toSort[i]; temp = toSort[i];
toSort[i] = toSort[i + 1]; toSort[i] = toSort[i + 1];

View file

@ -13,13 +13,13 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import resonantinduction.PacketHandler; import resonantinduction.PacketHandler;
import resonantinduction.api.IBattery;
import resonantinduction.api.ITesla; import resonantinduction.api.ITesla;
import resonantinduction.base.IPacketReceiver; import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.ListUtil; import resonantinduction.base.ListUtil;
import resonantinduction.base.TileEntityBase; import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3;
import resonantinduction.tesla.TeslaGrid; import resonantinduction.tesla.TeslaGrid;
import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
@ -69,25 +69,25 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
if (structure.visibleInventory[1] != null) if (structure.visibleInventory[1] != null)
{ {
ItemStack itemStack = structure.visibleInventory[1]; ItemStack itemStack = structure.visibleInventory[1];
IBattery battery = (IBattery) itemStack.getItem(); IItemElectric battery = (IItemElectric) itemStack.getItem();
float energyStored = getMaxEnergyStored(); float energyStored = getMaxEnergyStored();
float batteryNeeded = battery.getMaxEnergyStored(itemStack) - battery.getEnergyStored(itemStack); float batteryNeeded = battery.getMaxElectricityStored(itemStack) - battery.getElectricityStored(itemStack);
float toGive = Math.min(energyStored, Math.min(battery.getTransfer(itemStack), batteryNeeded)); float toGive = Math.min(energyStored, Math.min(battery.getTransfer(itemStack), batteryNeeded));
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) + removeEnergy(toGive, true)); battery.setElectricity(itemStack, battery.getElectricityStored(itemStack) + removeEnergy(toGive, true));
} }
if (structure.visibleInventory[2] != null) if (structure.visibleInventory[2] != null)
{ {
ItemStack itemStack = structure.visibleInventory[2]; ItemStack itemStack = structure.visibleInventory[2];
IBattery battery = (IBattery) itemStack.getItem(); IItemElectric battery = (IItemElectric) itemStack.getItem();
float energyNeeded = getMaxEnergyStored() - getEnergyStored(); float energyNeeded = getMaxEnergyStored() - getEnergyStored();
float batteryStored = battery.getEnergyStored(itemStack); float batteryStored = battery.getElectricityStored(itemStack);
float toReceive = Math.min(energyNeeded, Math.min(battery.getTransfer(itemStack), batteryStored)); float toReceive = Math.min(energyNeeded, Math.min(battery.getTransfer(itemStack), batteryStored));
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) - addEnergy(toReceive, true)); battery.setElectricity(itemStack, battery.getElectricityStored(itemStack) - addEnergy(toReceive, true));
} }
if (prevStructure != structure) if (prevStructure != structure)
@ -265,16 +265,16 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
for (ItemStack itemStack : structure.inventory) for (ItemStack itemStack : structure.inventory)
{ {
if (itemStack.getItem() instanceof IBattery) if (itemStack.getItem() instanceof IItemElectric)
{ {
IBattery battery = (IBattery) itemStack.getItem(); IItemElectric battery = (IItemElectric) itemStack.getItem();
float needed = amount - added; float needed = amount - added;
float itemAdd = Math.min(battery.getMaxEnergyStored(itemStack) - battery.getEnergyStored(itemStack), needed); float itemAdd = Math.min(battery.getMaxElectricityStored(itemStack) - battery.getElectricityStored(itemStack), needed);
if (doAdd) if (doAdd)
{ {
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) + itemAdd); battery.setElectricity(itemStack, battery.getElectricityStored(itemStack) + itemAdd);
} }
added += itemAdd; added += itemAdd;
@ -300,16 +300,16 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
for (ItemStack itemStack : inverse) for (ItemStack itemStack : inverse)
{ {
if (itemStack.getItem() instanceof IBattery) if (itemStack.getItem() instanceof IItemElectric)
{ {
IBattery battery = (IBattery) itemStack.getItem(); IItemElectric battery = (IItemElectric) itemStack.getItem();
float needed = amount - removed; float needed = amount - removed;
float itemRemove = Math.min(battery.getEnergyStored(itemStack), needed); float itemRemove = Math.min(battery.getElectricityStored(itemStack), needed);
if (doRemove) if (doRemove)
{ {
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) - itemRemove); battery.setElectricity(itemStack, battery.getElectricityStored(itemStack) - itemRemove);
} }
removed += itemRemove; removed += itemRemove;
@ -334,9 +334,9 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
{ {
if (itemStack != null) if (itemStack != null)
{ {
if (itemStack.getItem() instanceof IBattery) if (itemStack.getItem() instanceof IItemElectric)
{ {
max += ((IBattery) itemStack.getItem()).getMaxEnergyStored(itemStack); max += ((IItemElectric) itemStack.getItem()).getMaxElectricityStored(itemStack);
} }
} }
} }
@ -359,9 +359,9 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
{ {
if (itemStack != null) if (itemStack != null)
{ {
if (itemStack.getItem() instanceof IBattery) if (itemStack.getItem() instanceof IItemElectric)
{ {
energy += ((IBattery) itemStack.getItem()).getEnergyStored(itemStack); energy += ((IItemElectric) itemStack.getItem()).getElectricityStored(itemStack);
} }
} }
} }

View file

@ -9,9 +9,9 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase; import resonantinduction.base.BlockBase;
import resonantinduction.base.Vector3;
import resonantinduction.entangler.ItemCoordLink; import resonantinduction.entangler.ItemCoordLink;
import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.BlockRenderingHandler;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -4,7 +4,6 @@
package resonantinduction.contractor; package resonantinduction.contractor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -12,7 +11,7 @@ import java.util.Set;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.base.Vector3; import universalelectricity.core.vector.Vector3;
/** /**
* Uses the well known A* Pathfinding algorithm. * Uses the well known A* Pathfinding algorithm.

View file

@ -3,7 +3,7 @@
*/ */
package resonantinduction.contractor; package resonantinduction.contractor;
import resonantinduction.base.Vector3; import universalelectricity.core.vector.Vector3;
/** /**
* @author Calclavia * @author Calclavia

View file

@ -23,8 +23,8 @@ import resonantinduction.ResonantInduction;
import resonantinduction.base.IPacketReceiver; import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.InventoryUtil; import resonantinduction.base.InventoryUtil;
import resonantinduction.base.TileEntityBase; import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import universalelectricity.core.vector.Vector3;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;

View file

@ -9,7 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import resonantinduction.base.ItemBase; import resonantinduction.base.ItemBase;
import resonantinduction.base.Vector3; import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -6,7 +6,7 @@ package resonantinduction.entangler;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.base.Vector3; import universalelectricity.core.vector.Vector3;
/** /**
* @author Calclavia * @author Calclavia

View file

@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.base.Vector3; import universalelectricity.core.vector.Vector3;
/** /**
* *

View file

@ -27,7 +27,7 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.base.Vector3; import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -425,7 +425,7 @@ public class FXElectricBolt extends EntityFX
Vector3 prevDiffNorm = this.prev.difference.clone().normalize(); Vector3 prevDiffNorm = this.prev.difference.clone().normalize();
Vector3 diffNorm = this.difference.clone().normalize(); Vector3 diffNorm = this.difference.clone().normalize();
this.prevDiff = diffNorm.translate(prevDiffNorm).normalize(); this.prevDiff = diffNorm.translate(prevDiffNorm).normalize();
this.sinPrev = Math.sin(diffNorm.getAnglePreNorm(prevDiffNorm.scale(-1)) / 2); this.sinPrev = Math.sin(diffNorm.anglePreNorm(prevDiffNorm.scale(-1)) / 2);
} }
else else
{ {
@ -438,7 +438,7 @@ public class FXElectricBolt extends EntityFX
Vector3 nextDiffNorm = this.next.difference.clone().normalize(); Vector3 nextDiffNorm = this.next.difference.clone().normalize();
Vector3 diffNorm = this.difference.clone().normalize(); Vector3 diffNorm = this.difference.clone().normalize();
this.nextDiff = diffNorm.translate(nextDiffNorm).normalize(); this.nextDiff = diffNorm.translate(nextDiffNorm).normalize();
this.sinNext = Math.sin(diffNorm.getAnglePreNorm(nextDiffNorm.scale(-1)) / 2); this.sinNext = Math.sin(diffNorm.anglePreNorm(nextDiffNorm.scale(-1)) / 2);
} }
else else
{ {

View file

@ -22,9 +22,9 @@ import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.base.Vector3;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
import resonantinduction.model.ModelBattery; import resonantinduction.model.ModelBattery;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -86,9 +86,9 @@ public class RenderBattery extends TileEntitySpecialRenderer
for (int slot = 0; slot < 4; slot++) for (int slot = 0; slot < 4; slot++)
{ {
Vector3 sideVec = new Vector3(t).getFromSide(correctSide(direction)); Vector3 sideVec = new Vector3(t).modifyPositionFromSide(correctSide(direction));
if(!t.worldObj.isAirBlock((int)sideVec.x, (int)sideVec.y, (int)sideVec.z)) if (!t.worldObj.isAirBlock((int) sideVec.x, (int) sideVec.y, (int) sideVec.z))
{ {
continue; continue;
} }
@ -154,7 +154,7 @@ public class RenderBattery extends TileEntitySpecialRenderer
private ForgeDirection correctSide(ForgeDirection side) private ForgeDirection correctSide(ForgeDirection side)
{ {
switch(side) switch (side)
{ {
case NORTH: case NORTH:
return ForgeDirection.WEST; return ForgeDirection.WEST;

View file

@ -11,9 +11,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase; import resonantinduction.base.BlockBase;
import resonantinduction.base.Vector3;
import resonantinduction.entangler.ItemCoordLink; import resonantinduction.entangler.ItemCoordLink;
import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.BlockRenderingHandler;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -25,8 +25,8 @@ import resonantinduction.ResonantInduction;
import resonantinduction.api.ITesla; import resonantinduction.api.ITesla;
import resonantinduction.base.IPacketReceiver; import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.TileEntityBase; import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
import universalelectricity.core.vector.Vector3;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;