Merge branch 'master' of github.com:aidancbrady/Mekanism

This commit is contained in:
Ben Spiers 2013-10-12 15:39:01 +01:00
commit 3c73914337
17 changed files with 279 additions and 67 deletions

View file

@ -23,6 +23,9 @@
<get src="http://www.chickenbones.craftsaddle.org/Files/New_Versions/1.6.4/NotEnoughItems-dev%201.6.1.5.jar"
dest="${dir.mcp}/lib/NEI-dev.jar"/>
<get src="http://www.chickenbones.craftsaddle.org/Files/New_Versions/1.6.4/CodeChickenCore-dev%200.9.0.7.jar"
dest = "${dir.mcp}/lib/CCC-dev.jar"/>
<copy todir="${dir.mcp}/src/minecraft">

View file

@ -19,6 +19,9 @@ import ic2.api.energy.tile.IEnergySink;
* It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a
* one-time configurable input energy buffer, thus providing a common use case for machines.
*
* Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended.
* The delegate can be extended with additional functionality through a sub class though.
*
* The constraints set by BasicSink like the strict tank-like energy buffering should provide a
* more easy to use and stable interface than using IEnergySink directly while aiming for
* optimal performance.
@ -42,14 +45,14 @@ import ic2.api.energy.tile.IEnergySink;
*
* @Override
* public void invalidate() {
* ic2EnergySink.onInvalidate(); // notify the energy sink
* ic2EnergySink.invalidate(); // notify the energy sink
* ...
* super.invalidate(); // this is important for mc!
* }
*
* @Override
* public void onChunkUnload() {
* ic2EnergySink.onOnChunkUnload(); // notify the energy sink
* ic2EnergySink.onChunkUnload(); // notify the energy sink
* ...
* }
*
@ -57,7 +60,7 @@ import ic2.api.energy.tile.IEnergySink;
* public void readFromNBT(NBTTagCompound tag) {
* super.readFromNBT(tag);
*
* ic2EnergySink.onReadFromNbt(tag);
* ic2EnergySink.readFromNBT(tag);
* ...
* }
*
@ -65,15 +68,15 @@ import ic2.api.energy.tile.IEnergySink;
* public void writeToNBT(NBTTagCompound tag) {
* super.writeToNBT(tag);
*
* ic2EnergySink.onWriteToNbt(tag);
* ic2EnergySink.writeToNBT(tag);
* ...
* }
*
* @Override
* public void updateEntity() {
* ic2EnergySink.onUpdateEntity(); // notify the energy sink
* ic2EnergySink.updateEntity(); // notify the energy sink
* ...
* if (ic2EnergySink.addEnergy(5)) { // use 5 eu from the sink's buffer this tick
* if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick
* ... // do something with the energy
* }
* ...
@ -105,16 +108,17 @@ public class BasicSink extends TileEntity implements IEnergySink {
// in-world te forwards >>
/**
* Forward for the TileEntity's updateEntity(), used for creating the energy net link.
* Either onUpdateEntity or onLoaded have to be used.
* Forward for the base TileEntity's updateEntity(), used for creating the energy net link.
* Either updateEntity or onLoaded have to be used.
*/
public void onUpdateEntity() {
@Override
public void updateEntity() {
if (!addedToEnet) onLoaded();
}
/**
* Notification that the TileEntity finished loaded, for advanced uses.
* Either onUpdateEntity or onLoaded have to be used.
* Notification that the base TileEntity finished loaded, for advanced uses.
* Either updateEntity or onLoaded have to be used.
*/
public void onLoaded() {
if (!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient()) {
@ -130,10 +134,22 @@ public class BasicSink extends TileEntity implements IEnergySink {
}
/**
* Forward for the TileEntity's invalidate(), used for destroying the energy net link.
* Both onInvalidate and onOnChunkUnload have to be used.
* Forward for the base TileEntity's invalidate(), used for destroying the energy net link.
* Both invalidate and onChunkUnload have to be used.
*/
public void onInvalidate() {
@Override
public void invalidate() {
super.invalidate();
onChunkUnload();
}
/**
* Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link.
* Both invalidate and onChunkUnload have to be used.
*/
@Override
public void onChunkUnload() {
if (addedToEnet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
@ -142,30 +158,32 @@ public class BasicSink extends TileEntity implements IEnergySink {
}
/**
* Forward for the TileEntity's onChunkUnload(), used for destroying the energy net link.
* Both onInvalidate and onOnChunkUnload have to be used.
*/
public void onOnChunkUnload() {
onInvalidate();
}
/**
* Forward for the TileEntity's readFromNBT(), used for loading the state.
* Forward for the base TileEntity's readFromNBT(), used for loading the state.
*
* @param tag Compound tag as supplied by TileEntity.readFromNBT()
*/
public void onReadFromNbt(NBTTagCompound tag) {
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
NBTTagCompound data = tag.getCompoundTag("IC2BasicSink");
energyStored = data.getDouble("energy");
}
/**
* Forward for the TileEntity's writeToNBT(), used for saving the state.
* Forward for the base TileEntity's writeToNBT(), used for saving the state.
*
* @param tag Compound tag as supplied by TileEntity.writeToNBT()
*/
public void onWriteToNbt(NBTTagCompound tag) {
@Override
public void writeToNBT(NBTTagCompound tag) {
try {
super.writeToNBT(tag);
} catch (RuntimeException e) {
// happens if this is a delegate, ignore
}
NBTTagCompound data = new NBTTagCompound();
data.setDouble("energy", energyStored);
@ -225,6 +243,35 @@ public class BasicSink extends TileEntity implements IEnergySink {
// << methods for using this adapter
// backwards compatibility (ignore these) >>
@Deprecated
public void onUpdateEntity() {
updateEntity();
}
@Deprecated
public void onInvalidate() {
invalidate();
}
@Deprecated
public void onOnChunkUnload() {
onChunkUnload();
}
@Deprecated
public void onReadFromNbt(NBTTagCompound tag) {
readFromNBT(tag);
}
@Deprecated
public void onWriteToNbt(NBTTagCompound tag) {
writeToNBT(tag);
}
// << backwards compatibility
// ******************************
// *** Methods for use by ic2 ***
// ******************************

View file

@ -21,6 +21,9 @@ import ic2.api.item.ElectricItem;
* It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a
* one-time configurable output energy buffer, thus providing a common use case for generators.
*
* Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended.
* The delegate can be extended with additional functionality through a sub class though.
*
* The constraints set by BasicSource like the strict tank-like energy buffering should provide a
* more easy to use and stable interface than using IEnergySource directly while aiming for
* optimal performance.
@ -44,14 +47,14 @@ import ic2.api.item.ElectricItem;
*
* @Override
* public void invalidate() {
* ic2EnergySource.onInvalidate(); // notify the energy source
* ic2EnergySource.invalidate(); // notify the energy source
* ...
* super.invalidate(); // this is important for mc!
* }
*
* @Override
* public void onChunkUnload() {
* ic2EnergySource.onOnChunkUnload(); // notify the energy source
* ic2EnergySource.onChunkUnload(); // notify the energy source
* ...
* }
*
@ -59,7 +62,7 @@ import ic2.api.item.ElectricItem;
* public void readFromNBT(NBTTagCompound tag) {
* super.readFromNBT(tag);
*
* ic2EnergySource.onReadFromNbt(tag);
* ic2EnergySource.readFromNBT(tag);
* ...
* }
*
@ -67,13 +70,13 @@ import ic2.api.item.ElectricItem;
* public void writeToNBT(NBTTagCompound tag) {
* super.writeToNBT(tag);
*
* ic2EnergySource.onWriteToNbt(tag);
* ic2EnergySource.writeToNBT(tag);
* ...
* }
*
* @Override
* public void updateEntity() {
* ic2EnergySource.onUpdateEntity(); // notify the energy source
* ic2EnergySource.updateEntity(); // notify the energy source
* ...
* ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick
* ...
@ -92,7 +95,7 @@ public class BasicSource extends TileEntity implements IEnergySource {
/**
* Constructor for a new BasicSource delegate.
*
* @param parent TileEntity represented by this energy source.
* @param parent Base TileEntity represented by this energy source.
* @param capacity Maximum amount of eu to store.
* @param tier IC2 tier, 1=LV, 2=MV, ...
*/
@ -107,16 +110,17 @@ public class BasicSource extends TileEntity implements IEnergySource {
// in-world te forwards >>
/**
* Forward for the TileEntity's updateEntity(), used for creating the energy net link.
* Either onUpdateEntity or onLoaded have to be used.
* Forward for the base TileEntity's updateEntity(), used for creating the energy net link.
* Either updateEntity or onLoaded have to be used.
*/
public void onUpdateEntity() {
@Override
public void updateEntity() {
if (!addedToEnet) onLoaded();
}
/**
* Notification that the TileEntity finished loaded, for advanced uses.
* Either onUpdateEntity or onLoaded have to be used.
* Notification that the base TileEntity finished loading, for advanced uses.
* Either updateEntity or onLoaded have to be used.
*/
public void onLoaded() {
if (!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient()) {
@ -132,10 +136,22 @@ public class BasicSource extends TileEntity implements IEnergySource {
}
/**
* Forward for the TileEntity's invalidate(), used for destroying the energy net link.
* Both onInvalidate and onOnChunkUnload have to be used.
* Forward for the base TileEntity's invalidate(), used for destroying the energy net link.
* Both invalidate and onChunkUnload have to be used.
*/
public void onInvalidate() {
@Override
public void invalidate() {
super.invalidate();
onChunkUnload();
}
/**
* Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link.
* Both invalidate and onChunkUnload have to be used.
*/
@Override
public void onChunkUnload() {
if (addedToEnet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
@ -144,30 +160,32 @@ public class BasicSource extends TileEntity implements IEnergySource {
}
/**
* Forward for the TileEntity's onChunkUnload(), used for destroying the energy net link.
* Both onInvalidate and onOnChunkUnload have to be used.
*/
public void onOnChunkUnload() {
onInvalidate();
}
/**
* Forward for the TileEntity's readFromNBT(), used for loading the state.
* Forward for the base TileEntity's readFromNBT(), used for loading the state.
*
* @param tag Compound tag as supplied by TileEntity.readFromNBT()
*/
public void onReadFromNbt(NBTTagCompound tag) {
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
NBTTagCompound data = tag.getCompoundTag("IC2BasicSource");
energyStored = data.getDouble("energy");
}
/**
* Forward for the TileEntity's writeToNBT(), used for saving the state.
* Forward for the base TileEntity's writeToNBT(), used for saving the state.
*
* @param tag Compound tag as supplied by TileEntity.writeToNBT()
*/
public void onWriteToNbt(NBTTagCompound tag) {
@Override
public void writeToNBT(NBTTagCompound tag) {
try {
super.writeToNBT(tag);
} catch (RuntimeException e) {
// happens if this is a delegate, ignore
}
NBTTagCompound data = new NBTTagCompound();
data.setDouble("energy", energyStored);
@ -241,6 +259,35 @@ public class BasicSource extends TileEntity implements IEnergySource {
// << methods for using this adapter
// backwards compatibility (ignore these) >>
@Deprecated
public void onUpdateEntity() {
updateEntity();
}
@Deprecated
public void onInvalidate() {
invalidate();
}
@Deprecated
public void onOnChunkUnload() {
onChunkUnload();
}
@Deprecated
public void onReadFromNbt(NBTTagCompound tag) {
readFromNBT(tag);
}
@Deprecated
public void onWriteToNbt(NBTTagCompound tag) {
writeToNBT(tag);
}
// << backwards compatibility
// ******************************
// *** Methods for use by ic2 ***
// ******************************

View file

@ -21,11 +21,11 @@ public class GuiFactory extends GuiMekanism
public GuiFactory(InventoryPlayer inventory, TileEntityFactory tentity)
{
super(new ContainerFactory(inventory, tentity));
xSize+=26;
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.tier.guiLocation));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.tier.guiLocation));
guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation));
}
@Override
@ -42,7 +42,7 @@ public class GuiFactory extends GuiMekanism
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
{
drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis);
drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis);
}
}
@ -63,10 +63,7 @@ public class GuiFactory extends GuiMekanism
int displayInt;
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 26, 52 - displayInt, 4, displayInt);
displayInt = tileEntity.getScaledRecipeProgress(15);
drawTexturedModalRect(guiWidth + 181, guiHeight + 94, 176 + 26, 86, 10, displayInt);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt);
if(tileEntity.tier == FactoryTier.BASIC)
{
@ -75,7 +72,7 @@ public class GuiFactory extends GuiMekanism
int xPos = 59 + (i*38);
displayInt = tileEntity.getScaledProgress(20, i);
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176 + 26, 52, 8, displayInt);
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt);
}
}
else if(tileEntity.tier == FactoryTier.ADVANCED)
@ -85,7 +82,7 @@ public class GuiFactory extends GuiMekanism
int xPos = 39 + (i*26);
displayInt = tileEntity.getScaledProgress(20, i);
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176 + 26, 52, 8, displayInt);
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt);
}
}
else if(tileEntity.tier == FactoryTier.ELITE)
@ -95,7 +92,7 @@ public class GuiFactory extends GuiMekanism
int xPos = 33 + (i*19);
displayInt = tileEntity.getScaledProgress(20, i);
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176 + 26, 52, 8, displayInt);
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt);
}
}
}

View file

@ -0,0 +1,69 @@
package mekanism.client.gui;
import mekanism.common.tileentity.TileEntityFactory;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class GuiRecipeType extends GuiElement
{
public GuiRecipeType(GuiContainer gui, TileEntity tile, ResourceLocation def)
{
super(MekanismUtils.getResource(ResourceType.GUI, "GuiRecipeType.png"), gui, tile, def);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
{
mc.renderEngine.bindTexture(RESOURCE);
guiContainer.drawTexturedModalRect(guiWidth + 176, guiHeight + 70, 0, 0, 26, 63);
TileEntityFactory factory = (TileEntityFactory)tileEntity;
int displayInt = factory.getScaledRecipeProgress(15);
guiContainer.drawTexturedModalRect(guiWidth + 181, guiHeight + 94, 26, 0, 10, displayInt);
mc.renderEngine.bindTexture(defaultLocation);
}
@Override
public void renderForeground(int xAxis, int yAxis)
{
}
@Override
public void preMouseClicked(int xAxis, int yAxis, int button)
{
if(button == 0)
{
if(xAxis >= 180 && xAxis <= 196 && yAxis >= 75 && yAxis <= 91)
{
offsetX(26);
}
else if(xAxis >= 180 && xAxis <= 196 && yAxis >= 112 && yAxis <= 128)
{
offsetX(26);
}
}
}
@Override
public void mouseClicked(int xAxis, int yAxis, int button)
{
if(button == 0)
{
if(xAxis >= 180 && xAxis <= 196 && yAxis >= 75 && yAxis <= 91)
{
offsetX(-26);
}
else if(xAxis >= 180 && xAxis <= 196 && yAxis >= 112 && yAxis <= 128)
{
offsetX(-26);
}
}
}
}

View file

@ -86,13 +86,13 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
InfuseType type = ((CachedIORecipe)arecipes.get(i)).infusionType;
float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F;
drawProgressBar(67, 32, 176 + 26, 52, 32, 8, f, 0);
drawProgressBar(67, 32, 176, 52, 32, 8, f, 0);
f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F;
if(ticksPassed < 20) f = 0.0F;
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
drawProgressBar(160, 2, 176 + 26, 0, 4, 52, f, 3);
drawProgressBar(160, 2, 176, 0, 4, 52, f, 3);
changeTexture(type.texture);
drawProgressBar(2, 2, type.texX, type.texY, 4, 52, f, 3);

View file

@ -332,8 +332,7 @@ public class MekanismRenderer
{
return Arrays.equals(boolArray, (boolean[])o);
}
else
{
else {
return false;
}
}

View file

@ -21,7 +21,6 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
renderAModelAt((TileEntityLogisticalTransporter)tileEntity, x, y, z, partialTick);
}
@SuppressWarnings("incomplete-switch")
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter" + (tileEntity.isActive ? "Active" : "") + ".png"));

View file

@ -158,6 +158,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
@SuppressWarnings("incomplete-switch")
private DisplayInteger getListAndRender(ForgeDirection side, EnumGas type)
{
if(side == ForgeDirection.UNKNOWN)

View file

@ -118,6 +118,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
@SuppressWarnings("incomplete-switch")
private static Model3D[] assignEnergy()
{
Model3D[] energyArray = new Model3D[7];

View file

@ -1,5 +1,6 @@
package mekanism.common.tileentity;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
@ -55,6 +56,11 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
{
if(!worldObj.isRemote)
{
if(packetTick == 0)
{
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
}
if(getEnergy() < getMaxEnergy() && powerHandler.getEnergyStored() > 0)
{
setEnergy(getEnergy() + powerHandler.useEnergy(0, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), true)*Mekanism.FROM_BC);

View file

@ -209,7 +209,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
public int getFuel(ItemStack itemstack)
{
return itemstack.itemID == MekanismGenerators.BioFuel.itemID ? 100 : 0;
return itemstack.itemID == MekanismGenerators.BioFuel.itemID ? 200 : 0;
}
/**

43
docs/Development.md Normal file
View file

@ -0,0 +1,43 @@
# Development
Mekanism is developed for Minecraft 1.6.2 using Minecraft Forge.
## Prerequisites
* Minecraft Forge for MC 1.6.2 <http://files.minecraftforge.net/>
* Dev build of CodeChickenCore for MC 1.6.2 <http://www.chickenbones.craftsaddle.org/Files/New_Versions/links.php>
* Dev build of NEI for MC 1.6.2 <http://www.chickenbones.craftsaddle.org/Files/New_Versions/links.php>
## Directory Structure
* /common - Source code
- / _other_ _mod_ _apis_
- /mekanism
- /{api,client,common} - Core Mekanism mod
- /generators - Generators Mod
- /tools - Tools Mod
* /docs - Documentation
* /etc - logo and mcmod.info for each package
* /resources - Non-code assets for the core mod
## Packaging structure
### Mekanism.jar
* /assets - From /resources/assets
* / _other_ _mod_ _apis_ - .class files from /common/ _other_ _mod_ _apis_
* /mekanism/{api,client,common} - .class files from /common/mekanism/{api,client,common}
* logo.png - from /etc/core
* mcmod.info - from /etc/core
### MekanismGenerators.jar
* /mekanism/generators - .class files from /common/mekanism/generators
* logo.png - from /etc/generators
* mcmod.info - from /etc/generators
### MekanismTools.jar
* /mekanism/tools - .class files from /common/mekanism/tools
* logo.png - from /etc/tools
* mcmod.info - from /etc/tools

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB