Updated UE API to 1.2.6
This commit is contained in:
parent
9e41c06f57
commit
d3b8e7ab62
29 changed files with 490 additions and 598 deletions
|
@ -12,7 +12,6 @@ import net.minecraftforge.client.ForgeHooksClient;
|
|||
import universalelectricity.core.vector.Vector3;
|
||||
import assemblyline.client.model.ModelHelper;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.detector.TileEntityDetector;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import universalelectricity.core.UniversalElectricity;
|
|||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.prefab.tile.TileEntityElectricityRunnable;
|
||||
|
||||
public class TIC2Receiver extends TileEntityElectricityRunnable implements IEnergySink
|
||||
public abstract class TIC2Runnable extends TileEntityElectricityRunnable implements IEnergySink
|
||||
{
|
||||
@Override
|
||||
public void initiate()
|
||||
|
@ -48,7 +48,7 @@ public class TIC2Receiver extends TileEntityElectricityRunnable implements IEner
|
|||
@Override
|
||||
public int demandsEnergy()
|
||||
{
|
||||
return (int) (this.getRequest().getWatts() * UniversalElectricity.TO_IC2_RATIO);
|
||||
return (int) Math.ceil(this.getRequest().getWatts() * UniversalElectricity.TO_IC2_RATIO);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -13,7 +13,7 @@ import universalelectricity.prefab.network.PacketManager;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public abstract class TileEntityAssemblyNetwork extends TIC2Receiver
|
||||
public abstract class TileEntityAssemblyNetwork extends TIC2Runnable
|
||||
{
|
||||
public boolean debugMode = true;
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,8 @@ public class CommandGrab extends Command
|
|||
|
||||
public static final float radius = 0.5f;
|
||||
/**
|
||||
* If the grab command is specific to one entity this tell whether or not to grab the child version of that entity.
|
||||
* If the grab command is specific to one entity this tell whether or not to grab the child
|
||||
* version of that entity.
|
||||
*/
|
||||
public boolean child = false;
|
||||
/**
|
||||
|
@ -61,7 +62,10 @@ public class CommandGrab extends Command
|
|||
{
|
||||
super.doTask();
|
||||
|
||||
if (this.tileEntity.getGrabbedEntities().size() > 0) { return false; }
|
||||
if (this.tileEntity.getGrabbedEntities().size() > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 serachPosition = this.tileEntity.getHandPosition();
|
||||
List<Entity> found = this.world.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox(serachPosition.x - radius, serachPosition.y - radius, serachPosition.z - radius, serachPosition.x + radius, serachPosition.y + radius, serachPosition.z + radius));
|
||||
|
|
|
@ -2,11 +2,9 @@ package universalelectricity.core;
|
|||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import universalelectricity.core.electricity.Electricity;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
/**
|
||||
* A class used to load Universal Electricity and make it work.
|
||||
|
|
|
@ -31,7 +31,7 @@ public class UniversalElectricity
|
|||
*/
|
||||
public static final int MAJOR_VERSION = 1;
|
||||
public static final int MINOR_VERSION = 2;
|
||||
public static final int REVISION_VERSION = 5;
|
||||
public static final int REVISION_VERSION = 6;
|
||||
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ public class UniversalElectricity
|
|||
// The amount of UE Joules equivalent to IC2 EU
|
||||
public static double IC2_RATIO = 40;
|
||||
// The amount of UE Joules equivalent to BC Minecraft Joules
|
||||
public static double BC3_RATIO = 400;
|
||||
public static double BC3_RATIO = 100;
|
||||
public static double TO_IC2_RATIO = 1 / IC2_RATIO;
|
||||
public static double TO_BC_RATIO = 1 / BC3_RATIO;
|
||||
|
||||
|
@ -71,19 +71,25 @@ public class UniversalElectricity
|
|||
*/
|
||||
public static void register(Object mod, int major, int minor, int revision, boolean strict)
|
||||
{
|
||||
if (MAJOR_VERSION != major) { throw new RuntimeException("A Universal Electricity mod is way too old! Make sure it is update to v" + major + "." + minor + "." + revision); }
|
||||
if (MAJOR_VERSION != major)
|
||||
{
|
||||
throw new RuntimeException("A Universal Electricity mod " + mod.getClass().getSimpleName() + " is way too old! Make sure it is update to v" + major + "." + minor + "." + revision);
|
||||
}
|
||||
|
||||
if (MINOR_VERSION < minor) { throw new RuntimeException("A Universal Electricity mod is too old! Make sure it is update to v" + major + "." + minor + "." + revision); }
|
||||
if (MINOR_VERSION < minor)
|
||||
{
|
||||
throw new RuntimeException("A Universal Electricity mod " + mod.getClass().getSimpleName() + " is too old! Make sure it is update to v" + major + "." + minor + "." + revision);
|
||||
}
|
||||
|
||||
if (REVISION_VERSION < revision)
|
||||
{
|
||||
if (strict)
|
||||
{
|
||||
throw new RuntimeException("A Universal Electricity mod is too old! Require v" + major + "." + minor + "." + revision);
|
||||
throw new RuntimeException("A Universal Electricity mod " + mod.getClass().getSimpleName() + " is too old! Require v" + major + "." + minor + "." + revision);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.warning("The version of Universal Electricity detected is not the recommended version by the mod. Odd things might happen. Recommended to try v" + major + "." + minor + "." + revision);
|
||||
FMLLog.warning("The version of Universal Electricity detected is not the recommended version by the mod " + mod.getClass().getSimpleName() + ". Odd things might happen. Recommended to try v" + major + "." + minor + "." + revision);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,9 +105,15 @@ public class UniversalElectricity
|
|||
*/
|
||||
public static void forgeLock(int major, int minor, int revision, boolean strict)
|
||||
{
|
||||
if (ForgeVersion.getMajorVersion() != major) { throw new RuntimeException("Universal Electricity: Wrong Minecraft Forge version! Require " + major + "." + minor + "." + revision); }
|
||||
if (ForgeVersion.getMajorVersion() != major)
|
||||
{
|
||||
throw new RuntimeException("Universal Electricity: Wrong Minecraft Forge version! Require " + major + "." + minor + "." + revision);
|
||||
}
|
||||
|
||||
if (ForgeVersion.getMinorVersion() < minor) { throw new RuntimeException("Universal Electricity: Minecraft Forge minor version is too old! Require " + major + "." + minor + "." + revision); }
|
||||
if (ForgeVersion.getMinorVersion() < minor)
|
||||
{
|
||||
throw new RuntimeException("Universal Electricity: Minecraft Forge minor version is too old! Require " + major + "." + minor + "." + revision);
|
||||
}
|
||||
|
||||
if (ForgeVersion.getRevisionVersion() < revision)
|
||||
{
|
||||
|
|
|
@ -146,15 +146,30 @@ public class ElectricInfo
|
|||
unitName = unit.getPlural();
|
||||
}
|
||||
|
||||
if (value == 0) { return value + " " + unitName; }
|
||||
if (value == 0)
|
||||
{
|
||||
return value + " " + unitName;
|
||||
}
|
||||
|
||||
if (value <= MeasurementUnit.MILLI.value) { return roundDecimals(MeasurementUnit.MICRO.process(value), decimalPlaces) + " " + MeasurementUnit.MICRO.getName(isShort) + unitName; }
|
||||
if (value <= MeasurementUnit.MILLI.value)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.MICRO.process(value), decimalPlaces) + " " + MeasurementUnit.MICRO.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
if (value < 1) { return roundDecimals(MeasurementUnit.MILLI.process(value), decimalPlaces) + " " + MeasurementUnit.MILLI.getName(isShort) + unitName; }
|
||||
if (value < 1)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.MILLI.process(value), decimalPlaces) + " " + MeasurementUnit.MILLI.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
if (value > MeasurementUnit.MEGA.value) { return roundDecimals(MeasurementUnit.MEGA.process(value), decimalPlaces) + " " + MeasurementUnit.MEGA.getName(isShort) + unitName; }
|
||||
if (value > MeasurementUnit.MEGA.value)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.MEGA.process(value), decimalPlaces) + " " + MeasurementUnit.MEGA.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
if (value > MeasurementUnit.KILO.value) { return roundDecimals(MeasurementUnit.KILO.process(value), decimalPlaces) + " " + MeasurementUnit.KILO.getName(isShort) + unitName; }
|
||||
if (value > MeasurementUnit.KILO.value)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.KILO.process(value), decimalPlaces) + " " + MeasurementUnit.KILO.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unitName;
|
||||
}
|
||||
|
@ -178,12 +193,18 @@ public class ElectricInfo
|
|||
{
|
||||
if (value > 1)
|
||||
{
|
||||
if (decimalPlaces < 1) { return (int) value + " " + unit.getPlural(); }
|
||||
if (decimalPlaces < 1)
|
||||
{
|
||||
return (int) value + " " + unit.getPlural();
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.getPlural();
|
||||
}
|
||||
|
||||
if (decimalPlaces < 1) { return (int) value + " " + unit.name; }
|
||||
if (decimalPlaces < 1)
|
||||
{
|
||||
return (int) value + " " + unit.name;
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.name;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,10 @@ public class ElectricityConnections
|
|||
{
|
||||
EnumSet<ForgeDirection> enumSet = connectors.get(tileEntity);
|
||||
|
||||
if (enumSet != null) { return enumSet.contains(side); }
|
||||
if (enumSet != null)
|
||||
{
|
||||
return enumSet.contains(side);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -84,14 +84,17 @@ public class ElectricityNetwork
|
|||
}
|
||||
|
||||
/**
|
||||
* @param ignoreTiles The TileEntities to ignore during this calculation. Null will make it not
|
||||
* ignore any.
|
||||
* @return The electricity produced in this electricity network
|
||||
*/
|
||||
public ElectricityPack getProduced()
|
||||
public ElectricityPack getProduced(TileEntity... ignoreTiles)
|
||||
{
|
||||
ElectricityPack totalElectricity = new ElectricityPack(0, 0);
|
||||
|
||||
Iterator it = this.producers.entrySet().iterator();
|
||||
|
||||
loop:
|
||||
while (it.hasNext())
|
||||
{
|
||||
Map.Entry pairs = (Map.Entry) it.next();
|
||||
|
@ -118,6 +121,17 @@ public class ElectricityNetwork
|
|||
continue;
|
||||
}
|
||||
|
||||
if (ignoreTiles != null)
|
||||
{
|
||||
for (TileEntity ignoreTile : ignoreTiles)
|
||||
{
|
||||
if (tileEntity == ignoreTile)
|
||||
{
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ElectricityPack pack = (ElectricityPack) pairs.getValue();
|
||||
|
||||
if (pairs.getKey() != null && pairs.getValue() != null && pack != null)
|
||||
|
@ -137,11 +151,10 @@ public class ElectricityNetwork
|
|||
/**
|
||||
* @return How much electricity this network needs.
|
||||
*/
|
||||
public ElectricityPack getRequest()
|
||||
public ElectricityPack getRequest(TileEntity... ignoreTiles)
|
||||
{
|
||||
ElectricityPack totalElectricity = this.getRequestWithoutReduction();
|
||||
totalElectricity.amperes = Math.max(totalElectricity.amperes - this.getProduced().amperes, 0);
|
||||
|
||||
totalElectricity.amperes = Math.max(totalElectricity.amperes - this.getProduced(ignoreTiles).amperes, 0);
|
||||
return totalElectricity;
|
||||
}
|
||||
|
||||
|
@ -384,7 +397,10 @@ public class ElectricityNetwork
|
|||
{
|
||||
if (ElectricityConnections.isConnector(tileEntity))
|
||||
{
|
||||
if (ElectricityConnections.canConnect(tileEntity, approachDirection.getOpposite())) { return ((IConductor) tileEntity).getNetwork(); }
|
||||
if (ElectricityConnections.canConnect(tileEntity, approachDirection.getOpposite()))
|
||||
{
|
||||
return ((IConductor) tileEntity).getNetwork();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,7 +348,10 @@ public class Vector3 extends Vector2 implements Cloneable
|
|||
|
||||
if (ElectricityConnections.isConnector(tileEntity))
|
||||
{
|
||||
if (ElectricityConnections.canConnect(tileEntity, getOrientationFromSide(side, ForgeDirection.NORTH))) { return tileEntity; }
|
||||
if (ElectricityConnections.canConnect(tileEntity, getOrientationFromSide(side, ForgeDirection.NORTH)))
|
||||
{
|
||||
return tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -26,54 +26,38 @@ public abstract class BlockMachine extends BlockContainer implements ISneakUseWr
|
|||
public BlockMachine(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
this.setHardness(0.5f);
|
||||
this.setHardness(0.6f);
|
||||
}
|
||||
|
||||
public BlockMachine(String name, int id, Material material)
|
||||
public BlockMachine(int id, int textureIndex, Material material)
|
||||
{
|
||||
super(id, textureIndex, material);
|
||||
this.setHardness(0.6f);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BlockMachine(String string, int id, Material material)
|
||||
{
|
||||
this(id, material);
|
||||
this.setBlockName(name);
|
||||
this.setBlockName(string);
|
||||
}
|
||||
|
||||
public BlockMachine(String name, int id, Material material, CreativeTabs creativeTab)
|
||||
@Deprecated
|
||||
public BlockMachine(String string, int id, Material material, CreativeTabs creativeTab)
|
||||
{
|
||||
this(name, id, material);
|
||||
this(string, id, material);
|
||||
this.setCreativeTab(creativeTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata)
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
@Override
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT OVERRIDE THIS FUNCTION! Called when the block is right clicked by the player. This
|
||||
* modified version detects electric items and wrench actions on your machine block. Do not
|
||||
* override this function. Use onMachineActivated instead! (It does the same thing)
|
||||
*
|
||||
* @param world The World Object.
|
||||
* @param x, y, z The coordinate of the block.
|
||||
* @param x , y, z The coordinate of the block.
|
||||
* @param side The side the player clicked on.
|
||||
* @param hitX, hitY, hitZ The position the player clicked on relative to the block.
|
||||
* @param hitX , hitY, hitZ The position the player clicked on relative to the block.
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
|
@ -94,18 +78,22 @@ public abstract class BlockMachine extends BlockContainer implements ISneakUseWr
|
|||
}
|
||||
else if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IItemElectric)
|
||||
{
|
||||
if (this.onUseElectricItem(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ)) { return true; }
|
||||
if (this.onUseElectricItem(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (par5EntityPlayer.isSneaking())
|
||||
{
|
||||
return this.onSneakMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.onMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
|
||||
if (this.onSneakMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return this.onMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +106,11 @@ public abstract class BlockMachine extends BlockContainer implements ISneakUseWr
|
|||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* Called when the machine is being wrenched by a player while sneaking.
|
||||
*
|
||||
* @return True if something happens
|
||||
*/
|
||||
public boolean onSneakMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return false;
|
||||
|
@ -145,7 +137,8 @@ public abstract class BlockMachine extends BlockContainer implements ISneakUseWr
|
|||
}
|
||||
|
||||
/**
|
||||
* Called when a player uses a wrench on the machine while sneaking
|
||||
* Called when a player uses a wrench on the machine while sneaking. Only works with the UE
|
||||
* wrench.
|
||||
*
|
||||
* @return True if some happens
|
||||
*/
|
||||
|
@ -165,12 +158,18 @@ public abstract class BlockMachine extends BlockContainer implements ISneakUseWr
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this if you don't need it. This will eject all items out of this machine if it has
|
||||
* an inventory
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World par1World, int x, int y, int z, int par5, int par6)
|
||||
{
|
||||
this.dropEntireInventory(par1World, x, y, z, par5, par6);
|
||||
super.breakBlock(par1World, x, y, z, par5, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this if you don't need it. This will eject all items out of this machine if it has
|
||||
* an inventory.
|
||||
*/
|
||||
public void dropEntireInventory(World par1World, int x, int y, int z, int par5, int par6)
|
||||
{
|
||||
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
||||
|
||||
|
@ -218,7 +217,5 @@ public abstract class BlockMachine extends BlockContainer implements ISneakUseWr
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, x, y, z, par5, par6);
|
||||
}
|
||||
}
|
||||
|
|
194
src/minecraft/universalelectricity/prefab/GuiBase.java
Normal file
194
src/minecraft/universalelectricity/prefab/GuiBase.java
Normal file
|
@ -0,0 +1,194 @@
|
|||
package universalelectricity.prefab;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class GuiBase extends GuiScreen
|
||||
{
|
||||
/**
|
||||
* The X size of the inventory window in pixels.
|
||||
*/
|
||||
protected int xSize = 176;
|
||||
|
||||
/**
|
||||
* The Y size of the inventory window in pixels.
|
||||
*/
|
||||
protected int ySize = 166;
|
||||
|
||||
/**
|
||||
* Starting X position for the Gui. Inconsistent use for Gui backgrounds.
|
||||
*/
|
||||
protected int guiLeft;
|
||||
|
||||
/**
|
||||
* Starting Y position for the Gui. Inconsistent use for Gui backgrounds.
|
||||
*/
|
||||
protected int guiTop;
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
this.guiLeft = (this.width - this.xSize) / 2;
|
||||
this.guiTop = (this.height - this.ySize) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
int var4 = this.guiLeft;
|
||||
int var5 = this.guiTop;
|
||||
this.drawBackgroundLayer(par1, par2, par3);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) var4, (float) var5, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
short var7 = 240;
|
||||
short var8 = 240;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) var7 / 1.0F, (float) var8 / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.drawForegroundLayer(par1, par2, par3);
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
super.drawScreen(par1, par2, par3);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the foreground layer for the GUI
|
||||
*/
|
||||
protected abstract void drawForegroundLayer(int var2, int var3, float var1);
|
||||
|
||||
/**
|
||||
* Draws the background layer for the GUI
|
||||
*/
|
||||
|
||||
protected abstract void drawBackgroundLayer(int var2, int var3, float var1);
|
||||
|
||||
/**
|
||||
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
|
||||
*/
|
||||
@Override
|
||||
protected void keyTyped(char x, int y)
|
||||
{
|
||||
if (y == 1 || y == this.mc.gameSettings.keyBindInventory.keyCode)
|
||||
{
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this GUI should pause the game when it is displayed in single-player
|
||||
*/
|
||||
@Override
|
||||
public boolean doesGuiPauseGame()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the main game loop to update the screen.
|
||||
*/
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
super.updateScreen();
|
||||
|
||||
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
|
||||
{
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawTooltip(List<String> toolTips, int x, int y)
|
||||
{
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
if (!toolTips.isEmpty())
|
||||
{
|
||||
int var5 = 0;
|
||||
int var6;
|
||||
int var7;
|
||||
|
||||
for (var6 = 0; var6 < toolTips.size(); ++var6)
|
||||
{
|
||||
var7 = this.fontRenderer.getStringWidth((String) toolTips.get(var6));
|
||||
|
||||
if (var7 > var5)
|
||||
{
|
||||
var5 = var7;
|
||||
}
|
||||
}
|
||||
|
||||
var6 = x + 12;
|
||||
var7 = y - 12;
|
||||
int var9 = 8;
|
||||
|
||||
if (toolTips.size() > 1)
|
||||
{
|
||||
var9 += 2 + (toolTips.size() - 1) * 10;
|
||||
}
|
||||
|
||||
if (this.guiTop + var7 + var9 + 6 > this.height)
|
||||
{
|
||||
var7 = this.height - var9 - this.guiTop - 6;
|
||||
}
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
int var10 = -267386864;
|
||||
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10);
|
||||
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10);
|
||||
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10);
|
||||
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10);
|
||||
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10);
|
||||
int var11 = 1347420415;
|
||||
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
|
||||
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12);
|
||||
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12);
|
||||
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11);
|
||||
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
|
||||
|
||||
for (int var13 = 0; var13 < toolTips.size(); ++var13)
|
||||
{
|
||||
String var14 = "\u00a77" + toolTips.get(var13);
|
||||
|
||||
this.fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
|
||||
|
||||
if (var13 == 0)
|
||||
{
|
||||
var7 += 2;
|
||||
}
|
||||
|
||||
var7 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,12 +3,10 @@ package universalelectricity.prefab;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.electricity.ElectricInfo;
|
||||
import universalelectricity.core.electricity.ElectricInfo.ElectricUnit;
|
||||
|
@ -27,7 +25,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
{
|
||||
super(id);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage((int) this.getMaxJoules());
|
||||
this.setMaxDamage(100);
|
||||
this.setNoRepair();
|
||||
}
|
||||
|
||||
|
@ -58,21 +56,6 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
par3List.add(color + ElectricInfo.getDisplay(joules, ElectricUnit.JOULES) + " - " + Math.round((joules / this.getMaxJoules(par1ItemStack)) * 100) + "%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure you super this method!
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
// Makes sure the damage is set correctly
|
||||
// for this electric item!
|
||||
ItemElectric item = ((ItemElectric) par1ItemStack.getItem());
|
||||
item.setJoules(item.getJoules(par1ItemStack), par1ItemStack);
|
||||
|
||||
// For items that can change electricity capacity
|
||||
this.setMaxDamage((int) this.getMaxJoules(par1ItemStack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure the item is uncharged when it is crafted and not charged. Change this if you do
|
||||
* not want this to happen!
|
||||
|
@ -99,11 +82,13 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
return electricityToUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveElectricity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceElectricity()
|
||||
{
|
||||
return false;
|
||||
|
@ -122,16 +107,19 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
{
|
||||
ItemStack itemStack = (ItemStack) data[0];
|
||||
|
||||
// Saves the frequency in the
|
||||
// itemstack
|
||||
if (itemStack.stackTagCompound == null)
|
||||
// Saves the frequency in the ItemStack
|
||||
if (itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(wattHours, this.getMaxJoules(itemStack)), 0);
|
||||
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
|
||||
itemStack.setItemDamage((int) (getMaxJoules() - electricityStored));
|
||||
itemStack.getTagCompound().setDouble("electricity", electricityStored);
|
||||
|
||||
/**
|
||||
* Sets the damage as a percentage to render the bar properly.
|
||||
*/
|
||||
itemStack.setItemDamage((int) (100 - (electricityStored / getMaxJoules()) * 100));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,17 +135,17 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
{
|
||||
ItemStack itemStack = (ItemStack) data[0];
|
||||
|
||||
if (itemStack.stackTagCompound == null) { return 0; }
|
||||
double electricityStored = 0;
|
||||
if (itemStack.stackTagCompound.getTag("electricity") instanceof NBTTagFloat)
|
||||
if (itemStack.getTagCompound() == null)
|
||||
{
|
||||
electricityStored = itemStack.stackTagCompound.getFloat("electricity");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
|
||||
}
|
||||
itemStack.setItemDamage((int) (getMaxJoules(itemStack) - electricityStored));
|
||||
|
||||
double electricityStored = itemStack.getTagCompound().getDouble("electricity");
|
||||
|
||||
/**
|
||||
* Sets the damage as a percentage to render the bar properly.
|
||||
*/
|
||||
itemStack.setItemDamage((int) (100 - (electricityStored / getMaxJoules()) * 100));
|
||||
return electricityStored;
|
||||
}
|
||||
|
||||
|
@ -172,36 +160,41 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
* @return The ItemStack of a fully charged electric item
|
||||
*/
|
||||
public ItemStack getUncharged()
|
||||
{
|
||||
return this.getWithCharge(0);
|
||||
}
|
||||
|
||||
public ItemStack getWithCharge(double joules)
|
||||
{
|
||||
ItemStack chargedItem = new ItemStack(this);
|
||||
chargedItem.setItemDamage((int) this.getMaxJoules(chargedItem));
|
||||
((IItemElectric) chargedItem.getItem()).setJoules(joules, chargedItem);
|
||||
return chargedItem;
|
||||
}
|
||||
|
||||
public static ItemStack getUncharged(ItemStack itemStack)
|
||||
public static ItemStack getWithCharge(ItemStack itemStack, double joules)
|
||||
{
|
||||
if (itemStack.getItem() instanceof IItemElectric)
|
||||
{
|
||||
ItemStack chargedItem = itemStack.copy();
|
||||
chargedItem.setItemDamage((int) ((IItemElectric) itemStack.getItem()).getMaxJoules(chargedItem));
|
||||
((IItemElectric) chargedItem.getItem()).setJoules(joules, chargedItem);
|
||||
return chargedItem;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getUncharged(ItemStack itemStack)
|
||||
{
|
||||
return getWithCharge(itemStack, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
// Add an uncharged version of the
|
||||
// electric item
|
||||
ItemStack unchargedItem = new ItemStack(this, 1);
|
||||
unchargedItem.setItemDamage((int) this.getMaxJoules(unchargedItem));
|
||||
par3List.add(unchargedItem);
|
||||
// Add an electric item to the creative
|
||||
// list that is fully charged
|
||||
ItemStack chargedItem = new ItemStack(this, 1);
|
||||
this.setJoules(((IItemElectric) chargedItem.getItem()).getMaxJoules(chargedItem), chargedItem);
|
||||
par3List.add(chargedItem);
|
||||
// Add an uncharged version of the electric item
|
||||
par3List.add(this.getUncharged());
|
||||
// Add an electric item to the creative list that is fully charged
|
||||
ItemStack chargedItem = new ItemStack(this);
|
||||
par3List.add(this.getWithCharge(this.getMaxJoules(chargedItem)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package universalelectricity.prefab;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.core.implement.IItemElectric;
|
||||
|
||||
/**
|
||||
|
@ -11,19 +9,11 @@ import universalelectricity.core.implement.IItemElectric;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class SlotElectricItem extends Slot
|
||||
@Deprecated
|
||||
public class SlotElectricItem extends SlotSpecific
|
||||
{
|
||||
public SlotElectricItem(IInventory par2IInventory, int par3, int par4, int par5)
|
||||
{
|
||||
super(par2IInventory, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
return par1ItemStack.getItem() instanceof IItemElectric;
|
||||
super(par2IInventory, par3, par4, par5, IItemElectric.class);
|
||||
}
|
||||
}
|
||||
|
|
95
src/minecraft/universalelectricity/prefab/SlotSpecific.java
Normal file
95
src/minecraft/universalelectricity/prefab/SlotSpecific.java
Normal file
|
@ -0,0 +1,95 @@
|
|||
package universalelectricity.prefab;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Creates a slot with a specific amount of items that matches the slot's requirements. Allows easy
|
||||
* shift right clicking management and slot blocking in classes. In your container you can use
|
||||
* this.getSlot(i).isItemValid to justify the player's shift clicking actions to match the slot.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class SlotSpecific extends Slot
|
||||
{
|
||||
public ItemStack[] validItemStacks = new ItemStack[0];
|
||||
public Class[] validClasses = new Class[0];
|
||||
|
||||
public boolean isInverted = false;
|
||||
public boolean isMetadataSensitive = false;
|
||||
|
||||
public SlotSpecific(IInventory par2IInventory, int par3, int par4, int par5, ItemStack... itemStacks)
|
||||
{
|
||||
super(par2IInventory, par3, par4, par5);
|
||||
this.setItemStacks(itemStacks);
|
||||
}
|
||||
|
||||
public SlotSpecific(IInventory par2IInventory, int par3, int par4, int par5, Class... validClasses)
|
||||
{
|
||||
super(par2IInventory, par3, par4, par5);
|
||||
this.setClasses(validClasses);
|
||||
}
|
||||
|
||||
public SlotSpecific setMetadataSensitive()
|
||||
{
|
||||
this.isMetadataSensitive = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlotSpecific setItemStacks(ItemStack... validItemStacks)
|
||||
{
|
||||
this.validItemStacks = validItemStacks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlotSpecific setClasses(Class... validClasses)
|
||||
{
|
||||
this.validClasses = validClasses;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlotSpecific toggleInverted()
|
||||
{
|
||||
this.isInverted = !this.isInverted;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack compareStack)
|
||||
{
|
||||
boolean returnValue = false;
|
||||
|
||||
for (ItemStack itemStack : this.validItemStacks)
|
||||
{
|
||||
if (compareStack.isItemEqual(itemStack) || (!this.isMetadataSensitive && compareStack.itemID == itemStack.itemID))
|
||||
{
|
||||
returnValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!returnValue)
|
||||
{
|
||||
for (Class clazz : this.validClasses)
|
||||
{
|
||||
if (clazz.equals(compareStack.getItem().getClass()) || clazz.isInstance(compareStack.getItem()))
|
||||
{
|
||||
returnValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isInverted)
|
||||
{
|
||||
return !returnValue;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,10 @@ public class UETab extends CreativeTabs
|
|||
@Override
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
if (itemStack == null) { return new ItemStack(Block.blocksList[this.getTabIconItemIndex()]); }
|
||||
if (itemStack == null)
|
||||
{
|
||||
return new ItemStack(Block.blocksList[this.getTabIconItemIndex()]);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class UpdateNotifier implements IPlayerTracker
|
||||
{
|
||||
public static final UpdateNotifier INSTANCE = new UpdateNotifier();
|
||||
|
@ -86,7 +87,7 @@ public class UpdateNotifier implements IPlayerTracker
|
|||
if (MODS_TO_UPDATE.size() > 0)
|
||||
{
|
||||
// Output Notification Message.
|
||||
String updateNotification = "You have " + MODS_TO_UPDATE.size() + " mod(s) that needs to be updated: ";
|
||||
String updateNotification = "Please update the following mod(s): ";
|
||||
|
||||
Iterator it = MODS_TO_UPDATE.entrySet().iterator();
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package universalelectricity.prefab.modifier;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* This must be applied to an item that acts as a modifier or an upgrade.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface IModifier
|
||||
{
|
||||
/**
|
||||
* @return - The name of the modifier.
|
||||
*/
|
||||
public String getName(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* @return - How much effect does this modifier have?
|
||||
*/
|
||||
public int getEffectiveness(ItemStack itemstack);
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package universalelectricity.prefab.modifier;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* This slot should be used by any container that contains an item that is a modifier. An example of
|
||||
* this would be upgrade slots.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class SlotModifier extends Slot
|
||||
{
|
||||
public SlotModifier(IInventory par2IInventory, int par3, int par4, int par5)
|
||||
{
|
||||
super(par2IInventory, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
return par1ItemStack.getItem() instanceof IModifier;
|
||||
}
|
||||
}
|
|
@ -90,7 +90,10 @@ public class BlockMulti extends BlockContainer
|
|||
{
|
||||
int mainBlockID = par1World.getBlockId(mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
|
||||
|
||||
if (mainBlockID > 0) { return Block.blocksList[mainBlockID].getPickBlock(target, par1World, mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ()); }
|
||||
if (mainBlockID > 0)
|
||||
{
|
||||
return Block.blocksList[mainBlockID].getPickBlock(target, par1World, mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -37,7 +37,10 @@ public class TileEntityMulti extends TileEntity implements IPacketReceiver
|
|||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
if (this.mainBlockPosition != null) { return PacketManager.getPacket("BasicComponents", this, this.mainBlockPosition.x, this.mainBlockPosition.y, this.mainBlockPosition.z); }
|
||||
if (this.mainBlockPosition != null)
|
||||
{
|
||||
return PacketManager.getPacket("BasicComponents", this, this.mainBlockPosition.x, this.mainBlockPosition.y, this.mainBlockPosition.z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -67,7 +70,10 @@ public class TileEntityMulti extends TileEntity implements IPacketReceiver
|
|||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof IMultiBlock) { return ((IMultiBlock) tileEntity).onActivated(par5EntityPlayer); }
|
||||
if (tileEntity instanceof IMultiBlock)
|
||||
{
|
||||
return ((IMultiBlock) tileEntity).onActivated(par5EntityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,10 @@ public class PacketManager implements IPacketHandler, IPacketReceiver
|
|||
|
||||
public static PacketType get(int id)
|
||||
{
|
||||
if (id >= 0 && id < PacketType.values().length) { return PacketType.values()[id]; }
|
||||
if (id >= 0 && id < PacketType.values().length)
|
||||
{
|
||||
return PacketType.values()[id];
|
||||
}
|
||||
return UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
/**
|
||||
* This class is used for storing ore generation data. If you are too lazy to generate your own
|
||||
* ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores
|
||||
* to generate.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public abstract class OreGenBase
|
||||
{
|
||||
public String name;
|
||||
|
||||
public String oreDictionaryName;
|
||||
|
||||
public boolean shouldGenerate = false;
|
||||
|
||||
public int blockIndexTexture;
|
||||
|
||||
public ItemStack oreStack;
|
||||
|
||||
public int oreID;
|
||||
|
||||
public int oreMeta;
|
||||
|
||||
/**
|
||||
* What harvest level does this machine need to be acquired?
|
||||
*/
|
||||
public int harvestLevel;
|
||||
|
||||
/**
|
||||
* The predefined tool classes are "pickaxe", "shovel", "axe". You can add others for custom
|
||||
* tools.
|
||||
*/
|
||||
public String harvestTool;
|
||||
|
||||
/**
|
||||
* @param name - The name of the ore for display
|
||||
* @param textureFile - The 16x16 png texture of your ore to override
|
||||
* @param minGenerateLevel - The highest generation level of your ore
|
||||
* @param maxGenerateLevel - The lowest generation level of your ore
|
||||
* @param amountPerChunk - The amount of ores to generate per chunk
|
||||
* @param amountPerBranch - The amount of ores to generate in a clutter. E.g coal generates with
|
||||
* a lot of other coal next to it. How much do you want?
|
||||
*/
|
||||
public OreGenBase(String name, String oreDiectionaryName, ItemStack stack, String harvestTool, int harvestLevel)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
this.name = name;
|
||||
this.harvestTool = harvestTool;
|
||||
this.harvestLevel = harvestLevel;
|
||||
this.oreDictionaryName = oreDiectionaryName;
|
||||
this.oreStack = stack;
|
||||
this.oreID = stack.itemID;
|
||||
this.oreMeta = stack.getItemDamage();
|
||||
|
||||
OreDictionary.registerOre(oreDictionaryName, stack);
|
||||
MinecraftForge.setBlockHarvestLevel(Block.blocksList[stack.itemID], stack.getItemDamage(), harvestTool, harvestLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.severe("ItemStack is null while registering ore generation!");
|
||||
}
|
||||
}
|
||||
|
||||
public OreGenBase enable(Configuration config)
|
||||
{
|
||||
this.shouldGenerate = shouldGenerateOre(config, this.name);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the config file and see if Universal Electricity should generate this ore
|
||||
*/
|
||||
private static boolean shouldGenerateOre(Configuration configuration, String oreName)
|
||||
{
|
||||
configuration.load();
|
||||
boolean shouldGenerate = configuration.get("Ore Generation", "Generate " + oreName, true).getBoolean(true);
|
||||
configuration.save();
|
||||
return shouldGenerate;
|
||||
}
|
||||
|
||||
public abstract void generate(World world, Random random, int varX, int varZ);
|
||||
|
||||
public abstract boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator);
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderEnd;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import net.minecraft.world.gen.ChunkProviderHell;
|
||||
|
||||
/**
|
||||
* This class is used for storing ore generation data. If you are too lazy to generate your own
|
||||
* ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores
|
||||
* to generate.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class OreGenReplace extends OreGenBase
|
||||
{
|
||||
|
||||
public int minGenerateLevel;
|
||||
public int maxGenerateLevel;
|
||||
public int amountPerChunk;
|
||||
public int amountPerBranch;
|
||||
public int replaceID;
|
||||
|
||||
/**
|
||||
* Dimensions to ignore ore generation
|
||||
*/
|
||||
public boolean ignoreSurface = false;
|
||||
public boolean ignoreNether = true;
|
||||
public boolean ignoreEnd = true;
|
||||
|
||||
/**
|
||||
* @param name - The name of the ore for display
|
||||
* @param textureFile - The 16x16 png texture of your ore to override
|
||||
* @param minGenerateLevel - The highest generation level of your ore
|
||||
* @param maxGenerateLevel - The lowest generation level of your ore
|
||||
* @param amountPerChunk - The amount of ores to generate per chunk
|
||||
* @param amountPerBranch - The amount of ores to generate in a clutter. E.g coal generates with
|
||||
* a lot of other coal next to it. How much do you want?
|
||||
*/
|
||||
public OreGenReplace(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel)
|
||||
{
|
||||
super(name, oreDiectionaryName, stack, harvestTool, harvestLevel);
|
||||
this.minGenerateLevel = minGenerateLevel;
|
||||
this.maxGenerateLevel = maxGenerateLevel;
|
||||
this.amountPerChunk = amountPerChunk;
|
||||
this.amountPerBranch = amountPerBranch;
|
||||
this.replaceID = replaceID;
|
||||
}
|
||||
|
||||
public void generate(World world, Random random, int varX, int varZ)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < this.amountPerChunk; i++)
|
||||
{
|
||||
int x = varX + random.nextInt(16);
|
||||
int z = varZ + random.nextInt(16);
|
||||
int y = random.nextInt(Math.max(this.maxGenerateLevel - this.minGenerateLevel, 0)) + this.minGenerateLevel;
|
||||
this.generateReplace(world, random, x, y, z);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Error generating ore: " + this.name);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean generateReplace(World par1World, Random par2Random, int par3, int par4, int par5)
|
||||
{
|
||||
float var6 = par2Random.nextFloat() * (float) Math.PI;
|
||||
double var7 = (double) ((float) (par3 + 8) + MathHelper.sin(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var9 = (double) ((float) (par3 + 8) - MathHelper.sin(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var11 = (double) ((float) (par5 + 8) + MathHelper.cos(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var13 = (double) ((float) (par5 + 8) - MathHelper.cos(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var15 = (double) (par4 + par2Random.nextInt(3) - 2);
|
||||
double var17 = (double) (par4 + par2Random.nextInt(3) - 2);
|
||||
|
||||
for (int var19 = 0; var19 <= this.amountPerBranch; ++var19)
|
||||
{
|
||||
double var20 = var7 + (var9 - var7) * (double) var19 / (double) this.amountPerBranch;
|
||||
double var22 = var15 + (var17 - var15) * (double) var19 / (double) this.amountPerBranch;
|
||||
double var24 = var11 + (var13 - var11) * (double) var19 / (double) this.amountPerBranch;
|
||||
double var26 = par2Random.nextDouble() * (double) this.amountPerBranch / 16.0D;
|
||||
double var28 = (double) (MathHelper.sin((float) var19 * (float) Math.PI / (float) this.amountPerBranch) + 1.0F) * var26 + 1.0D;
|
||||
double var30 = (double) (MathHelper.sin((float) var19 * (float) Math.PI / (float) this.amountPerBranch) + 1.0F) * var26 + 1.0D;
|
||||
int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
|
||||
int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
|
||||
int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
|
||||
int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
|
||||
int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
|
||||
int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
|
||||
|
||||
for (int var38 = var32; var38 <= var35; ++var38)
|
||||
{
|
||||
double var39 = ((double) var38 + 0.5D - var20) / (var28 / 2.0D);
|
||||
|
||||
if (var39 * var39 < 1.0D)
|
||||
{
|
||||
for (int var41 = var33; var41 <= var36; ++var41)
|
||||
{
|
||||
double var42 = ((double) var41 + 0.5D - var22) / (var30 / 2.0D);
|
||||
|
||||
if (var39 * var39 + var42 * var42 < 1.0D)
|
||||
{
|
||||
for (int var44 = var34; var44 <= var37; ++var44)
|
||||
{
|
||||
double var45 = ((double) var44 + 0.5D - var24) / (var28 / 2.0D);
|
||||
|
||||
int block = par1World.getBlockId(var38, var41, var44);
|
||||
if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (this.replaceID == 0 || block == this.replaceID))
|
||||
{
|
||||
par1World.setBlockAndMetadata(var38, var41, var44, this.oreID, this.oreMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator)
|
||||
{
|
||||
if (!this.shouldGenerate) { return false; }
|
||||
if (this.ignoreSurface && chunkGenerator instanceof ChunkProviderGenerate) { return false; }
|
||||
if (this.ignoreNether && chunkGenerator instanceof ChunkProviderHell) { return false; }
|
||||
if (this.ignoreEnd && chunkGenerator instanceof ChunkProviderEnd) { return false; }
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class OreGenReplaceStone extends OreGenReplace
|
||||
{
|
||||
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel)
|
||||
{
|
||||
super(name, oreDiectionaryName, stack, 1, minGenerateLevel, maxGenerateLevel, amountPerChunk, amountPerBranch, harvestTool, harvestLevel);
|
||||
}
|
||||
|
||||
// A simplified version of the constructor
|
||||
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int maxGenerateLevel, int amountPerChunk, int amountPerBranch)
|
||||
{
|
||||
this(name, oreDiectionaryName, stack, 0, maxGenerateLevel, amountPerChunk, amountPerBranch, "pickaxe", 1);
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class OreGenerator implements IWorldGenerator
|
||||
{
|
||||
public static boolean isInitiated = false;
|
||||
|
||||
/**
|
||||
* Add your ore data to this list of ores for it to automatically generate! No hassle indeed!
|
||||
*/
|
||||
private static final List<OreGenBase> ORES_TO_GENERATE = new ArrayList<OreGenBase>();
|
||||
|
||||
/**
|
||||
* Adds an ore to the ore generate list. Do this in pre-init.
|
||||
*/
|
||||
public static void addOre(OreGenBase data)
|
||||
{
|
||||
if (!isInitiated)
|
||||
{
|
||||
GameRegistry.registerWorldGenerator(new OreGenerator());
|
||||
}
|
||||
|
||||
ORES_TO_GENERATE.add(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this ore
|
||||
*
|
||||
* @param oreName
|
||||
* @return
|
||||
*/
|
||||
public static boolean oreExists(String oreName)
|
||||
{
|
||||
for (OreGenBase ore : ORES_TO_GENERATE)
|
||||
{
|
||||
if (ore.oreDictionaryName == oreName) { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an ore to the ore generate list. Do this in init.
|
||||
*/
|
||||
public static void removeOre(OreGenBase data)
|
||||
{
|
||||
ORES_TO_GENERATE.remove(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
||||
{
|
||||
chunkX = chunkX << 4;
|
||||
chunkZ = chunkZ << 4;
|
||||
|
||||
// Checks to make sure this is the normal
|
||||
// world
|
||||
for (OreGenBase oreData : ORES_TO_GENERATE)
|
||||
{
|
||||
if (oreData.shouldGenerate && oreData.isOreGeneratedInWorld(world, chunkGenerator))
|
||||
{
|
||||
oreData.generate(world, rand, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package universalelectricity.prefab.potion;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public abstract class CustomPotion extends Potion
|
||||
{
|
||||
/**
|
||||
* Creates a new type of potion
|
||||
*
|
||||
* @param id - The ID of this potion. Make it greater than 20.
|
||||
* @param isBadEffect - Is this potion a good potion or a bad one?
|
||||
* @param color - The color of this potion.
|
||||
* @param name - The name of this potion.
|
||||
*/
|
||||
public CustomPotion(int id, boolean isBadEffect, int color, String name)
|
||||
{
|
||||
super(id, isBadEffect, color);
|
||||
this.setPotionName("potion." + name);
|
||||
LanguageRegistry.instance().addStringLocalization(this.getName(), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Potion setIconIndex(int par1, int par2)
|
||||
{
|
||||
super.setIconIndex(par1, par2);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* You must register all your potion effects during mod initialization!
|
||||
*/
|
||||
public void register()
|
||||
{
|
||||
Potion.potionTypes[this.getId()] = this;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
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);
|
||||
}
|
||||
|
||||
public CustomPotionEffect(Potion potion, int duration, int amplifier)
|
||||
{
|
||||
this(potion.getId(), duration, amplifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a potion effect with custom curable items.
|
||||
*
|
||||
* @param curativeItems - ItemStacks that can cure this potion effect
|
||||
*/
|
||||
public CustomPotionEffect(int potionID, int duration, int amplifier, List<ItemStack> curativeItems)
|
||||
{
|
||||
super(potionID, duration, amplifier);
|
||||
|
||||
if (curativeItems == null)
|
||||
{
|
||||
this.setCurativeItems(new ArrayList<ItemStack>());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setCurativeItems(curativeItems);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import net.minecraft.network.INetworkManager;
|
|||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.bouncycastle.util.Arrays;
|
||||
|
@ -21,6 +22,9 @@ import universalelectricity.prefab.network.PacketManager;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* This tile entity pre-fabricated for all conductors.
|
||||
*
|
||||
|
@ -203,4 +207,10 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements
|
|||
{
|
||||
return PacketManager.getPacket(this.channel, this, this.visuallyConnected[0], this.visuallyConnected[1], this.visuallyConnected[2], this.visuallyConnected[3], this.visuallyConnected[4], this.visuallyConnected[5]);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue