v5.3.0 Release (hopefully)

*Removed unneeded textures.
*Added new, better textures!
*Revamped upgrade system.
*Machines and generators now only stack to 1.
*Machines and generators now drop with their upgrades and charge stored
in NBT.
*Fixed NEI plugin.
*Removed divider system for portable energy storage.
*Fixed some sound bugs.
*Fixed crazy entity item for energy cube and advanced solar generator.
*Made energy cube only drop in survival.
*Rewrote infusion system.
*Added liquid dictionary support.
*Added biofuel to ore dictionary.
*Bugfixes. Wooo!
This commit is contained in:
Aidan Brady 2013-02-14 13:26:13 -05:00
parent fb33db1ce2
commit d58222b028
78 changed files with 1854 additions and 789 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View file

@ -1,25 +0,0 @@
package mekanism.api;
import net.minecraft.item.ItemStack;
/**
* Implement this in your Item class if it can be used as a machine upgrade.
* @author AidanBrady
*
*/
public interface IMachineUpgrade
{
/**
* The energy boost this upgrade contains.
* @param itemstack - stack to check
* @return energy boost
*/
public int getEnergyBoost(ItemStack itemstack);
/**
* The operating tick reduction this upgrade provides.
* @param itemstack - stack to check
* @return tick reduction
*/
public int getTickReduction(ItemStack itemstack);
}

View file

@ -0,0 +1,12 @@
package mekanism.api;
public interface IUpgradeManagement
{
public int getEnergyMultiplier(Object... data);
public void setEnergyMultiplier(int multiplier, Object... data);
public int getSpeedMultiplier(Object... data);
public void setSpeedMultiplier(int multiplier, Object... data);
}

View file

@ -0,0 +1,13 @@
package mekanism.api;
public class InfuseObject
{
public InfusionType type;
public int stored;
public InfuseObject(InfusionType infusion, int i)
{
type = infusion;
stored = i;
}
}

View file

@ -14,13 +14,12 @@ public final class Tier
*/
public static enum EnergyCubeTier
{
BASIC("Basic", 1000000, 10000, 128),
ADVANCED("Advanced", 2500000, 25000, 256),
ELITE("Elite", 5000000, 50000, 512);
BASIC("Basic", 1000000, 128),
ADVANCED("Advanced", 2500000, 256),
ELITE("Elite", 5000000, 512);
public double MAX_ELECTRICITY;
public double VOLTAGE;
public int DIVIDER;
public int OUTPUT;
public String name;
@ -38,11 +37,10 @@ public final class Tier
return BASIC;
}
private EnergyCubeTier(String s, double maxEnergy, int divider, int out)
private EnergyCubeTier(String s, double maxEnergy, int out)
{
name = s;
MAX_ELECTRICITY = maxEnergy;
DIVIDER = divider;
OUTPUT = out;
}
}

View file

@ -34,6 +34,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.TextureFXManager;
import cpw.mods.fml.client.registry.ClientRegistry;
@ -50,6 +51,15 @@ public class ClientProxy extends CommonProxy
{
public static int RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void loadConfiguration()
{
super.loadConfiguration();
Mekanism.configuration.load();
Mekanism.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true);
}
@Override
public int getArmorIndex(String string)
{
@ -73,11 +83,9 @@ public class ClientProxy extends CommonProxy
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/CrusherFront.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/CompressorFront.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/CombinerFront.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/ElementizerFront.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/ElementizerBack.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/ElementizerSide.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/HydrogenFront.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/HydrogenSide.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/InfuserFront.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/InfuserBack.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/InfuserSide.png");
MinecraftForgeClient.preloadTexture("/resources/mekanism/animate/PurificationChamberFront.png");
//Register animated TextureFX
@ -85,11 +93,9 @@ public class ClientProxy extends CommonProxy
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/CrusherFront.png", Mekanism.ANIMATED_TEXTURE_INDEX+1));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/CompressorFront.png", Mekanism.ANIMATED_TEXTURE_INDEX+2));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/CombinerFront.png", Mekanism.ANIMATED_TEXTURE_INDEX+3));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/ElementizerFront.png", Mekanism.ANIMATED_TEXTURE_INDEX+4));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/ElementizerBack.png", Mekanism.ANIMATED_TEXTURE_INDEX+5));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/ElementizerSide.png", Mekanism.ANIMATED_TEXTURE_INDEX+6));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/InfuserFront.png", Mekanism.ANIMATED_TEXTURE_INDEX+7));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/InfuserSide.png", Mekanism.ANIMATED_TEXTURE_INDEX+8));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/InfuserFront.png", Mekanism.ANIMATED_TEXTURE_INDEX+4));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/InfuserBack.png", Mekanism.ANIMATED_TEXTURE_INDEX+5));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/InfuserSide.png", Mekanism.ANIMATED_TEXTURE_INDEX+6));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/resources/mekanism/animate/PurificationChamberFront.png", Mekanism.ANIMATED_TEXTURE_INDEX+9));
} catch (IOException e) {
System.err.println("[Mekanism] Error registering animation with FML: " + e.getMessage());
@ -181,22 +187,28 @@ public class ClientProxy extends CommonProxy
@Override
public void loadSoundHandler()
{
if(Mekanism.enableSounds)
{
Mekanism.audioHandler = new SoundHandler();
}
}
@Override
public void unloadSoundHandler()
{
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
for(Sound sound : Mekanism.audioHandler.sounds)
{
sound.stop();
sound.stopLoop();
Mekanism.audioHandler.soundSystem.removeSource(sound.identifier);
}
Mekanism.audioHandler.sounds.clear();
}
}
}
}

View file

@ -2,11 +2,14 @@ package mekanism.client;
import java.util.EnumSet;
import org.lwjgl.input.Keyboard;
import mekanism.common.Mekanism;
import mekanism.common.MekanismUtils;
import net.minecraft.src.ModLoader;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
@ -22,21 +25,24 @@ public class ClientTickHandler implements ITickHandler
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
if(!hasNotified && ModLoader.getMinecraftInstance().theWorld != null && ModLoader.getMinecraftInstance().thePlayer != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
if(!hasNotified && FMLClientHandler.instance().getClient().theWorld != null && FMLClientHandler.instance().getClient().thePlayer != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
{
MekanismUtils.checkForUpdates(ModLoader.getMinecraftInstance().thePlayer);
MekanismUtils.checkForUpdates(FMLClientHandler.instance().getClient().thePlayer);
hasNotified = true;
}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
Mekanism.audioHandler.onTick();
}
}
}
@Override
public EnumSet<TickType> ticks()

View file

@ -14,6 +14,7 @@ public class GuiAdvancedElectricMachine extends GuiContainer
public GuiAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity)
{
super(new ContainerAdvancedElectricMachine(inventory, tentity));
xSize+=26;
tileEntity = tentity;
}
@ -36,12 +37,15 @@ public class GuiAdvancedElectricMachine extends GuiContainer
int displayInt;
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 19 + 52 - displayInt, 4, displayInt);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 26, 19 + 52 - displayInt, 4, displayInt);
displayInt = tileEntity.getScaledSecondaryEnergyLevel(12);
drawTexturedModalRect(guiWidth + 61, guiHeight + 37 + 12 - displayInt, 176, 7 + 12 - displayInt, 5, displayInt);
drawTexturedModalRect(guiWidth + 61, guiHeight + 37 + 12 - displayInt, 176 + 26, 7 + 12 - displayInt, 5, displayInt);
displayInt = tileEntity.getScaledProgress(24);
drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7);
drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176 + 26, 0, displayInt + 1, 7);
displayInt = tileEntity.getScaledUpgradeProgress(14);
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 71, 10, displayInt);
}
}

View file

@ -14,6 +14,7 @@ public class GuiElectricMachine extends GuiContainer
public GuiElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity)
{
super(new ContainerElectricMachine(inventory, tentity));
xSize+=26;
tileEntity = tentity;
}
@ -36,9 +37,12 @@ public class GuiElectricMachine extends GuiContainer
int displayInt;
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 7 + 52 - displayInt, 4, displayInt);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 26, 7 + 52 - displayInt, 4, displayInt);
displayInt = tileEntity.getScaledProgress(24);
drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7);
drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176 + 26, 0, displayInt + 1, 7);
displayInt = tileEntity.getScaledUpgradeProgress(14);
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 59, 10, displayInt);
}
}

View file

@ -19,6 +19,7 @@ public class GuiMetallurgicInfuser extends GuiContainer
public GuiMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity)
{
super(new ContainerMetallurgicInfuser(inventory, tentity));
xSize+=26;
tileEntity = tentity;
}
@ -41,7 +42,7 @@ public class GuiMetallurgicInfuser extends GuiContainer
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
fontRenderer.drawString("Inventory", 15, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
}
@Override
@ -57,12 +58,15 @@ public class GuiMetallurgicInfuser extends GuiContainer
int displayInt;
displayInt = tileEntity.getScaledInfuseLevel(52);
drawTexturedModalRect(guiWidth + 7, guiHeight + 27 + 52 - displayInt, 176 + (tileEntity.type == InfusionType.COAL ? 4 : 0), 52 + (tileEntity.type == InfusionType.TIN ? 52 : 0) - displayInt, 4, displayInt);
drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176 + 26 + (tileEntity.type == InfusionType.COAL ? 4 : 0), 52 + (tileEntity.type == InfusionType.TIN ? 52 : 0) - displayInt, 4, displayInt);
displayInt = tileEntity.getScaledProgress(32);
drawTexturedModalRect(guiWidth + 72, guiHeight + 47, 176, 52 + 52, displayInt + 1, 8);
drawTexturedModalRect(guiWidth + 72, guiHeight + 47, 176 + 26, 52 + 52, displayInt + 1, 8);
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 26, 52 - displayInt, 4, displayInt);
displayInt = tileEntity.getScaledUpgradeProgress(14);
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 112, 10, displayInt);
}
}

View file

@ -15,6 +15,7 @@ public class GuiSmeltingFactory extends GuiContainer
public GuiSmeltingFactory(InventoryPlayer inventory, TileEntitySmeltingFactory tentity)
{
super(new ContainerSmeltingFactory(inventory, tentity));
xSize+=26;
tileEntity = tentity;
}
@ -38,7 +39,10 @@ public class GuiSmeltingFactory extends GuiContainer
int displayInt;
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt);
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 26, 52 - displayInt, 4, displayInt);
displayInt = tileEntity.getScaledUpgradeProgress(14);
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 72, 10, displayInt);
if(tileEntity.tier == SmeltingFactoryTier.BASIC)
{
@ -47,7 +51,7 @@ public class GuiSmeltingFactory extends GuiContainer
int xAxis = 59 + (i*38);
displayInt = tileEntity.getScaledProgress(20, i);
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176, 52, 8, displayInt);
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176 + 26, 52, 8, displayInt);
}
}
else if(tileEntity.tier == SmeltingFactoryTier.ADVANCED)
@ -57,7 +61,7 @@ public class GuiSmeltingFactory extends GuiContainer
int xAxis = 39 + (i*26);
displayInt = tileEntity.getScaledProgress(20, i);
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176, 52, 8, displayInt);
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176 + 26, 52, 8, displayInt);
}
}
else if(tileEntity.tier == SmeltingFactoryTier.ELITE)
@ -67,7 +71,7 @@ public class GuiSmeltingFactory extends GuiContainer
int xAxis = 33 + (i*19);
displayInt = tileEntity.getScaledProgress(20, i);
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176, 52, 8, displayInt);
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176 + 26, 52, 8, displayInt);
}
}
}

View file

@ -1,6 +1,7 @@
package mekanism.client;
import mekanism.common.EnumColor;
import mekanism.common.MekanismUtils;
import mekanism.common.TileEntityTheoreticalElementizer;
import net.minecraft.entity.player.InventoryPlayer;
@ -18,7 +19,7 @@ public class GuiTheoreticalElementizer extends GuiAdvancedElectricMachine
String displayText = "";
if(tileEntity.isActive)
{
if(tileEntity.currentTicksRequired == 1000)
if(MekanismUtils.getTicks(tileEntity.speedMultiplier) == 1000)
{
displayText = "Status: " + Double.toString(Math.round(tileEntity.operatingTicks/10)).replace(".0", "") + "%";
}

View file

@ -94,7 +94,7 @@ public class Sound
/**
* Stop looping the sound effect
*/
public void stop()
public void stopLoop()
{
synchronized(Mekanism.audioHandler.sounds)
{
@ -120,7 +120,7 @@ public class Sound
{
if(isPlaying)
{
stop();
stopLoop();
}
Mekanism.audioHandler.sounds.remove(this);
@ -132,11 +132,11 @@ public class Sound
}
}
/** Updates the volume based on how far away the player is from the machine.
*
/**
* Updates the volume based on how far away the player is from the machine.
* @param entityplayer - player who is near the machine, always Minecraft.thePlayer
*/
public void updateVolume(EntityPlayer entityplayer)
public void distanceUpdate(EntityPlayer entityplayer)
{
synchronized(Mekanism.audioHandler.sounds)
{

View file

@ -43,7 +43,7 @@ public class SoundHandler
{
if(FMLClientHandler.instance().getClient().thePlayer != null && FMLClientHandler.instance().getClient().theWorld != null)
{
sound.updateVolume(FMLClientHandler.instance().getClient().thePlayer);
sound.distanceUpdate(FMLClientHandler.instance().getClient().thePlayer);
}
}

View file

@ -17,14 +17,17 @@ import mekanism.generators.common.BlockGenerator.GeneratorType;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.src.*;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -203,21 +206,6 @@ public class BlockEnergyCube extends BlockContainer
}
}
}
EntityItem entityItem = new EntityItem(world, x, y, z, new ItemStack(Mekanism.EnergyCube));
float motion = 0.05F;
entityItem.motionX = powerRand.nextGaussian() * motion;
entityItem.motionY = powerRand.nextGaussian() * motion + 0.2F;
entityItem.motionZ = powerRand.nextGaussian() * motion;
IEnergyCube energyCube = (IEnergyCube)entityItem.getEntityItem().getItem();
energyCube.setTier(entityItem.getEntityItem(), tileEntity.tier);
IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem();
electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem());
world.spawnEntityInWorld(entityItem);
}
super.breakBlock(world, x, y, z, i1, i2);
@ -225,6 +213,12 @@ public class BlockEnergyCube extends BlockContainer
@Override
public int quantityDropped(Random random)
{
return 0;
}
@Override
public int idDropped(int i, Random random, int j)
{
return 0;
}
@ -246,28 +240,6 @@ public class BlockEnergyCube extends BlockContainer
};
}
/*@Override
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
if(world.getBlockTileEntity(x, y, z) != null)
{
ItemStack itemstack = new ItemStack(Mekanism.EnergyCube);
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z);
IEnergyCube energyCube = (IEnergyCube)itemstack.getItem();
energyCube.setTier(itemstack, tileEntity.tier);
IItemElectric electricItem = (IItemElectric)itemstack.getItem();
electricItem.setJoules(tileEntity.electricityStored, itemstack);
ret.add(itemstack);
}
return ret;
}*/
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3)
{
@ -324,6 +296,32 @@ public class BlockEnergyCube extends BlockContainer
return false;
}
@Override
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
{
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z);
float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, new ItemStack(Mekanism.EnergyCube));
IEnergyCube energyCube = (IEnergyCube)entityItem.getEntityItem().getItem();
energyCube.setTier(entityItem.getEntityItem(), tileEntity.tier);
IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem();
electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem());
world.spawnEntityInWorld(entityItem);
}
return world.setBlockWithNotify(x, y, z, 0);
}
@Override
public String getTextureFile()
{
@ -335,4 +333,19 @@ public class BlockEnergyCube extends BlockContainer
{
return new TileEntityEnergyCube();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z);
ItemStack itemStack = new ItemStack(Mekanism.EnergyCube);
IEnergyCube energyCube = (IEnergyCube)itemStack.getItem();
energyCube.setTier(itemStack, tileEntity.tier);
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
electricItem.setJoules(tileEntity.electricityStored, itemStack);
return itemStack;
}
}

View file

@ -7,6 +7,8 @@ import universalelectricity.core.implement.IItemElectric;
import universalelectricity.prefab.implement.IToolConfigurator;
import mekanism.api.IActiveState;
import mekanism.api.IEnergyCube;
import mekanism.api.IUpgradeManagement;
import mekanism.client.ClientProxy;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -19,6 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -133,7 +136,7 @@ public class BlockMachine extends BlockContainer
return 9;
}
else {
return 26;
return 2;
}
}
else if(meta == 1)
@ -143,7 +146,7 @@ public class BlockMachine extends BlockContainer
return 14;
}
else {
return 26;
return 2;
}
}
else if(meta == 2)
@ -224,12 +227,16 @@ public class BlockMachine extends BlockContainer
}
else if(meta == 8)
{
if(side == 3)
if(side == 0 || side == 1)
{
return 33;
return 18;
}
else if(side == 3)
{
return 16;
}
else {
return 32;
return 19;
}
}
else if(meta == 9)
@ -261,7 +268,7 @@ public class BlockMachine extends BlockContainer
return MekanismUtils.isActive(world, x, y, z) ? 8 : 9;
}
else {
return 26;
return 2;
}
}
else if(metadata == 1)
@ -271,7 +278,7 @@ public class BlockMachine extends BlockContainer
return MekanismUtils.isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX+2 : 14;
}
else {
return 26;
return 2;
}
}
else if(metadata == 2)
@ -358,12 +365,22 @@ public class BlockMachine extends BlockContainer
}
else if(metadata == 8)
{
if(side == tileEntity.facing)
if(side == 0 || side == 1)
{
return MekanismUtils.isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX+7 : 33;
return MekanismUtils.isActive(world, x, y, z) ? 20 : 18;
}
else {
return MekanismUtils.isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX+8 : 32;
if(side == tileEntity.facing)
{
return MekanismUtils.isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX+4 : 16;
}
else if(side == ForgeDirection.getOrientation(tileEntity.facing).getOpposite().ordinal())
{
return MekanismUtils.isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX+5 : 17;
}
else {
return MekanismUtils.isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX+6 : 19;
}
}
}
else if(metadata == 9)
@ -541,28 +558,73 @@ public class BlockMachine extends BlockContainer
return ClientProxy.RENDER_ID;
}
@Override
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
{
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, new ItemStack(Mekanism.MachineBlock, 1, world.getBlockMetadata(x, y, z)));
IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem();
electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem());
IUpgradeManagement upgrade = (IUpgradeManagement)entityItem.getEntityItem().getItem();
upgrade.setEnergyMultiplier(((IUpgradeManagement)tileEntity).getEnergyMultiplier(), entityItem.getEntityItem());
upgrade.setSpeedMultiplier(((IUpgradeManagement)tileEntity).getSpeedMultiplier(), entityItem.getEntityItem());
world.spawnEntityInWorld(entityItem);
}
return world.setBlockWithNotify(x, y, z, 0);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
ItemStack itemStack = new ItemStack(Mekanism.MachineBlock, 1, world.getBlockMetadata(x, y, z));
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
electricItem.setJoules(tileEntity.electricityStored, itemStack);
IUpgradeManagement upgrade = (IUpgradeManagement)itemStack.getItem();
upgrade.setEnergyMultiplier(((IUpgradeManagement)tileEntity).getEnergyMultiplier(), itemStack);
upgrade.setSpeedMultiplier(((IUpgradeManagement)tileEntity).getSpeedMultiplier(), itemStack);
return itemStack;
}
public static enum MachineType
{
ENRICHMENT_CHAMBER(0, 3, TileEntityEnrichmentChamber.class, false),
PLATINUM_COMPRESSOR(1, 4, TileEntityPlatinumCompressor.class, false),
COMBINER(2, 5, TileEntityCombiner.class, false),
CRUSHER(3, 6, TileEntityCrusher.class, false),
THEORETICAL_ELEMENTIZER(4, 7, TileEntityTheoreticalElementizer.class, true),
BASIC_SMELTING_FACTORY(5, 11, TileEntitySmeltingFactory.class, false),
ADVANCED_SMELTING_FACTORY(6, 11, TileEntityAdvancedSmeltingFactory.class, false),
ELITE_SMELTING_FACTORY(7, 11, TileEntityEliteSmeltingFactory.class, false),
METALLURGIC_INFUSER(8, 12, TileEntityMetallurgicInfuser.class, false),
PURIFICATION_CHAMBER(9, 15, TileEntityPurificationChamber.class, false);
ENRICHMENT_CHAMBER(0, 3, 3200, TileEntityEnrichmentChamber.class, false),
PLATINUM_COMPRESSOR(1, 4, 3200, TileEntityPlatinumCompressor.class, false),
COMBINER(2, 5, 3200, TileEntityCombiner.class, false),
CRUSHER(3, 6, 3200, TileEntityCrusher.class, false),
THEORETICAL_ELEMENTIZER(4, 7, 4800, TileEntityTheoreticalElementizer.class, true),
BASIC_SMELTING_FACTORY(5, 11, 9600, TileEntitySmeltingFactory.class, false),
ADVANCED_SMELTING_FACTORY(6, 11, 16000, TileEntityAdvancedSmeltingFactory.class, false),
ELITE_SMELTING_FACTORY(7, 11, 22400, TileEntityEliteSmeltingFactory.class, false),
METALLURGIC_INFUSER(8, 12, 3200, TileEntityMetallurgicInfuser.class, false),
PURIFICATION_CHAMBER(9, 15, 12000, TileEntityPurificationChamber.class, false);
public int meta;
public int guiId;
public double baseEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean hasModel;
private MachineType(int i, int j, Class<? extends TileEntity> tileClass, boolean model)
private MachineType(int i, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
{
meta = i;
guiId = j;
baseEnergy = k;
tileEntityClass = tileClass;
hasModel = model;
}

View file

@ -24,13 +24,7 @@ public class CommandMekanism extends CommandBase
@Override
public List getCommandAliases()
{
return Arrays.asList(new String[] {"mekanism"});
}
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
return !MinecraftServer.getServer().isSinglePlayer() && super.canCommandSenderUseCommand(sender);
return Arrays.asList(new String[] {"mekanism", "mek"});
}
@Override

View file

@ -69,6 +69,7 @@ public class CommonProxy
Mekanism.disableBCSteelCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCSteelCrafting", false).getBoolean(true);
Mekanism.disableBCBronzeCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCBronzeCrafting", false).getBoolean(true);
Mekanism.updateNotifications = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpdateNotifications", true).getBoolean(true);
Mekanism.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean(true);
Mekanism.configuration.save();
}

View file

@ -22,7 +22,7 @@ public class ContainerAdvancedElectricMachine extends Container
addSlotToContainer(new Slot(tentity, 1, 56, 53));
addSlotToContainer(new SlotFurnace(inventory.player, tentity, 2, 116, 35));
addSlotToContainer(new SlotEnergy(tentity, 3, 31, 35));
addSlotToContainer(new SlotMachineUpgrade(tentity, 4, 7, 7));
addSlotToContainer(new SlotMachineUpgrade(tentity, 4, 180, 11));
int slotX;
for (slotX = 0; slotX < 3; ++slotX)

View file

@ -20,7 +20,7 @@ public class ContainerElectricMachine extends Container
addSlotToContainer(new Slot(tentity, 0, 56, 17));
addSlotToContainer(new SlotEnergy(tentity, 1, 56, 53));
addSlotToContainer(new SlotFurnace(inventory.player, tentity, 2, 116, 35));
addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 7, 7));
addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11));
int slotX;
for (slotX = 0; slotX < 3; ++slotX)

View file

@ -1,5 +1,7 @@
package mekanism.common;
import java.util.Map;
import ic2.api.IElectricItem;
import mekanism.api.InfusionInput;
import mekanism.api.InfusionOutput;
@ -21,7 +23,7 @@ public class ContainerMetallurgicInfuser extends Container
public ContainerMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity)
{
tileEntity = tentity;
addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 7, 7));
addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11));
addSlotToContainer(new Slot(tentity, 1, 17, 35));
addSlotToContainer(new Slot(tentity, 2, 51, 43));
addSlotToContainer(new SlotFurnace(inventory.player, tentity, 3, 109, 43));
@ -70,7 +72,7 @@ public class ContainerMetallurgicInfuser extends Container
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4)
{
if(MekanismUtils.oreDictCheck(slotStack, "dustTin") && (tileEntity.type == InfusionType.TIN || tileEntity.type == InfusionType.NONE))
if(MekanismUtils.getInfuseObject(slotStack) != null && (tileEntity.type == InfusionType.NONE || tileEntity.type == MekanismUtils.getInfuseObject(slotStack).type))
{
if(!mergeItemStack(slotStack, 1, 2, false))
{
@ -84,13 +86,6 @@ public class ContainerMetallurgicInfuser extends Container
return null;
}
}
else if(slotStack.isItemEqual(new ItemStack(Mekanism.CompressedCarbon)) && (tileEntity.type == InfusionType.COAL || tileEntity.type == InfusionType.NONE))
{
if(!mergeItemStack(slotStack, 1, 2, false))
{
return null;
}
}
else if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem)
{
if(!mergeItemStack(slotStack, 4, 5, false))
@ -98,7 +93,7 @@ public class ContainerMetallurgicInfuser extends Container
return null;
}
}
else if(RecipeHandler.getOutput(InfusionInput.getInfusion(tileEntity.type, tileEntity.infuseStored, slotStack), false, Recipe.METALLURGIC_INFUSER.get()) != null)
else if(isInputItem(slotStack))
{
if(!mergeItemStack(slotStack, 2, 3, false))
{
@ -154,4 +149,27 @@ public class ContainerMetallurgicInfuser extends Container
return stack;
}
public boolean isInputItem(ItemStack itemStack)
{
if(tileEntity.type != InfusionType.NONE)
{
if(RecipeHandler.getOutput(InfusionInput.getInfusion(tileEntity.type, tileEntity.infuseStored, itemStack), false, Recipe.METALLURGIC_INFUSER.get()) != null)
{
return true;
}
}
else {
for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet())
{
InfusionInput input = (InfusionInput)obj;
if(input.inputSlot.isItemEqual(itemStack))
{
return true;
}
}
}
return false;
}
}

View file

@ -21,7 +21,7 @@ public class ContainerSmeltingFactory extends Container
{
tileEntity = tentity;
addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 7, 7));
addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11));
addSlotToContainer(new SlotEnergy(tentity, 1, 7, 35));
if(tileEntity.tier == SmeltingFactoryTier.BASIC)

View file

@ -5,7 +5,9 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
@ -13,7 +15,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
{
public ItemAtomicDisassembler(int id)
{
super(id, 120000, 512, 1200);
super(id, 1000000, 120);
}
@Override
@ -27,7 +29,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
{
super.addInformation(itemstack, entityplayer, list, flag);
list.add("Block efficiency: 40");
list.add("Block efficiency: " + getEfficiency(itemstack));
}
@Override
@ -35,7 +37,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
{
if(getJoules(itemstack) > 0)
{
hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 18);
hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 20);
onUse(2000, itemstack);
}
else {
@ -46,7 +48,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
public float getStrVsBlock(ItemStack itemstack, Block block)
{
return getJoules(itemstack) != 0 ? 40F : 1F;
return getJoules(itemstack) != 0 ? getEfficiency(itemstack) : 1F;
}
@Override
@ -54,10 +56,10 @@ public class ItemAtomicDisassembler extends ItemEnergized
{
if ((double)Block.blocksList[id].getBlockHardness(world, x, y, z) != 0.0D)
{
onUse(120, itemstack);
onUse(getEfficiency(itemstack), itemstack);
}
else {
onUse(60, itemstack);
onUse(getEfficiency(itemstack)/2, itemstack);
}
return true;
@ -74,4 +76,69 @@ public class ItemAtomicDisassembler extends ItemEnergized
{
return false;
}
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
if(!world.isRemote)
{
incrementEfficiency(itemstack);
entityplayer.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Efficiency bumped to " + getEfficiency(itemstack));
}
return itemstack;
}
public int getEfficiency(ItemStack itemStack)
{
if(itemStack.stackTagCompound == null)
{
return 5;
}
int efficiency = 5;
if(itemStack.stackTagCompound.getTag("efficiency") != null)
{
efficiency = itemStack.stackTagCompound.getInteger("efficiency");
}
return efficiency;
}
public void incrementEfficiency(ItemStack itemStack)
{
if(itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
itemStack.stackTagCompound.setInteger("efficiency", 20);
}
itemStack.stackTagCompound.setInteger("efficiency", getIncremented(getEfficiency(itemStack)));
}
public int getIncremented(int previous)
{
if(previous == 5)
{
return 10;
}
else if(previous == 10)
{
return 25;
}
else if(previous == 25)
{
return 50;
}
else if(previous == 50)
{
return 100;
}
else if(previous == 100)
{
return 5;
}
return 0;
}
}

View file

@ -79,7 +79,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IItemElectric, IEn
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
}
itemStack.setItemDamage((int)(getTier(itemStack).MAX_ELECTRICITY - electricityStored)/getTier(itemStack).DIVIDER);
itemStack.setItemDamage((int)(Math.abs(((electricityStored/getTier(itemStack).MAX_ELECTRICITY)*100)-100)));
return electricityStored;
}
@ -100,7 +100,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IItemElectric, IEn
double electricityStored = Math.max(Math.min(wattHours, getMaxJoules(itemStack)), 0);
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
itemStack.setItemDamage((int)(getTier(itemStack).MAX_ELECTRICITY - electricityStored)/getTier(itemStack).DIVIDER);
itemStack.setItemDamage((int)(Math.abs(((electricityStored/getTier(itemStack).MAX_ELECTRICITY)*100)-100)));
}
}
@ -113,6 +113,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IItemElectric, IEn
return getTier(itemstack).MAX_ELECTRICITY;
}
return EnergyCubeTier.BASIC.MAX_ELECTRICITY;
}

View file

@ -1,8 +1,21 @@
package mekanism.common;
import java.util.List;
import ic2.api.ICustomElectricItem;
import universalelectricity.core.electricity.ElectricInfo;
import universalelectricity.core.electricity.ElectricInfo.ElectricUnit;
import universalelectricity.core.implement.IItemElectric;
import mekanism.api.IUpgradeManagement;
import mekanism.common.BlockMachine.MachineType;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.world.World;
/**
* Item class for handling multiple machine block IDs.
@ -19,7 +32,7 @@ import net.minecraft.item.ItemStack;
* @author AidanBrady
*
*/
public class ItemBlockMachine extends ItemBlock
public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICustomElectricItem, IUpgradeManagement
{
public Block metaBlock;
@ -28,6 +41,8 @@ public class ItemBlockMachine extends ItemBlock
super(id);
metaBlock = block;
setHasSubtypes(true);
setNoRepair();
setMaxStackSize(1);
}
@Override
@ -36,12 +51,6 @@ public class ItemBlockMachine extends ItemBlock
return i;
}
@Override
public int getIconFromDamage(int i)
{
return metaBlock.getBlockTextureFromSideAndMetadata(2, i);
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
@ -84,4 +93,278 @@ public class ItemBlockMachine extends ItemBlock
}
return getItemName() + "." + name;
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
double energy = getJoules(itemstack);
list.add("Stored Energy: " + ElectricInfo.getDisplayShort(energy, ElectricUnit.JOULES));
list.add("Energy: x" + (getEnergyMultiplier(itemstack)+1));
list.add("Speed: x" + (getSpeedMultiplier(itemstack)+1));
}
@Override
public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
{
ItemBlockMachine item = ((ItemBlockMachine)itemstack.getItem());
item.setJoules(item.getJoules(itemstack), itemstack);
}
@Override
public double getJoules(Object... data)
{
if (data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack) data[0];
if (itemStack.stackTagCompound == null)
{
return 0;
}
double electricityStored = 0;
if (itemStack.stackTagCompound.getTag("electricity") instanceof NBTTagFloat)
{
electricityStored = itemStack.stackTagCompound.getFloat("electricity");
}
else
{
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
}
return electricityStored;
}
return -1;
}
@Override
public void setJoules(double wattHours, Object... data)
{
if (data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
double electricityStored = Math.max(Math.min(wattHours, getMaxJoules(itemStack)), 0);
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
}
}
@Override
public double getMaxJoules(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemstack = (ItemStack)data[0];
return MekanismUtils.getEnergy(getEnergyMultiplier(itemstack), MachineType.getFromMetadata(itemstack.getItemDamage()).baseEnergy);
}
return 3200;
}
@Override
public double getVoltage(Object... data)
{
return 120;
}
@Override
public double onReceive(double amps, double voltage, ItemStack itemStack)
{
double rejectedElectricity = Math.max((getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)) - getMaxJoules(itemStack), 0);
setJoules(getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1) - rejectedElectricity, itemStack);
return rejectedElectricity;
}
@Override
public double onUse(double joulesNeeded, ItemStack itemStack)
{
double electricityToUse = Math.min(getJoules(itemStack), joulesNeeded);
setJoules(getJoules(itemStack) - electricityToUse, itemStack);
return electricityToUse;
}
@Override
public boolean canReceiveElectricity()
{
return true;
}
@Override
public boolean canProduceElectricity()
{
return false;
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
if (place)
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof IUpgradeManagement)
{
((IUpgradeManagement)tileEntity).setEnergyMultiplier(getEnergyMultiplier(stack));
((IUpgradeManagement)tileEntity).setSpeedMultiplier(getSpeedMultiplier(stack));
}
tileEntity.electricityStored = getJoules(stack);
}
return place;
}
@Override
public int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
{
double givenEnergy = amount*Mekanism.FROM_IC2;
double energyNeeded = getMaxJoules(itemStack)-getJoules(itemStack);
double energyToStore = Math.min(Math.min(amount, getMaxJoules(itemStack)*0.01), energyNeeded);
if(!simulate)
{
setJoules(getJoules(itemStack) + energyToStore, itemStack);
}
return (int)(energyToStore*Mekanism.TO_IC2);
}
@Override
public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
{
double energyWanted = amount*Mekanism.FROM_IC2;
double energyToGive = Math.min(Math.min(energyWanted, getMaxJoules(itemStack)*0.01), getJoules(itemStack));
if(!simulate)
{
setJoules(getJoules(itemStack) - energyToGive, itemStack);
}
return (int)(energyToGive*Mekanism.TO_IC2);
}
@Override
public boolean canUse(ItemStack itemStack, int amount)
{
return getJoules(itemStack) >= amount*Mekanism.FROM_IC2;
}
@Override
public boolean canShowChargeToolTip(ItemStack itemStack)
{
return false;
}
@Override
public boolean canProvideEnergy()
{
return canProduceElectricity();
}
@Override
public int getChargedItemId()
{
return itemID;
}
@Override
public int getEmptyItemId()
{
return itemID;
}
@Override
public int getMaxCharge()
{
return 0;
}
@Override
public int getTier()
{
return 3;
}
@Override
public int getTransferLimit()
{
return (int)(getVoltage()*Mekanism.TO_IC2);
}
@Override
public int getEnergyMultiplier(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack) data[0];
if (itemStack.stackTagCompound == null)
{
return 0;
}
return itemStack.stackTagCompound.getInteger("energyMultiplier");
}
return 0;
}
@Override
public void setEnergyMultiplier(int multiplier, Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.stackTagCompound.setInteger("energyMultiplier", multiplier);
}
}
@Override
public int getSpeedMultiplier(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack) data[0];
if (itemStack.stackTagCompound == null)
{
return 0;
}
return itemStack.stackTagCompound.getInteger("speedMultiplier");
}
return 0;
}
@Override
public void setSpeedMultiplier(int multiplier, Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.stackTagCompound.setInteger("speedMultiplier", multiplier);
}
}
}

View file

@ -13,7 +13,7 @@ public class ItemConfigurator extends ItemEnergized
public ItemConfigurator(int id)
{
super(id, 60000, 120, 600);
super(id, 60000, 120);
}
@Override

View file

@ -16,7 +16,7 @@ public class ItemElectricBow extends ItemEnergized
{
public ItemElectricBow(int id)
{
super(id, 120000, 120, 1200);
super(id, 120000, 120);
}
@Override

View file

@ -23,13 +23,9 @@ public class ItemEnergized extends ItemMekanism implements IItemElectric, ICusto
/** How fast this item can transfer energy. */
public double VOLTAGE;
/** The number that, when the max amount of energy is divided by, will make it equal 100. */
public int DIVIDER;
public ItemEnergized(int id, double maxElectricity, double voltage, int divider)
public ItemEnergized(int id, double maxElectricity, double voltage)
{
super(id);
DIVIDER = divider;
MAX_ELECTRICITY = maxElectricity;
VOLTAGE = voltage;
setMaxStackSize(1);
@ -100,7 +96,7 @@ public class ItemEnergized extends ItemMekanism implements IItemElectric, ICusto
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
}
itemStack.setItemDamage((int)(MAX_ELECTRICITY - electricityStored)/DIVIDER);
itemStack.setItemDamage((int)(Math.abs(((electricityStored/MAX_ELECTRICITY)*100)-100)));
return electricityStored;
}
@ -121,7 +117,7 @@ public class ItemEnergized extends ItemMekanism implements IItemElectric, ICusto
double electricityStored = Math.max(Math.min(wattHours, getMaxJoules()), 0);
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
itemStack.setItemDamage((int)(MAX_ELECTRICITY - electricityStored)/DIVIDER);
itemStack.setItemDamage((int)(Math.abs(((electricityStored/MAX_ELECTRICITY)*100)-100)));
}
}

View file

@ -4,32 +4,19 @@ import java.util.List;
import universalelectricity.prefab.modifier.IModifier;
import mekanism.api.IMachineUpgrade;
import mekanism.api.TabProxy;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemMachineUpgrade extends Item implements IMachineUpgrade, IModifier
public class ItemMachineUpgrade extends Item implements IModifier
{
public int ENERGY_BOOST;
public int TICK_REDUCTION;
public ItemMachineUpgrade(int id, int energyBoost, int tickReduction)
{
super(id);
setMaxStackSize(1);
setCreativeTab(TabProxy.tabMekanism(CreativeTabs.tabMisc));
ENERGY_BOOST = energyBoost;
TICK_REDUCTION = tickReduction;
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
list.add("Energy Boost: " + ENERGY_BOOST);
list.add("Tick Reduction: " + TICK_REDUCTION);
setMaxStackSize(8);
setCreativeTab(Mekanism.tabMekanism);
}
@Override
@ -38,29 +25,15 @@ public class ItemMachineUpgrade extends Item implements IMachineUpgrade, IModifi
return "/resources/mekanism/textures/items.png";
}
@Override
public int getEnergyBoost(ItemStack itemstack)
{
return ENERGY_BOOST;
}
@Override
public int getTickReduction(ItemStack itemstack)
{
return TICK_REDUCTION;
}
@Override
public String getName(ItemStack itemstack)
{
return itemID == Mekanism.SpeedUpgrade.itemID ? "Speed" :
(itemID == Mekanism.EnergyUpgrade.itemID ? "Capacity" : "All");
return itemID == Mekanism.SpeedUpgrade.itemID ? "Speed" : "Capacity";
}
@Override
public int getEffectiveness(ItemStack itemstack)
{
return itemID == Mekanism.SpeedUpgrade.itemID ? 150 :
(itemID == Mekanism.EnergyUpgrade.itemID ? 1000 : 2500);
return itemID == Mekanism.SpeedUpgrade.itemID ? 150 : 1000;
}
}

View file

@ -11,7 +11,7 @@ public class ItemPortableTeleporter extends ItemEnergized
{
public ItemPortableTeleporter(int id)
{
super(id, 500000, 120, 5000);
super(id, 2000000, 120);
}
@Override
@ -40,7 +40,7 @@ public class ItemPortableTeleporter extends ItemEnergized
int distance = (int)entity.getDistanceSq(coords.xCoord, coords.yCoord, coords.zCoord);
neededEnergy+=(distance*10);
neededEnergy+=(distance);
return neededEnergy;
}

View file

@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import mekanism.api.InfuseObject;
import mekanism.api.InfusionInput;
import mekanism.api.InfusionOutput;
import mekanism.api.InfusionType;
@ -29,11 +30,13 @@ import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.ServerStarting;
import cpw.mods.fml.common.Mod.ServerStopping;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
@ -49,7 +52,7 @@ import cpw.mods.fml.server.FMLServerHandler;
* @author AidanBrady
*
*/
@Mod(modid = "Mekanism", name = "Mekanism", version = "5.2.3")
@Mod(modid = "Mekanism", name = "Mekanism", version = "5.3.0")
@NetworkMod(channels = {"Mekanism"}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class Mekanism
{
@ -71,11 +74,14 @@ public class Mekanism
public static Configuration configuration;
/** Mekanism version number */
public static Version versionNumber = new Version(5, 2, 3);
public static Version versionNumber = new Version(5, 3, 0);
/** Map of Teleporter info. */
public static Map<Teleporter.Code, ArrayList<Teleporter.Coords>> teleporters = new HashMap<Teleporter.Code, ArrayList<Teleporter.Coords>>();
/** Map of infuse objects */
public static Map<ItemStack, InfuseObject> infusions = new HashMap<ItemStack, InfuseObject>();
/** Mekanism creative tab */
public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism();
@ -147,6 +153,8 @@ public class Mekanism
public static boolean disableBCBronzeCrafting = true;
public static boolean disableBCSteelCrafting = true;
public static boolean updateNotifications = true;
public static boolean enableSounds = true;
public static boolean controlCircuitOreDict = true;
//Extra data
public static float ObsidianTNTBlastRadius = 12.0F;
@ -201,6 +209,9 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(BasicBlock, 1, 5), new Object[] {
"***", "***", "***", Character.valueOf('*'), "ingotSteel"
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(Ingot, 9, 4), new Object[] {
"*", Character.valueOf('*'), new ItemStack(BasicBlock, 1, 5)
}));
//Extra
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ObsidianTNT, 1), new Object[] {
@ -316,7 +327,6 @@ public class Mekanism
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 0, new ItemStack(Item.ingotIron), 1.0F);
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 1, new ItemStack(Item.ingotGold), 1.0F);
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 5, new ItemStack(Ingot, 1, 4), 1.0F);
GameRegistry.addSmelting(Item.coal.itemID, new ItemStack(CompressedCarbon), 1.0F);
//Enrichment Chamber Recipes
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Dust, 1, 4), new ItemStack(Item.diamond));
@ -324,7 +334,7 @@ public class Mekanism
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.obsidian), new ItemStack(Dust, 1, 3));
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreIron), new ItemStack(Dust, 2, 0));
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Dust, 2, 1));
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Item.coal, 4), new ItemStack(CompressedCarbon, 8));
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Item.coal, 2), new ItemStack(CompressedCarbon));
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreLapis), new ItemStack(Item.dyePowder, 12, 4));
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreRedstone), new ItemStack(Item.redstone, 12));
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreCoal), new ItemStack(Block.oreCoal));
@ -347,6 +357,10 @@ public class Mekanism
//Metallurgic Infuser Recipes
RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfusionType.COAL, 10, new ItemStack(EnrichedIron)), new ItemStack(Dust, 1, 5));
infusions.put(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfusionType.COAL, 10));
infusions.put(new ItemStack(Item.coal, 1, 1), new InfuseObject(InfusionType.COAL, 20));
infusions.put(new ItemStack(CompressedCarbon), new InfuseObject(InfusionType.COAL, 100));
}
/**
@ -362,9 +376,9 @@ public class Mekanism
{
LanguageRegistry.addName(Stopwatch, "Steve's Stopwatch");
LanguageRegistry.addName(WeatherOrb, "Weather Orb");
LanguageRegistry.addName(EnrichedAlloy, "Enriched Alloy");
}
LanguageRegistry.addName(EnrichedAlloy, "Enriched Alloy");
LanguageRegistry.addName(EnergyTablet, "Energy Tablet");
LanguageRegistry.addName(SpeedUpgrade, "Speed Upgrade");
LanguageRegistry.addName(EnergyUpgrade, "Energy Upgrade");
@ -461,9 +475,9 @@ public class Mekanism
{
Stopwatch.setIconIndex(224);
WeatherOrb.setIconIndex(226);
EnrichedAlloy.setIconIndex(227);
}
EnrichedAlloy.setIconIndex(227);
EnergyTablet.setIconIndex(228);
SpeedUpgrade.setIconIndex(232);
EnergyUpgrade.setIconIndex(231);
@ -494,7 +508,7 @@ public class Mekanism
}
Dust = new ItemDust(configuration.getItem("Dust", 11204).getInt()-256);
Ingot = new ItemIngot(configuration.getItem("Ingot", 11205).getInt()-256);
EnergyTablet = (ItemEnergized) new ItemEnergized(configuration.getItem("EnergyTablet", 11206).getInt(), 250000, 800, 2500).setItemName("EnergyTablet");
EnergyTablet = (ItemEnergized) new ItemEnergized(configuration.getItem("EnergyTablet", 11206).getInt(), 600000, 800).setItemName("EnergyTablet");
SpeedUpgrade = new ItemMachineUpgrade(configuration.getItem("SpeedUpgrade", 11207).getInt(), 0, 150).setItemName("SpeedUpgrade");
EnergyUpgrade = new ItemMachineUpgrade(configuration.getItem("EnergyUpgrade", 11208).getInt(), 1000, 0).setItemName("EnergyUpgrade");
UltimateUpgrade = new ItemMachineUpgrade(configuration.getItem("UltimateUpgrade", 11209).getInt(), 2500, 180).setItemName("UltimateUpgrade");
@ -584,8 +598,13 @@ public class Mekanism
OreDictionary.registerOre("orePlatinum", new ItemStack(OreBlock, 1, 0));
if(controlCircuitOreDict)
{
OreDictionary.registerOre("basicCircuit", new ItemStack(ControlCircuit));
}
OreDictionary.registerOre("compressedCarbon", new ItemStack(CompressedCarbon));
OreDictionary.registerOre("enrichedAlloy", new ItemStack(EnrichedAlloy));
if(hooks.IC2Loaded)
{
@ -728,6 +747,10 @@ public class Mekanism
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 7, OreDictionary.getOres("ingotTin").get(0), 1.0F);
} catch(Exception e) {}
try {
FurnaceRecipes.smelting().addSmelting(Dust.itemID, 8, OreDictionary.getOres("ingotSilver").get(0), 1.0F);
} catch(Exception e) {}
try {
for(ItemStack ore : OreDictionary.getOres("ingotCopper"))
{
@ -742,6 +765,13 @@ public class Mekanism
}
} catch(Exception e) {}
try {
for(ItemStack ore : OreDictionary.getOres("ingotSilver"))
{
RecipeHandler.addCrusherRecipe(MekanismUtils.getStackWithSize(ore, 1), new ItemStack(Dust, 1, 8));
}
} catch(Exception e) {}
for(ItemStack ore : OreDictionary.getOres("dustIron"))
{
RecipeHandler.addCombinerRecipe(MekanismUtils.getStackWithSize(ore, 8), new ItemStack(Block.oreIron));
@ -781,6 +811,7 @@ public class Mekanism
for(ItemStack ore : OreDictionary.getOres("dustTin"))
{
RecipeHandler.addCombinerRecipe(MekanismUtils.getStackWithSize(ore, 8), OreDictionary.getOres("oreTin").get(0));
infusions.put(ore, new InfuseObject(InfusionType.TIN, 100));
}
} catch(Exception e) {}
@ -830,13 +861,10 @@ public class Mekanism
proxy.registerSpecialTileEntities();
}
/**
* Registers the server command handler.
*/
@SideOnly(Side.SERVER)
public void registerServerCommands()
@ServerStarting
public void serverStarting(FMLServerStartingEvent event)
{
ServerCommandHandler.initialize();
event.registerServerCommand(new CommandMekanism());
}
@ServerStopping
@ -892,11 +920,6 @@ public class Mekanism
//Register to recieve subscribed events
MinecraftForge.EVENT_BUS.register(this);
//Attempt to load server commands
try {
registerServerCommands();
} catch(NoSuchMethodError e) {}
//Load this module
addItems();
addBlocks();

View file

@ -4,6 +4,7 @@ import universalelectricity.prefab.RecipeHelper;
import cpw.mods.fml.common.Loader;
import ic2.api.Ic2Recipes;
import ic2.api.Items;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.src.*;
@ -36,9 +37,12 @@ public final class MekanismHooks
public ItemStack IC2TinDust;
public ItemStack IC2CoalDust;
public int BuildCraftFuelID = 3808;
public int BuildCraftFuelID = 19108;
public ItemStack BuildCraftFuelBucket;
public int BuildCraftOilID = 1521;
public ItemStack BuildCraftOilBucket;
public int ForestryBiofuelID = 5013;
public ItemStack ForestryBiofuelBucket;
@ -98,6 +102,8 @@ public final class MekanismHooks
{
BuildCraftFuelID = getBuildCraftItem("fuel").itemID;
BuildCraftFuelBucket = getBuildCraftItem("bucketFuel");
BuildCraftOilID = getBuildCraftItem("oilStill").itemID;
BuildCraftOilBucket = getBuildCraftItem("bucketOil");
System.out.println("[Mekanism] Hooked into BuildCraft successfully.");
}
if(ForestryLoaded)
@ -124,6 +130,10 @@ public final class MekanismHooks
{
return (ItemStack)ret;
}
else if(ret instanceof Block)
{
return new ItemStack((Block)ret);
}
else {
throw new Exception("not instanceof ItemStack");
}
@ -144,6 +154,10 @@ public final class MekanismHooks
{
return new ItemStack((Item)ret);
}
else if(ret instanceof Block)
{
return new ItemStack((Block)ret);
}
else {
throw new Exception("not instanceof ItemStack");
}
@ -164,6 +178,10 @@ public final class MekanismHooks
{
return new ItemStack((Item)ret);
}
else if(ret instanceof Block)
{
return new ItemStack((Block)ret);
}
else {
throw new Exception("not instanceof ItemStack");
}
@ -184,6 +202,10 @@ public final class MekanismHooks
{
return new ItemStack((Item)ret);
}
else if(ret instanceof Block)
{
return new ItemStack((Block)ret);
}
else {
throw new Exception("not instanceof ItemStack");
}

View file

@ -5,9 +5,11 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.InfuseObject;
import mekanism.api.Tier.EnergyCubeTier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -41,7 +43,7 @@ public final class MekanismUtils
{
if(!Mekanism.latestVersionNumber.equals("Error retrieving data."))
{
if(!Mekanism.latestVersionNumber.contains(Mekanism.versionNumber.toString()))
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1)
{
entityplayer.addChatMessage(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------");
entityplayer.addChatMessage(EnumColor.GREY + " Using outdated version " + EnumColor.DARK_GREY + Mekanism.versionNumber + EnumColor.GREY + " for Minecraft 1.4.6/7.");
@ -50,6 +52,10 @@ public final class MekanismUtils
entityplayer.addChatMessage(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------");
return;
}
else if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == -1)
{
entityplayer.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Using developer build " + EnumColor.DARK_GREY + Mekanism.versionNumber);
}
}
else {
System.out.println("[Mekanism] Minecraft is in offline mode, could not check for updates.");
@ -343,4 +349,30 @@ public final class MekanismUtils
config.getConfiguration()[side] = 0;
}
}
public static InfuseObject getInfuseObject(ItemStack itemStack)
{
if(itemStack != null)
{
for(Map.Entry<ItemStack, InfuseObject> entry : Mekanism.infusions.entrySet())
{
if(itemStack.isItemEqual(entry.getKey()))
{
return entry.getValue();
}
}
}
return null;
}
public static int getTicks(int multiplier)
{
return 200/(multiplier+1);
}
public static double getEnergy(int multiplier, double def)
{
return def*(multiplier+1);
}
}

View file

@ -87,6 +87,8 @@ public final class RecipeHandler
* @return InfusionOutput
*/
public static InfusionOutput getOutput(InfusionInput infusion, boolean stackDecrease, Map<InfusionInput, InfusionOutput> recipes)
{
if(infusion != null && infusion.inputSlot != null)
{
for(Map.Entry entry : recipes.entrySet())
{
@ -103,6 +105,7 @@ public final class RecipeHandler
}
}
}
}
return null;
}
@ -115,6 +118,8 @@ public final class RecipeHandler
* @return output ItemStack
*/
public static ItemStack getOutput(ItemStack itemstack, boolean stackDecrease, Map<ItemStack, ItemStack> recipes)
{
if(itemstack != null)
{
for(Map.Entry entry : recipes.entrySet())
{
@ -128,6 +133,7 @@ public final class RecipeHandler
return ((ItemStack)entry.getValue()).copy();
}
}
}
return null;
}

View file

@ -1,25 +0,0 @@
package mekanism.common;
import net.minecraft.command.ServerCommandManager;
import cpw.mods.fml.common.FMLCommonHandler;
/**
* Handler to handle all incoming Mekanism commands.
* @author AidanBrady
*
*/
public class ServerCommandHandler
{
public static boolean initialized = false;
public static void initialize()
{
if(!initialized)
{
initialized = true;
ServerCommandManager manager = (ServerCommandManager)FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
manager.registerCommand(new CommandMekanism());
}
}
}

View file

@ -2,7 +2,6 @@ package mekanism.common;
import ic2.api.ElectricItem;
import ic2.api.IElectricItem;
import mekanism.api.IMachineUpgrade;
import mekanism.api.SideData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -76,7 +75,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
if(inventory[3] != null)
{
if(electricityStored < currentMaxElectricity)
if(electricityStored < MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
if(inventory[3].getItem() instanceof IItemElectric)
{
@ -84,18 +83,8 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
if (electricItem.canProduceElectricity())
{
double joulesNeeded = currentMaxElectricity-electricityStored;
double joulesReceived = 0;
if(electricItem.getVoltage(inventory[3]) <= joulesNeeded)
{
joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[3]), inventory[3]);
}
else if(electricItem.getVoltage(inventory[3]) > joulesNeeded)
{
joulesReceived = electricItem.onUse(joulesNeeded, inventory[3]);
}
double joulesNeeded = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
double joulesReceived = electricItem.onUse(Math.min(electricItem.getMaxJoules(inventory[3])*0.005, joulesNeeded), inventory[3]);
setJoules(electricityStored + joulesReceived);
}
}
@ -109,7 +98,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
}
}
}
if(inventory[3].itemID == Item.redstone.itemID && electricityStored+1000 <= currentMaxElectricity)
if(inventory[3].itemID == Item.redstone.itemID && electricityStored+1000 <= MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
setJoules(electricityStored + 1000);
--inventory[3].stackSize;
@ -121,41 +110,65 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
}
}
if(inventory[4] != null)
{
if(inventory[4].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
upgradeTicks = 0;
energyMultiplier+=1;
inventory[4].stackSize--;
if(inventory[4].stackSize == 0)
{
inventory[4] = null;
}
}
}
else if(inventory[4].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
upgradeTicks = 0;
speedMultiplier+=1;
inventory[4].stackSize--;
if(inventory[4].stackSize == 0)
{
inventory[4] = null;
}
}
}
else {
upgradeTicks = 0;
}
}
else {
upgradeTicks = 0;
}
handleSecondaryFuel();
if(inventory[4] != null && inventory[4].getItem() instanceof IMachineUpgrade)
{
int energyToAdd = 0;
int ticksToRemove = 0;
if(currentMaxElectricity == MAX_ELECTRICITY)
{
energyToAdd = ((IMachineUpgrade)inventory[4].getItem()).getEnergyBoost(inventory[4]);
}
if(currentTicksRequired == TICKS_REQUIRED)
{
ticksToRemove = ((IMachineUpgrade)inventory[4].getItem()).getTickReduction(inventory[4]);
}
currentMaxElectricity += energyToAdd;
currentTicksRequired -= ticksToRemove;
}
else if(inventory[4] == null)
{
currentTicksRequired = TICKS_REQUIRED;
currentMaxElectricity = MAX_ELECTRICITY;
}
if(electricityStored >= ENERGY_PER_TICK && secondaryEnergyStored >= SECONDARY_ENERGY_PER_TICK)
{
if(canOperate() && (operatingTicks+1) < currentTicksRequired && secondaryEnergyStored >= SECONDARY_ENERGY_PER_TICK)
if(canOperate() && (operatingTicks+1) < MekanismUtils.getTicks(speedMultiplier) && secondaryEnergyStored >= SECONDARY_ENERGY_PER_TICK)
{
++operatingTicks;
secondaryEnergyStored -= SECONDARY_ENERGY_PER_TICK;
electricityStored -= ENERGY_PER_TICK;
}
else if((operatingTicks+1) >= currentTicksRequired)
else if((operatingTicks+1) >= MekanismUtils.getTicks(speedMultiplier))
{
if(!worldObj.isRemote)
{
@ -269,8 +282,8 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
operatingTicks = dataStream.readInt();
electricityStored = dataStream.readDouble();
secondaryEnergyStored = dataStream.readInt();
currentMaxElectricity = dataStream.readDouble();
currentTicksRequired = dataStream.readInt();
energyMultiplier = dataStream.readInt();
speedMultiplier = dataStream.readInt();
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
} catch (Exception e)
@ -283,13 +296,13 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
@Override
public void sendPacket()
{
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, isActive, operatingTicks, electricityStored, secondaryEnergyStored, currentMaxElectricity, currentTicksRequired);
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, isActive, operatingTicks, electricityStored, secondaryEnergyStored, energyMultiplier, speedMultiplier);
}
@Override
public void sendPacketWithRange()
{
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, isActive, operatingTicks, electricityStored, secondaryEnergyStored, currentMaxElectricity, currentTicksRequired);
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, isActive, operatingTicks, electricityStored, secondaryEnergyStored, energyMultiplier, speedMultiplier);
}
@Override
@ -351,9 +364,9 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
case 5:
return new Object[] {canOperate()};
case 6:
return new Object[] {currentMaxElectricity};
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
case 7:
return new Object[] {(currentMaxElectricity-electricityStored)};
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
default:
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
return new Object[] {"Unknown command."};

View file

@ -9,8 +9,10 @@ import java.util.EnumSet;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IElectricMachine;
import mekanism.api.IUpgradeManagement;
import mekanism.api.SideData;
import mekanism.client.Sound;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
@ -27,7 +29,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IEnergySink, IJouleStorage, IVoltage, IPeripheral, IActiveState, IConfigurable
public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IEnergySink, IJouleStorage, IVoltage, IPeripheral, IActiveState, IConfigurable, IUpgradeManagement
{
/** The Sound instance for this machine. */
@SideOnly(Side.CLIENT)
@ -49,11 +51,13 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
/** Ticks required to operate -- or smelt an item. */
public int TICKS_REQUIRED;
/** The current tick requirement for this machine. */
public int currentTicksRequired;
public int energyMultiplier = 0;
/** The current energy capacity for this machine. */
public double currentMaxElectricity;
public int speedMultiplier = 0;
public int UPGRADE_TICKS_REQUIRED = 40;
public int upgradeTicks;
/** Whether or not this block is in it's active state. */
public boolean isActive;
@ -80,9 +84,8 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
{
super(name, maxEnergy);
ElectricityConnections.registerConnector(this, EnumSet.allOf(ForgeDirection.class));
currentMaxElectricity = MAX_ELECTRICITY;
ENERGY_PER_TICK = perTick;
TICKS_REQUIRED = currentTicksRequired = ticksRequired;
TICKS_REQUIRED = ticksRequired;
soundURL = soundPath;
guiTexturePath = path;
isActive = false;
@ -95,7 +98,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
if(powerProvider != null)
{
int received = (int)(powerProvider.useEnergy(0, (float)((currentMaxElectricity-electricityStored)*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
int received = (int)(powerProvider.useEnergy(0, (float)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
setJoules(electricityStored + received);
}
@ -114,13 +117,13 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
{
if(tileEntity instanceof IConductor)
{
if(electricityStored < currentMaxElectricity)
if(electricityStored < MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
double electricityNeeded = currentMaxElectricity - electricityStored;
double electricityNeeded = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY) - electricityStored;
((IConductor)tileEntity).getNetwork().startRequesting(this, electricityNeeded, electricityNeeded >= getVoltage() ? getVoltage() : electricityNeeded);
setJoules(electricityStored + ((IConductor)tileEntity).getNetwork().consumeElectricity(this).getWatts());
}
else if(electricityStored >= currentMaxElectricity)
else if(electricityStored >= MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
((IConductor)tileEntity).getNetwork().stopRequesting(this);
}
@ -132,16 +135,21 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
if(worldObj.isRemote)
{
try {
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
handleSound();
}
}
} catch(NoSuchMethodError e) {}
}
}
@SideOnly(Side.CLIENT)
public void handleSound()
{
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
@ -161,7 +169,8 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
}
else if(audio.isPlaying && isActive == false)
{
audio.stop();
audio.stopLoop();
}
}
}
}
@ -174,8 +183,9 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
operatingTicks = nbtTags.getInteger("operatingTicks");
isActive = nbtTags.getBoolean("isActive");
currentTicksRequired = nbtTags.getInteger("currentTicksRequired");
currentMaxElectricity = nbtTags.getDouble("currentMaxElectricity");
speedMultiplier = nbtTags.getInteger("speedMultiplier");
energyMultiplier = nbtTags.getInteger("energyMultiplier");
upgradeTicks = nbtTags.getInteger("upgradeTicks");
if(nbtTags.hasKey("sideDataStored"))
{
@ -193,8 +203,9 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
nbtTags.setInteger("operatingTicks", operatingTicks);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("currentTicksRequired", currentTicksRequired);
nbtTags.setDouble("currentMaxElectricity", currentMaxElectricity);
nbtTags.setInteger("speedMultiplier", speedMultiplier);
nbtTags.setInteger("energyMultiplier", energyMultiplier);
nbtTags.setInteger("upgradeTicks", upgradeTicks);
nbtTags.setBoolean("sideDataStored", true);
@ -229,7 +240,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
@Override
public int demandsEnergy()
{
return (int)((currentMaxElectricity - electricityStored)*Mekanism.TO_IC2);
return (int)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY) - electricityStored)*Mekanism.TO_IC2);
}
@Override
@ -237,7 +248,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
{
double givenEnergy = i*Mekanism.FROM_IC2;
double rejects = 0;
double neededEnergy = currentMaxElectricity-electricityStored;
double neededEnergy = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
if(givenEnergy <= neededEnergy)
{
@ -277,7 +288,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
*/
public int getScaledEnergyLevel(int i)
{
return (int)(electricityStored*i / currentMaxElectricity);
return (int)(electricityStored*i / MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY));
}
/**
@ -287,13 +298,18 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
*/
public int getScaledProgress(int i)
{
return operatingTicks*i / currentTicksRequired;
return operatingTicks*i / MekanismUtils.getTicks(speedMultiplier);
}
public int getScaledUpgradeProgress(int i)
{
return upgradeTicks*i / UPGRADE_TICKS_REQUIRED;
}
@Override
public double getMaxJoules(Object... data)
{
return currentMaxElectricity;
return MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY);
}
@Override
@ -360,7 +376,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
@Override
public int powerRequest()
{
return (int)(currentMaxElectricity-electricityStored);
return (int)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)*Mekanism.TO_BC);
}
@Override
@ -380,4 +396,28 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
{
return facing;
}
@Override
public int getEnergyMultiplier(Object... data)
{
return energyMultiplier;
}
@Override
public void setEnergyMultiplier(int multiplier, Object... data)
{
energyMultiplier = multiplier;
}
@Override
public int getSpeedMultiplier(Object... data)
{
return speedMultiplier;
}
@Override
public void setSpeedMultiplier(int multiplier, Object... data)
{
speedMultiplier = multiplier;
}
}

View file

@ -117,7 +117,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Override
public int powerRequest()
{
return (int)(MAX_ELECTRICITY-electricityStored);
return (int)((MAX_ELECTRICITY-electricityStored)*Mekanism.TO_BC);
}
@Override

View file

@ -1,9 +1,7 @@
package mekanism.common;
import ic2.api.ElectricItem;
import ic2.api.IElectricItem;
import mekanism.api.IMachineUpgrade;
import mekanism.api.SideData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -52,7 +50,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
if(inventory[1] != null)
{
if(electricityStored < currentMaxElectricity)
if(electricityStored < MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
if(inventory[1].getItem() instanceof IItemElectric)
{
@ -60,18 +58,8 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
if (electricItem.canProduceElectricity())
{
double joulesNeeded = currentMaxElectricity-electricityStored;
double joulesReceived = 0;
if(electricItem.getVoltage(inventory[1]) <= joulesNeeded)
{
joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[1]), inventory[1]);
}
else if(electricItem.getVoltage(inventory[1]) > joulesNeeded)
{
joulesReceived = electricItem.onUse(joulesNeeded, inventory[1]);
}
double joulesNeeded = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
double joulesReceived = electricItem.onUse(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, joulesNeeded), inventory[1]);
setJoules(electricityStored + joulesReceived);
}
}
@ -85,7 +73,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
}
}
}
if(inventory[1].itemID == Item.redstone.itemID && electricityStored+1000 <= currentMaxElectricity)
if(inventory[1].itemID == Item.redstone.itemID && electricityStored+1000 <= MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
setJoules(electricityStored + 1000);
--inventory[1].stackSize;
@ -97,38 +85,62 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
}
}
if(inventory[3] != null && inventory[3].getItem() instanceof IMachineUpgrade)
if(inventory[3] != null)
{
int energyToAdd = 0;
int ticksToRemove = 0;
if(currentMaxElectricity == MAX_ELECTRICITY)
if(inventory[3].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
{
energyToAdd = ((IMachineUpgrade)inventory[3].getItem()).getEnergyBoost(inventory[3]);
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
if(currentTicksRequired == TICKS_REQUIRED)
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
ticksToRemove = ((IMachineUpgrade)inventory[3].getItem()).getTickReduction(inventory[3]);
}
upgradeTicks = 0;
energyMultiplier+=1;
currentMaxElectricity += energyToAdd;
currentTicksRequired -= ticksToRemove;
}
else if(inventory[3] == null)
inventory[3].stackSize--;
if(inventory[3].stackSize == 0)
{
currentTicksRequired = TICKS_REQUIRED;
currentMaxElectricity = MAX_ELECTRICITY;
inventory[3] = null;
}
}
}
else if(inventory[3].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
upgradeTicks = 0;
speedMultiplier+=1;
inventory[3].stackSize--;
if(inventory[3].stackSize == 0)
{
inventory[3] = null;
}
}
}
else {
upgradeTicks = 0;
}
}
else {
upgradeTicks = 0;
}
if(electricityStored >= ENERGY_PER_TICK)
{
if(canOperate() && (operatingTicks+1) < currentTicksRequired)
if(canOperate() && (operatingTicks+1) < MekanismUtils.getTicks(speedMultiplier))
{
operatingTicks++;
electricityStored -= ENERGY_PER_TICK;
}
else if(canOperate() && (operatingTicks+1) >= currentTicksRequired)
else if(canOperate() && (operatingTicks+1) >= MekanismUtils.getTicks(speedMultiplier))
{
if(!worldObj.isRemote)
{
@ -214,8 +226,9 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
isActive = dataStream.readBoolean();
operatingTicks = dataStream.readInt();
electricityStored = dataStream.readDouble();
currentMaxElectricity = dataStream.readDouble();
currentTicksRequired = dataStream.readInt();
energyMultiplier = dataStream.readInt();
speedMultiplier = dataStream.readInt();
upgradeTicks = dataStream.readInt();
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
} catch (Exception e)
@ -228,13 +241,13 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
@Override
public void sendPacket()
{
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, isActive, operatingTicks, electricityStored, currentMaxElectricity, currentTicksRequired);
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, isActive, operatingTicks, electricityStored, energyMultiplier, speedMultiplier, upgradeTicks);
}
@Override
public void sendPacketWithRange()
{
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, isActive, operatingTicks, electricityStored, currentMaxElectricity, currentTicksRequired);
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, isActive, operatingTicks, electricityStored, energyMultiplier, speedMultiplier, upgradeTicks);
}
@Override
@ -259,9 +272,9 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
case 4:
return new Object[] {canOperate()};
case 5:
return new Object[] {currentMaxElectricity};
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
case 6:
return new Object[] {(currentMaxElectricity-electricityStored)};
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
default:
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
return new Object[] {"Unknown command."};

View file

@ -9,6 +9,7 @@ import ic2.api.energy.event.EnergyTileSourceEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import java.util.ArrayList;
import java.util.EnumSet;
import mekanism.api.IEnergyCube;
@ -103,10 +104,14 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
if(inventory[0].getItem() instanceof IItemElectric)
{
IItemElectric electricItem = (IItemElectric)inventory[0].getItem();
if(electricItem.canReceiveElectricity())
{
double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[0])*0.005, electricityStored), getVoltage()), electricityStored);
double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[0]);
setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects));
}
}
else if(inventory[0].getItem() instanceof IElectricItem)
{
double sent = ElectricItem.charge(inventory[0], (int)(electricityStored*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2;
@ -123,17 +128,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
if (electricItem.canProduceElectricity())
{
double joulesNeeded = tier.MAX_ELECTRICITY-electricityStored;
double joulesReceived = 0;
if(electricItem.getVoltage(inventory[1]) <= joulesNeeded)
{
joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[1]), inventory[1]);
}
else if(electricItem.getVoltage(inventory[1]) > joulesNeeded)
{
joulesReceived = electricItem.onUse(joulesNeeded, inventory[1]);
}
double joulesReceived = electricItem.onUse(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, joulesNeeded), inventory[1]);
setJoules(electricityStored + joulesReceived);
}
}
@ -188,13 +183,27 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
if(!worldObj.isRemote)
{
ForgeDirection outputDirection = ForgeDirection.getOrientation(facing);
ArrayList<ElectricityNetwork> inputNetworks = new ArrayList<ElectricityNetwork>();
for(ForgeDirection direction : ForgeDirection.values())
{
if(direction != outputDirection && direction != ForgeDirection.UNKNOWN)
{
ElectricityNetwork network = ElectricityNetwork.getNetworkFromTileEntity(Vector3.getTileEntityFromSide(worldObj, new Vector3(this), direction), direction);
if(network != null)
{
inputNetworks.add(network);
}
}
}
TileEntity outputTile = Vector3.getTileEntityFromSide(worldObj, new Vector3(this), outputDirection);
ElectricityNetwork outputNetwork = ElectricityNetwork.getNetworkFromTileEntity(outputTile, outputDirection);
if(outputNetwork != null)
if(outputNetwork != null && !inputNetworks.contains(outputNetwork))
{
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), getJoules());
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(getJoules(), 10000));
if(getJoules() > 0 && outputWatts > 0 && getJoules()-outputWatts >= 0)
{

View file

@ -12,7 +12,8 @@ import java.util.Map;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IMachineUpgrade;
import mekanism.api.IUpgradeManagement;
import mekanism.api.InfuseObject;
import mekanism.api.InfusionInput;
import mekanism.api.InfusionOutput;
import mekanism.api.InfusionType;
@ -44,7 +45,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IEnergySink, IJouleStorage, IVoltage, IPeripheral, IActiveState, IConfigurable
public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IEnergySink, IJouleStorage, IVoltage, IPeripheral, IActiveState, IConfigurable, IUpgradeManagement
{
/** The Sound instance for this machine. */
@SideOnly(Side.CLIENT)
@ -66,11 +67,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
/** How many ticks it takes to run an operation. */
public int TICKS_REQUIRED = 200;
/** The current cap of electricity this machine can hold. */
public double currentMaxElectricity;
public int energyMultiplier;
/** The current amount of ticks it takes this machine to run an operation. */
public int currentTicksRequired;
public int speedMultiplier;
public int UPGRADE_TICKS_REQUIRED = 40;
public int upgradeTicks;
/** The amount of infuse this machine has stored. */
public int infuseStored;
@ -99,9 +102,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
inventory = new ItemStack[5];
currentTicksRequired = TICKS_REQUIRED;
currentMaxElectricity = MAX_ELECTRICITY;
ElectricityConnections.registerConnector(this, EnumSet.allOf(ForgeDirection.class));
}
@ -113,16 +113,19 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
if(worldObj.isRemote)
{
try {
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
handleSound();
}
}
} catch(NoSuchMethodError e) {}
}
if(powerProvider != null)
{
int received = (int)(powerProvider.useEnergy(0, (float)((currentMaxElectricity-electricityStored)*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
int received = (int)(powerProvider.useEnergy(0, (float)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
setJoules(electricityStored + received);
}
@ -137,13 +140,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
{
if(tileEntity instanceof IConductor)
{
if(electricityStored < currentMaxElectricity)
if(electricityStored < MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
double electricityNeeded = currentMaxElectricity - electricityStored;
double electricityNeeded = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY) - electricityStored;
((IConductor)tileEntity).getNetwork().startRequesting(this, electricityNeeded, electricityNeeded >= getVoltage() ? getVoltage() : electricityNeeded);
setJoules(electricityStored + ((IConductor)tileEntity).getNetwork().consumeElectricity(this).getWatts());
}
else if(electricityStored >= currentMaxElectricity)
else if(electricityStored >= MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
((IConductor)tileEntity).getNetwork().stopRequesting(this);
}
@ -154,7 +157,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
if(inventory[4] != null)
{
if(electricityStored < currentMaxElectricity)
if(electricityStored < MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
if(inventory[4].getItem() instanceof IItemElectric)
{
@ -162,18 +165,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
if (electricItem.canProduceElectricity())
{
double joulesNeeded = currentMaxElectricity-electricityStored;
double joulesReceived = 0;
if(electricItem.getVoltage(inventory[4]) <= joulesNeeded)
{
joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[4]), inventory[4]);
}
else if(electricItem.getVoltage(inventory[4]) > joulesNeeded)
{
joulesReceived = electricItem.onUse(joulesNeeded, inventory[4]);
}
double joulesNeeded = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
double joulesReceived = electricItem.onUse(Math.min(electricItem.getMaxJoules(inventory[4])*0.005, joulesNeeded), inventory[4]);
setJoules(electricityStored + joulesReceived);
}
}
@ -187,7 +180,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
}
}
}
if(inventory[4].itemID == Item.redstone.itemID && electricityStored+1000 <= currentMaxElectricity)
if(inventory[4].itemID == Item.redstone.itemID && electricityStored+1000 <= MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
setJoules(electricityStored + 1000);
--inventory[4].stackSize;
@ -199,53 +192,67 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
}
}
if(inventory[0] != null && inventory[0].getItem() instanceof IMachineUpgrade)
if(inventory[0] != null)
{
int energyToAdd = 0;
int ticksToRemove = 0;
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
upgradeTicks = 0;
energyMultiplier+=1;
if(currentMaxElectricity == MAX_ELECTRICITY)
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
energyToAdd = ((IMachineUpgrade)inventory[0].getItem()).getEnergyBoost(inventory[0]);
inventory[0] = null;
}
}
}
else if(inventory[0].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
upgradeTicks = 0;
speedMultiplier+=1;
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
}
}
else {
upgradeTicks = 0;
}
}
else {
upgradeTicks = 0;
}
if(currentTicksRequired == TICKS_REQUIRED)
if(inventory[1] != null)
{
ticksToRemove = ((IMachineUpgrade)inventory[0].getItem()).getTickReduction(inventory[0]);
}
if(MekanismUtils.getInfuseObject(inventory[1]) != null)
{
InfuseObject infuse = MekanismUtils.getInfuseObject(inventory[1]);
currentMaxElectricity += energyToAdd;
currentTicksRequired -= ticksToRemove;
}
else if(inventory[0] == null)
if(type == InfusionType.NONE || type == infuse.type)
{
currentTicksRequired = TICKS_REQUIRED;
currentMaxElectricity = MAX_ELECTRICITY;
}
if(inventory[1] != null && infuseStored+100 <= MAX_INFUSE)
if(infuseStored+infuse.stored <= MAX_INFUSE)
{
if(inventory[1].isItemEqual(new ItemStack(Mekanism.CompressedCarbon)))
{
if(type == InfusionType.NONE || type == InfusionType.COAL)
{
infuseStored += 100;
infuseStored+=infuse.stored;
type = infuse.type;
inventory[1].stackSize--;
type = InfusionType.COAL;
if (inventory[1].stackSize <= 0)
{
inventory[1] = null;
}
}
}
else if(MekanismUtils.oreDictCheck(inventory[1], "dustTin"))
{
if(type == InfusionType.NONE || type == InfusionType.TIN)
{
infuseStored += 100;
inventory[1].stackSize--;
type = InfusionType.TIN;
if (inventory[1].stackSize <= 0)
{
@ -254,13 +261,14 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
}
}
}
}
if(canOperate() && (operatingTicks+1) < currentTicksRequired)
if(canOperate() && (operatingTicks+1) < MekanismUtils.getTicks(speedMultiplier))
{
++operatingTicks;
electricityStored -= ENERGY_PER_TICK;
}
else if(canOperate() && (operatingTicks+1) >= currentTicksRequired)
else if(canOperate() && (operatingTicks+1) >= MekanismUtils.getTicks(speedMultiplier))
{
if(!worldObj.isRemote)
{
@ -299,6 +307,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
@SideOnly(Side.CLIENT)
public void handleSound()
{
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
@ -318,7 +328,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
}
else if(audio.isPlaying && isActive == false)
{
audio.stop();
audio.stopLoop();
}
}
}
}
@ -395,12 +406,17 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
public int getScaledEnergyLevel(int i)
{
return (int)(electricityStored*i / currentMaxElectricity);
return (int)(electricityStored*i / MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY));
}
public int getScaledProgress(int i)
{
return operatingTicks*i / currentTicksRequired;
return operatingTicks*i / MekanismUtils.getTicks(speedMultiplier);
}
public int getScaledUpgradeProgress(int i)
{
return upgradeTicks*i / UPGRADE_TICKS_REQUIRED;
}
@Override
@ -419,8 +435,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
{
super.readFromNBT(nbtTags);
currentTicksRequired = nbtTags.getInteger("currentTicksRequired");
currentMaxElectricity = nbtTags.getDouble("currentMaxElectricity");
speedMultiplier = nbtTags.getInteger("speedMultiplier");
energyMultiplier = nbtTags.getInteger("energyMultiplier");
isActive = nbtTags.getBoolean("isActive");
operatingTicks = nbtTags.getInteger("operatingTicks");
infuseStored = nbtTags.getInteger("infuseStored");
@ -452,8 +468,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("currentTicksRequired", currentTicksRequired);
nbtTags.setDouble("currentMaxElectricity", currentMaxElectricity);
nbtTags.setInteger("speedMultiplier", speedMultiplier);
nbtTags.setInteger("energyMultiplier", energyMultiplier);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("operatingTicks", operatingTicks);
nbtTags.setInteger("infuseStored", infuseStored);
@ -485,8 +501,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
try {
facing = dataStream.readInt();
electricityStored = dataStream.readDouble();
currentTicksRequired = dataStream.readInt();
currentMaxElectricity = dataStream.readDouble();
speedMultiplier = dataStream.readInt();
energyMultiplier = dataStream.readInt();
isActive = dataStream.readBoolean();
operatingTicks = dataStream.readInt();
infuseStored = dataStream.readInt();
@ -503,13 +519,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
@Override
public void sendPacket()
{
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, electricityStored, currentTicksRequired, currentMaxElectricity, isActive, operatingTicks, infuseStored, type.name);
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, electricityStored, speedMultiplier, energyMultiplier, isActive, operatingTicks, infuseStored, type.name);
}
@Override
public void sendPacketWithRange()
{
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, electricityStored, currentTicksRequired, currentMaxElectricity, isActive, operatingTicks, infuseStored, type.name);
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, electricityStored, speedMultiplier, energyMultiplier, isActive, operatingTicks, infuseStored, type.name);
}
@Override
@ -538,9 +554,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
case 3:
return new Object[] {canOperate()};
case 4:
return new Object[] {currentMaxElectricity};
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
case 5:
return new Object[] {(currentMaxElectricity-electricityStored)};
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
case 6:
return new Object[] {infuseStored};
case 7:
@ -584,13 +600,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
@Override
public double getMaxJoules(Object... data)
{
return currentMaxElectricity;
return MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY);
}
@Override
public int demandsEnergy()
{
return (int)((currentMaxElectricity - electricityStored)*Mekanism.TO_IC2);
return (int)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY) - electricityStored)*Mekanism.TO_IC2);
}
@Override
@ -629,7 +645,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
{
double givenEnergy = i*Mekanism.FROM_IC2;
double rejects = 0;
double neededEnergy = currentMaxElectricity-electricityStored;
double neededEnergy = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
if(givenEnergy < neededEnergy)
{
@ -647,7 +663,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
@Override
public int powerRequest()
{
return (int)(currentMaxElectricity-electricityStored);
return (int)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)*Mekanism.TO_BC);
}
@Override
@ -667,4 +683,28 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
{
return facing;
}
@Override
public int getEnergyMultiplier(Object... data)
{
return energyMultiplier;
}
@Override
public void setEnergyMultiplier(int multiplier, Object... data)
{
energyMultiplier = multiplier;
}
@Override
public int getSpeedMultiplier(Object... data)
{
return speedMultiplier;
}
@Override
public void setSpeedMultiplier(int multiplier, Object... data)
{
speedMultiplier = multiplier;
}
}

View file

@ -20,7 +20,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
public TileEntityPurificationChamber()
{
super("PurificationChamber.ogg", "Purification Chamber", "/resources/mekanism/gui/GuiPurificationChamber.png", 16, 1, 200, 12000, 1200);
super("PurificationChamber.ogg", "Purification Chamber", "/resources/mekanism/gui/GuiPurificationChamber.png", 30, 1, 200, 12000, 1200);
}
@Override
@ -99,7 +99,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
if(item.canProvideGas(inventory[1], EnumGas.OXYGEN))
{
int received = 0;
int gasNeeded = (MAX_SECONDARY_ENERGY - secondaryEnergyStored)/2;
int gasNeeded = MAX_SECONDARY_ENERGY - secondaryEnergyStored;
if(item.getRate() <= gasNeeded)
{
received = item.removeGas(inventory[1], EnumGas.OXYGEN, item.getRate());
@ -109,7 +109,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
received = item.removeGas(inventory[1], EnumGas.OXYGEN, gasNeeded);
}
setGas(EnumGas.OXYGEN, secondaryEnergyStored + received*2);
setGas(EnumGas.OXYGEN, secondaryEnergyStored + received);
}
}
}

View file

@ -9,7 +9,7 @@ import ic2.api.IElectricItem;
import ic2.api.energy.tile.IEnergySink;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IMachineUpgrade;
import mekanism.api.IUpgradeManagement;
import mekanism.api.SideData;
import mekanism.api.Tier.SmeltingFactoryTier;
import mekanism.client.Sound;
@ -39,7 +39,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public class TileEntitySmeltingFactory extends TileEntityElectricBlock implements IEnergySink, IJouleStorage, IVoltage, IPeripheral, IActiveState, IConfigurable
public class TileEntitySmeltingFactory extends TileEntityElectricBlock implements IEnergySink, IJouleStorage, IVoltage, IPeripheral, IActiveState, IConfigurable, IUpgradeManagement
{
/** This Smelting Factory's tier. */
public SmeltingFactoryTier tier;
@ -61,11 +61,13 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
/** How much energy each operation consumes per tick. */
public int ENERGY_PER_TICK = 16;
/** How many ticks it takes, currently, to run an operation. */
public int currentTicksRequired;
public int speedMultiplier;
/** The current electricity cap this machine can handle. */
public double currentMaxElectricity;
public int energyMultiplier;
public int UPGRADE_TICKS_REQUIRED = 40;
public int upgradeTicks;
/** This machine's previous active state, used for calculating packets. */
public boolean prevActive;
@ -91,8 +93,6 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
super(type.name + " Smelting Factory", type.processes*3200);
ElectricityConnections.registerConnector(this, EnumSet.allOf(ForgeDirection.class));
tier = type;
currentTicksRequired = TICKS_REQUIRED;
currentMaxElectricity = MAX_ELECTRICITY;
inventory = new ItemStack[2+type.processes*2];
progress = new int[type.processes];
isActive = false;
@ -106,16 +106,19 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
if(worldObj.isRemote)
{
try {
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
handleSound();
}
}
} catch(NoSuchMethodError e) {}
}
if(powerProvider != null)
{
int received = (int)(powerProvider.useEnergy(0, (float)((currentMaxElectricity-electricityStored)*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
int received = (int)(powerProvider.useEnergy(0, (float)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)*Mekanism.TO_BC), true)*Mekanism.FROM_BC);
setJoules(electricityStored + received);
}
@ -130,13 +133,13 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
if(tileEntity instanceof IConductor)
{
if(electricityStored < currentMaxElectricity)
if(electricityStored < MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
double electricityNeeded = currentMaxElectricity - electricityStored;
double electricityNeeded = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY) - electricityStored;
((IConductor)tileEntity).getNetwork().startRequesting(this, electricityNeeded, electricityNeeded >= getVoltage() ? getVoltage() : electricityNeeded);
setJoules(electricityStored + ((IConductor)tileEntity).getNetwork().consumeElectricity(this).getWatts());
}
else if(electricityStored >= currentMaxElectricity)
else if(electricityStored >= MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
((IConductor)tileEntity).getNetwork().stopRequesting(this);
}
@ -155,7 +158,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
if(inventory[1] != null)
{
if(electricityStored < currentMaxElectricity)
if(electricityStored < MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
if(inventory[1].getItem() instanceof IItemElectric)
{
@ -163,18 +166,8 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
if (electricItem.canProduceElectricity())
{
double joulesNeeded = currentMaxElectricity-electricityStored;
double joulesReceived = 0;
if(electricItem.getVoltage(inventory[1]) <= joulesNeeded)
{
joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[1]), inventory[1]);
}
else if(electricItem.getVoltage(inventory[1]) > joulesNeeded)
{
joulesReceived = electricItem.onUse(joulesNeeded, inventory[1]);
}
double joulesNeeded = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
double joulesReceived = electricItem.onUse(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, joulesNeeded), inventory[1]);
setJoules(electricityStored + joulesReceived);
}
}
@ -188,7 +181,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
}
}
}
if(inventory[1].itemID == Item.redstone.itemID && electricityStored+1000 <= currentMaxElectricity)
if(inventory[1].itemID == Item.redstone.itemID && electricityStored+1000 <= MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY))
{
setJoules(electricityStored + 1000);
--inventory[1].stackSize;
@ -200,38 +193,62 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
}
}
if(inventory[0] != null && inventory[0].getItem() instanceof IMachineUpgrade)
if(inventory[0] != null)
{
int energyToAdd = 0;
int ticksToRemove = 0;
if(currentMaxElectricity == MAX_ELECTRICITY)
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
{
energyToAdd = ((IMachineUpgrade)inventory[0].getItem()).getEnergyBoost(inventory[0]);
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
if(currentTicksRequired == TICKS_REQUIRED)
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
ticksToRemove = ((IMachineUpgrade)inventory[0].getItem()).getTickReduction(inventory[0]);
}
upgradeTicks = 0;
energyMultiplier+=1;
currentMaxElectricity += energyToAdd;
currentTicksRequired -= ticksToRemove;
}
else if(inventory[0] == null)
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
currentTicksRequired = TICKS_REQUIRED;
currentMaxElectricity = MAX_ELECTRICITY;
inventory[0] = null;
}
}
}
else if(inventory[0].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{
upgradeTicks++;
}
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
{
upgradeTicks = 0;
speedMultiplier+=1;
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
}
}
else {
upgradeTicks = 0;
}
}
else {
upgradeTicks = 0;
}
for(int mainSlot = 0; mainSlot < tier.processes; mainSlot++)
{
if(canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)) && (progress[mainSlot]+1) < currentTicksRequired)
if(canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)) && (progress[mainSlot]+1) < MekanismUtils.getTicks(speedMultiplier))
{
++progress[mainSlot];
electricityStored -= ENERGY_PER_TICK;
}
else if(canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)) && (progress[mainSlot]+1) >= currentTicksRequired)
else if(canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)) && (progress[mainSlot]+1) >= MekanismUtils.getTicks(speedMultiplier))
{
if(!worldObj.isRemote)
{
@ -241,16 +258,6 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
electricityStored -= ENERGY_PER_TICK;
}
if(electricityStored < 0)
{
electricityStored = 0;
}
if(electricityStored > currentMaxElectricity)
{
electricityStored = currentMaxElectricity;
}
if(!canOperate(getInputSlot(mainSlot), getOutputSlot(mainSlot)))
{
progress[mainSlot] = 0;
@ -295,6 +302,8 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
@SideOnly(Side.CLIENT)
public void handleSound()
{
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
@ -314,7 +323,8 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
}
else if(audio.isPlaying && isActive == false)
{
audio.stop();
audio.stopLoop();
}
}
}
}
@ -333,7 +343,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
public int getScaledProgress(int i, int process)
{
return progress[process]*i / currentTicksRequired;
return progress[process]*i / MekanismUtils.getTicks(speedMultiplier);
}
/**
@ -343,7 +353,12 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
*/
public int getScaledEnergyLevel(int i)
{
return (int)(electricityStored*i / currentMaxElectricity);
return (int)(electricityStored*i / MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY));
}
public int getScaledUpgradeProgress(int i)
{
return upgradeTicks*i / UPGRADE_TICKS_REQUIRED;
}
public boolean canOperate(int inputSlot, int outputSlot)
@ -424,8 +439,8 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
try {
facing = dataStream.readInt();
electricityStored = dataStream.readDouble();
currentTicksRequired = dataStream.readInt();
currentMaxElectricity = dataStream.readDouble();
speedMultiplier = dataStream.readInt();
energyMultiplier = dataStream.readInt();
isActive = dataStream.readBoolean();
for(int i = 0; i < tier.processes; i++)
@ -447,8 +462,8 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
super.readFromNBT(nbtTags);
currentTicksRequired = nbtTags.getInteger("currentTicksRequired");
currentMaxElectricity = nbtTags.getDouble("currentMaxElectricity");
speedMultiplier = nbtTags.getInteger("speedMultiplier");
energyMultiplier = nbtTags.getInteger("energyMultiplier");
isActive = nbtTags.getBoolean("isActive");
for(int i = 0; i < tier.processes; i++)
@ -470,8 +485,8 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("currentTicksRequired", currentTicksRequired);
nbtTags.setDouble("currentMaxElectricity", currentMaxElectricity);
nbtTags.setInteger("speedMultiplier", speedMultiplier);
nbtTags.setInteger("energyMultiplier", energyMultiplier);
nbtTags.setBoolean("isActive", isActive);
for(int i = 0; i < tier.processes; i++)
@ -490,13 +505,13 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
@Override
public void sendPacket()
{
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, electricityStored, currentTicksRequired, currentMaxElectricity, isActive, progress);
PacketHandler.sendTileEntityPacketToClients(this, 0, facing, electricityStored, speedMultiplier, energyMultiplier, isActive, progress);
}
@Override
public void sendPacketWithRange()
{
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, electricityStored, currentTicksRequired, currentMaxElectricity, isActive, progress);
PacketHandler.sendTileEntityPacketToClients(this, 50, facing, electricityStored, speedMultiplier, energyMultiplier, isActive, progress);
}
@Override
@ -571,9 +586,9 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
return new Object[] {canOperate(getInputSlot((Integer)arguments[0]), getOutputSlot((Integer)arguments[0]))};
case 4:
return new Object[] {currentMaxElectricity};
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
case 5:
return new Object[] {(currentMaxElectricity-electricityStored)};
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
default:
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
return new Object[] {"Unknown command."};
@ -613,13 +628,13 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
@Override
public double getMaxJoules(Object... data)
{
return currentMaxElectricity;
return MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY);
}
@Override
public int demandsEnergy()
{
return (int)((currentMaxElectricity - electricityStored)*Mekanism.TO_IC2);
return (int)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY) - electricityStored)*Mekanism.TO_IC2);
}
@Override
@ -652,7 +667,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
double givenEnergy = i*Mekanism.FROM_IC2;
double rejects = 0;
double neededEnergy = currentMaxElectricity-electricityStored;
double neededEnergy = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
if(givenEnergy < neededEnergy)
{
@ -670,7 +685,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
@Override
public int powerRequest()
{
return (int)(currentMaxElectricity-electricityStored);
return (int)((MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)*Mekanism.TO_BC);
}
@Override
@ -690,4 +705,28 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
return facing;
}
@Override
public int getEnergyMultiplier(Object... data)
{
return energyMultiplier;
}
@Override
public void setEnergyMultiplier(int multiplier, Object... data)
{
energyMultiplier = multiplier;
}
@Override
public int getSpeedMultiplier(Object... data)
{
return speedMultiplier;
}
@Override
public void setSpeedMultiplier(int multiplier, Object... data)
{
speedMultiplier = multiplier;
}
}

View file

@ -46,7 +46,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IEn
public TileEntityTeleporter()
{
super("Teleporter", 3000000);
super("Teleporter", 4000000);
inventory = new ItemStack[1];
code = new Teleporter.Code(0, 0, 0, 0);
@ -142,17 +142,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IEn
if (electricItem.canProduceElectricity())
{
double joulesNeeded = MAX_ELECTRICITY-electricityStored;
double joulesReceived = 0;
if(electricItem.getVoltage(inventory[0]) <= joulesNeeded)
{
joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[0]), inventory[0]);
}
else if(electricItem.getVoltage(inventory[0]) > joulesNeeded)
{
joulesReceived = electricItem.onUse(joulesNeeded, inventory[0]);
}
double joulesReceived = electricItem.onUse(Math.min(electricItem.getMaxJoules(inventory[0])*0.005, joulesNeeded), inventory[0]);
setJoules(electricityStored + joulesReceived);
}
}
@ -310,7 +300,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IEn
int distance = (int)entity.getDistanceSq(coords.xCoord, coords.yCoord, coords.zCoord);
energyCost+=(distance*10);
energyCost+=(distance);
return energyCost;
}

View file

@ -39,6 +39,78 @@ public class Version
build = 0;
}
/**
* 1: greater than
* 0: equal to
* -1: less than
* @param version
* @return
*/
public byte comparedState(Version version)
{
if(version.major > major)
{
return -1;
}
else if(version.major == major)
{
if(version.minor > minor)
{
return -1;
}
else if(version.minor == minor)
{
if(version.build > build)
{
return -1;
}
else if(version.build == build)
{
return 0;
}
else {
return 1;
}
}
else {
return 1;
}
}
else {
return 1;
}
}
public static Version get(String s)
{
String[] split = s.replace('.', ':').split(":");
if(split.length != 3)
{
System.out.println(split.length);
return null;
}
for(String i : split)
{
for(Character c : i.toCharArray())
{
if(!Character.isDigit(c))
{
return null;
}
}
}
int[] digits = new int[3];
for(int i = 0; i < 3; i++)
{
digits[i] = Integer.parseInt(split[i]);
}
return new Version(digits[0], digits[1], digits[2]);
}
@Override
public String toString()
{

View file

@ -5,10 +5,12 @@ import java.util.List;
import java.util.Random;
import mekanism.api.IActiveState;
import mekanism.api.IEnergyCube;
import mekanism.common.Mekanism;
import mekanism.common.MekanismUtils;
import mekanism.common.TileEntityBasicBlock;
import mekanism.common.TileEntityElectricBlock;
import mekanism.common.TileEntityEnergyCube;
import mekanism.generators.client.GeneratorsClientProxy;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -20,9 +22,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.implement.IItemElectric;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IToolConfigurator;
import universalelectricity.prefab.multiblock.IMultiBlock;
@ -424,12 +428,13 @@ public class BlockGenerator extends BlockContainer
if(world.getBlockMetadata(x, y, z) == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
{
EntityItem entityItem = new EntityItem(world, x, y, z, new ItemStack(MekanismGenerators.Generator, 1, world.getBlockMetadata(x, y, z)));
float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, new ItemStack(MekanismGenerators.Generator, 1, 5));
float motion = 0.05F;
entityItem.motionX = machineRand.nextGaussian() * motion;
entityItem.motionY = machineRand.nextGaussian() * motion + 0.2F;
entityItem.motionZ = machineRand.nextGaussian() * motion;
world.spawnEntityInWorld(entityItem);
}
@ -570,24 +575,61 @@ public class BlockGenerator extends BlockContainer
}
}
@Override
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
{
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, new ItemStack(MekanismGenerators.Generator, 1, world.getBlockMetadata(x, y, z)));
IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem();
electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem());
world.spawnEntityInWorld(entityItem);
}
return world.setBlockWithNotify(x, y, z, 0);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
ItemStack itemStack = new ItemStack(MekanismGenerators.Generator, 1, world.getBlockMetadata(x, y, z));
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
electricItem.setJoules(tileEntity.electricityStored, itemStack);
return itemStack;
}
public static enum GeneratorType
{
HEAT_GENERATOR(0, 0, TileEntityHeatGenerator.class, true),
SOLAR_GENERATOR(1, 1, TileEntitySolarGenerator.class, false),
ELECTROLYTIC_SEPARATOR(2, 2, TileEntityElectrolyticSeparator.class, true),
HYDROGEN_GENERATOR(3, 3, TileEntityHydrogenGenerator.class, true),
BIO_GENERATOR(4, 4, TileEntityBioGenerator.class, true),
ADVANCED_SOLAR_GENERATOR(5, 1, TileEntityAdvancedSolarGenerator.class, true);
HEAT_GENERATOR(0, 0, 160000, TileEntityHeatGenerator.class, true),
SOLAR_GENERATOR(1, 1, 96000, TileEntitySolarGenerator.class, false),
ELECTROLYTIC_SEPARATOR(2, 2, 9600, TileEntityElectrolyticSeparator.class, true),
HYDROGEN_GENERATOR(3, 3, 400000, TileEntityHydrogenGenerator.class, true),
BIO_GENERATOR(4, 4, 160000, TileEntityBioGenerator.class, true),
ADVANCED_SOLAR_GENERATOR(5, 1, 200000, TileEntityAdvancedSolarGenerator.class, true);
public int meta;
public int guiId;
public double maxEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean hasModel;
private GeneratorType(int i, int j, Class<? extends TileEntity> tileClass, boolean model)
private GeneratorType(int i, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
{
meta = i;
guiId = j;
maxEnergy = k;
tileEntityClass = tileClass;
hasModel = model;
}

View file

@ -79,7 +79,8 @@ public class ContainerHeatGenerator extends Container
}
}
}
else if(tileEntity.getFuel(slotStack) > 0 || (Mekanism.hooks.BuildCraftLoaded && slotStack.itemID == Mekanism.hooks.BuildCraftFuelBucket.itemID))
else if(tileEntity.getFuel(slotStack) > 0 || (Mekanism.hooks.ForestryLoaded && slotStack.itemID == Mekanism.hooks.ForestryBiofuelBucket.itemID) ||
(Mekanism.hooks.BuildCraftLoaded && (slotStack.itemID == Mekanism.hooks.BuildCraftFuelBucket.itemID || slotStack.itemID == Mekanism.hooks.BuildCraftOilBucket.itemID)))
{
if(slotID != 0 && slotID != 1)
{

View file

@ -1,10 +1,21 @@
package mekanism.generators.common;
import java.util.List;
import ic2.api.ICustomElectricItem;
import universalelectricity.core.electricity.ElectricInfo;
import universalelectricity.core.electricity.ElectricInfo.ElectricUnit;
import universalelectricity.core.implement.IItemElectric;
import mekanism.common.Mekanism;
import mekanism.common.TileEntityElectricBlock;
import mekanism.generators.common.BlockGenerator.GeneratorType;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.world.World;
/**
@ -19,7 +30,7 @@ import net.minecraft.world.World;
* @author AidanBrady
*
*/
public class ItemBlockGenerator extends ItemBlock
public class ItemBlockGenerator extends ItemBlock implements IItemElectric, ICustomElectricItem
{
public Block metaBlock;
@ -28,6 +39,7 @@ public class ItemBlockGenerator extends ItemBlock
super(id);
metaBlock = block;
setHasSubtypes(true);
setMaxStackSize(1);
}
@Override
@ -42,41 +54,6 @@ public class ItemBlockGenerator extends ItemBlock
return metaBlock.getBlockTextureFromSideAndMetadata(2, i);
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if(stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
{
boolean canPlace = true;
if(world.getBlockId(x, y, z) != Block.tallGrass.blockID && world.getBlockId(x, y, z) != 0)
canPlace = false;
if(world.getBlockId(x, y, z) != 0)
{
if(Block.blocksList[world.getBlockId(x, y, z)].isBlockReplaceable(world, x, y, z))
canPlace = true;
}
for(int xPos=-1;xPos<=1;xPos++)
{
for(int zPos=-1;zPos<=1;zPos++)
{
if(world.getBlockId(x+xPos, y+2, z+zPos) != 0)
canPlace = false;
}
}
if(canPlace)
{
return super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
}
return false;
}
return super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
@ -110,4 +87,224 @@ public class ItemBlockGenerator extends ItemBlock
}
return getItemName() + "." + name;
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
double energy = getJoules(itemstack);
list.add("Stored Energy: " + ElectricInfo.getDisplayShort(energy, ElectricUnit.JOULES));
}
@Override
public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
{
ItemBlockGenerator item = ((ItemBlockGenerator)itemstack.getItem());
item.setJoules(item.getJoules(itemstack), itemstack);
}
@Override
public double getJoules(Object... data)
{
if (data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack) data[0];
if (itemStack.stackTagCompound == null)
{
return 0;
}
double electricityStored = 0;
if (itemStack.stackTagCompound.getTag("electricity") instanceof NBTTagFloat)
{
electricityStored = itemStack.stackTagCompound.getFloat("electricity");
}
else
{
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
}
return electricityStored;
}
return -1;
}
@Override
public void setJoules(double wattHours, Object... data)
{
if (data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
double electricityStored = Math.max(Math.min(wattHours, getMaxJoules(itemStack)), 0);
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
}
}
@Override
public double getMaxJoules(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemstack = (ItemStack)data[0];
return GeneratorType.getFromMetadata(itemstack.getItemDamage()).maxEnergy;
}
return 3200;
}
@Override
public double getVoltage(Object... data)
{
return 120;
}
@Override
public double onReceive(double amps, double voltage, ItemStack itemStack)
{
double rejectedElectricity = Math.max((getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)) - getMaxJoules(itemStack), 0);
setJoules(getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1) - rejectedElectricity, itemStack);
return rejectedElectricity;
}
@Override
public double onUse(double joulesNeeded, ItemStack itemStack)
{
double electricityToUse = Math.min(getJoules(itemStack), joulesNeeded);
setJoules(getJoules(itemStack) - electricityToUse, itemStack);
return electricityToUse;
}
@Override
public boolean canReceiveElectricity()
{
//TODO
return false;
}
@Override
public boolean canProduceElectricity()
{
return true;
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
boolean place = true;
if(stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
{
if(world.getBlockId(x, y, z) != Block.tallGrass.blockID && world.getBlockId(x, y, z) != 0)
place = false;
if(world.getBlockId(x, y, z) != 0)
{
if(Block.blocksList[world.getBlockId(x, y, z)].isBlockReplaceable(world, x, y, z))
place = true;
}
for(int xPos=-1;xPos<=1;xPos++)
{
for(int zPos=-1;zPos<=1;zPos++)
{
if(world.getBlockId(x+xPos, y+2, z+zPos) != 0)
place = false;
}
}
}
if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);
tileEntity.electricityStored = getJoules(stack);
return true;
}
return false;
}
@Override
public int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
{
double givenEnergy = amount*Mekanism.FROM_IC2;
double energyNeeded = getMaxJoules(itemStack)-getJoules(itemStack);
double energyToStore = Math.min(Math.min(amount, getMaxJoules(itemStack)*0.01), energyNeeded);
if(!simulate)
{
setJoules(getJoules(itemStack) + energyToStore, itemStack);
}
return (int)(energyToStore*Mekanism.TO_IC2);
}
@Override
public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
{
double energyWanted = amount*Mekanism.FROM_IC2;
double energyToGive = Math.min(Math.min(energyWanted, getMaxJoules(itemStack)*0.01), getJoules(itemStack));
if(!simulate)
{
setJoules(getJoules(itemStack) - energyToGive, itemStack);
}
return (int)(energyToGive*Mekanism.TO_IC2);
}
@Override
public boolean canUse(ItemStack itemStack, int amount)
{
return getJoules(itemStack) >= amount*Mekanism.FROM_IC2;
}
@Override
public boolean canShowChargeToolTip(ItemStack itemStack)
{
return false;
}
@Override
public boolean canProvideEnergy()
{
return canProduceElectricity();
}
@Override
public int getChargedItemId()
{
return itemID;
}
@Override
public int getEmptyItemId()
{
return itemID;
}
@Override
public int getMaxCharge()
{
return 0;
}
@Override
public int getTier()
{
return 3;
}
@Override
public int getTransferLimit()
{
return (int)(getVoltage()*Mekanism.TO_IC2);
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.BlockLeaves;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
@ -19,7 +20,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.2.3", dependencies = "required-after:Mekanism")
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.3.0", dependencies = "required-after:Mekanism")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class MekanismGenerators
{
@ -150,5 +151,7 @@ public class MekanismGenerators
BioFuel = new ItemMekanism(Mekanism.configuration.getItem("BioFuel", 11301).getInt()).setItemName("BioFuel");
ElectrolyticCore = new ItemMekanism(Mekanism.configuration.getItem("ElectrolyticCore", 11302).getInt()).setItemName("ElectrolyticCore");
Mekanism.configuration.save();
OreDictionary.registerOre("bioFuel", new ItemStack(BioFuel));
}
}

View file

@ -1,5 +1,8 @@
package mekanism.generators.common;
import java.util.HashMap;
import java.util.Map;
import ic2.api.ElectricItem;
import ic2.api.IElectricItem;
import mekanism.client.Sound;
@ -16,6 +19,7 @@ import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import universalelectricity.core.electricity.ElectricInfo;
@ -42,10 +46,17 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank
/** The LiquidSlot biofuel instance for this generator. */
public LiquidSlot bioFuelSlot = new LiquidSlot(24000, Mekanism.hooks.ForestryBiofuelID);
public static Map<Integer, Integer> fuels = new HashMap<Integer, Integer>();
public TileEntityBioGenerator()
{
super("Bio-Generator", 160000, 128);
inventory = new ItemStack[2];
if(Mekanism.hooks.ForestryLoaded)
{
fuels.put(Mekanism.hooks.ForestryBiofuelID, 16);
}
}
public float getMatrix()
@ -82,10 +93,14 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank
if(inventory[1].getItem() instanceof IItemElectric)
{
IItemElectric electricItem = (IItemElectric)inventory[1].getItem();
if(electricItem.canReceiveElectricity())
{
double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, electricityStored), getVoltage()), electricityStored);
double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[1]);
setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects));
}
}
else if(inventory[1].getItem() instanceof IElectricItem)
{
double sent = ElectricItem.charge(inventory[1], (int)(electricityStored*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2;
@ -93,17 +108,35 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank
}
}
if(inventory[0] != null && bioFuelSlot.liquidStored < bioFuelSlot.MAX_LIQUID)
if(inventory[0] != null)
{
if(Mekanism.hooks.ForestryLoaded)
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(inventory[0]);
if(liquid != null)
{
if(inventory[0].itemID == Mekanism.hooks.ForestryBiofuelBucket.itemID)
if(fuels.containsKey(liquid.itemID))
{
int liquidToAdd = liquid.amount*fuels.get(liquid.itemID);
if(bioFuelSlot.liquidStored+liquidToAdd <= bioFuelSlot.MAX_LIQUID)
{
bioFuelSlot.setLiquid(bioFuelSlot.liquidStored+liquidToAdd);
if(LiquidContainerRegistry.isBucket(inventory[0]))
{
bioFuelSlot.setLiquid(bioFuelSlot.liquidStored + 1000);
inventory[0] = new ItemStack(Item.bucketEmpty);
}
}
else {
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
}
}
}
}
else {
int fuel = getFuel(inventory[0]);
ItemStack prevStack = inventory[0].copy();
if(fuel > 0)
@ -113,6 +146,11 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank
{
bioFuelSlot.liquidStored += fuel;
--inventory[0].stackSize;
if(prevStack.isItemEqual(new ItemStack(Item.bucketLava)))
{
inventory[0] = new ItemStack(Item.bucketEmpty);
}
}
if(inventory[0].stackSize == 0)
@ -121,6 +159,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank
}
}
}
}
if(canOperate())
{

View file

@ -28,6 +28,8 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import universalelectricity.core.electricity.ElectricityConnections;
@ -130,17 +132,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
if (electricItem.canProduceElectricity())
{
double joulesNeeded = MAX_ELECTRICITY-electricityStored;
double joulesReceived = 0;
if(electricItem.getVoltage(inventory[3]) <= joulesNeeded)
{
joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[3]), inventory[3]);
}
else if(electricItem.getVoltage(inventory[3]) > joulesNeeded)
{
joulesReceived = electricItem.onUse(joulesNeeded, inventory[3]);
}
double joulesReceived = electricItem.onUse(Math.min(electricItem.getMaxJoules(inventory[3])*0.005, joulesNeeded), inventory[3]);
setJoules(electricityStored + joulesReceived);
}
}
@ -155,12 +147,29 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
}
}
if(inventory[0] != null && waterSlot.liquidStored < waterSlot.MAX_LIQUID)
if(inventory[0] != null)
{
if(inventory[0].itemID == Item.bucketWater.itemID)
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(inventory[0]);
if(liquid != null)
{
inventory[0] = new ItemStack(Item.bucketEmpty, 1);
waterSlot.setLiquid(waterSlot.liquidStored + 1000);
if(waterSlot.liquidStored+liquid.amount <= waterSlot.MAX_LIQUID)
{
waterSlot.setLiquid(waterSlot.liquidStored + liquid.amount);
if(inventory[0].isItemEqual(new ItemStack(Item.bucketWater)))
{
inventory[0] = new ItemStack(Item.bucketEmpty);
}
else {
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
}
}
}
}

View file

@ -76,10 +76,13 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
if(worldObj.isRemote)
{
try {
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
handleSound();
}
}
} catch(NoSuchMethodError e) {}
}
@ -130,7 +133,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
if(outputNetwork != null)
{
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), getJoules());
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(getJoules(), 10000));
if(getJoules() > 0 && outputWatts > 0 && getJoules()-outputWatts >= 0)
{
@ -146,6 +149,8 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
@SideOnly(Side.CLIENT)
public void handleSound()
{
if(Mekanism.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
{
@ -165,7 +170,8 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
}
else if(audio.isPlaying && isActive == false)
{
audio.stop();
audio.stopLoop();
}
}
}
}

View file

@ -1,12 +1,17 @@
package mekanism.generators.common;
import java.util.HashMap;
import java.util.Map;
import ic2.api.ElectricItem;
import ic2.api.IElectricItem;
import mekanism.client.Sound;
import mekanism.common.LiquidSlot;
import mekanism.common.Mekanism;
import mekanism.common.MekanismHooks;
import mekanism.common.MekanismUtils;
import mekanism.common.PacketHandler;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -17,6 +22,7 @@ import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import universalelectricity.core.electricity.ElectricInfo;
@ -38,10 +44,24 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
/** The amount of electricity this machine can produce with a unit of fuel. */
public final int GENERATION = 80;
public static Map<Integer, Integer> fuels = new HashMap<Integer, Integer>();
public TileEntityHeatGenerator()
{
super("Heat Generator", 160000, 128);
inventory = new ItemStack[2];
fuels.put(Block.lavaStill.blockID, 1);
if(Mekanism.hooks.BuildCraftLoaded)
{
fuels.put(Mekanism.hooks.BuildCraftFuelID, 16);
fuels.put(Mekanism.hooks.BuildCraftOilID, 4);
}
if(Mekanism.hooks.ForestryLoaded)
{
fuels.put(Mekanism.hooks.ForestryBiofuelID, 8);
}
}
@Override
@ -54,10 +74,14 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
if(inventory[1].getItem() instanceof IItemElectric)
{
IItemElectric electricItem = (IItemElectric)inventory[1].getItem();
if(electricItem.canReceiveElectricity())
{
double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, electricityStored), getVoltage()), electricityStored);
double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[1]);
setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects));
}
}
else if(inventory[1].getItem() instanceof IElectricItem)
{
double sent = ElectricItem.charge(inventory[1], (int)(electricityStored*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2;
@ -65,17 +89,35 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
}
}
if(inventory[0] != null && fuelSlot.liquidStored < fuelSlot.MAX_LIQUID)
if(inventory[0] != null)
{
if(Mekanism.hooks.BuildCraftLoaded)
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(inventory[0]);
if(liquid != null)
{
if(inventory[0].itemID == Mekanism.hooks.BuildCraftFuelBucket.itemID)
if(fuels.containsKey(liquid.itemID))
{
int liquidToAdd = liquid.amount*fuels.get(liquid.itemID);
if(fuelSlot.liquidStored+liquidToAdd <= fuelSlot.MAX_LIQUID)
{
fuelSlot.setLiquid(fuelSlot.liquidStored+liquidToAdd);
if(LiquidContainerRegistry.isBucket(inventory[0]))
{
fuelSlot.setLiquid(fuelSlot.liquidStored + 1000);
inventory[0] = new ItemStack(Item.bucketEmpty);
}
}
else {
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
}
}
}
}
else {
int fuel = getFuel(inventory[0]);
ItemStack prevStack = inventory[0].copy();
if(fuel > 0)
@ -98,6 +140,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
}
}
}
}
setJoules(electricityStored + getEnvironmentBoost());
@ -163,6 +206,11 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
public int getFuel(ItemStack itemstack)
{
if(itemstack.itemID == Item.bucketLava.itemID)
{
return 1000;
}
return TileEntityFurnace.getItemBurnTime(itemstack);
}
@ -254,13 +302,11 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{
if(from != ForgeDirection.getOrientation(facing))
{
if(resource.itemID == Mekanism.hooks.BuildCraftFuelID)
if(fuels.containsKey(resource.itemID) && from != ForgeDirection.getOrientation(facing))
{
int fuelTransfer = 0;
int fuelNeeded = fuelSlot.MAX_LIQUID - fuelSlot.liquidStored;
int attemptTransfer = resource.amount;
int attemptTransfer = resource.amount*fuels.get(resource.itemID);
if(attemptTransfer <= fuelNeeded)
{
@ -275,8 +321,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
fuelSlot.setLiquid(fuelSlot.liquidStored + fuelTransfer);
}
return fuelTransfer;
}
return fuelTransfer/fuels.get(resource.itemID);
}
return 0;

View file

@ -45,10 +45,14 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
if(inventory[1].getItem() instanceof IItemElectric)
{
IItemElectric electricItem = (IItemElectric)inventory[1].getItem();
if(electricItem.canReceiveElectricity())
{
double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, electricityStored), getVoltage()), electricityStored);
double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[1]);
setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects));
}
}
else if(inventory[1].getItem() instanceof IElectricItem)
{
double sent = ElectricItem.charge(inventory[1], (int)(electricityStored*UniversalElectricity.TO_IC2_RATIO), 3, false, false)*UniversalElectricity.IC2_RATIO;

View file

@ -67,10 +67,14 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
if(inventory[0].getItem() instanceof IItemElectric)
{
IItemElectric electricItem = (IItemElectric)inventory[0].getItem();
if(electricItem.canReceiveElectricity())
{
double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[0])*0.005, electricityStored), getVoltage()), electricityStored);
double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[0]);
setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects));
}
}
else if(inventory[0].getItem() instanceof IElectricItem)
{
double sent = ElectricItem.charge(inventory[0], (int)(electricityStored*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2;

View file

@ -37,14 +37,14 @@ public abstract class AdvancedMachineRecipeHandler extends TemplateRecipeHandler
public void drawExtras(GuiContainerManager guimanager, int i)
{
float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F;
drawProgressBar(guimanager, 63, 34, 176, 0, 24, 7, f, 0);
drawProgressBar(guimanager, 63, 34, 176 + 26, 0, 24, 7, f, 0);
f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F;
if(ticksPassed < 20) f = 0.0F;
drawProgressBar(guimanager, 45, 32, 176, 7, 5, 12, f, 3);
drawProgressBar(guimanager, 45, 32, 176 + 26, 7, 5, 12, f, 3);
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
drawProgressBar(guimanager, 149, 12, 176, 19, 4, 52, f, 3);
drawProgressBar(guimanager, 149, 12, 176 + 26, 19, 4, 52, f, 3);
}
@Override

View file

@ -35,9 +35,9 @@ public abstract class MachineRecipeHandler extends TemplateRecipeHandler
public void drawExtras(GuiContainerManager guimanager, int i)
{
float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F;
drawProgressBar(guimanager, 63, 34, 176, 0, 24, 7, f, 0);
drawProgressBar(guimanager, 63, 34, 176 + 26, 0, 24, 7, f, 0);
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
drawProgressBar(guimanager, 149, 12, 176, 7, 4, 52, f, 3);
drawProgressBar(guimanager, 149, 12, 176 + 26, 7, 4, 52, f, 3);
}
@Override

View file

@ -77,17 +77,17 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
public void drawExtras(GuiContainerManager guimanager, int i)
{
float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F;
drawProgressBar(guimanager, 67, 42, 176, 104, 32, 8, f, 0);
drawProgressBar(guimanager, 67, 42, 176 + 26, 104, 32, 8, f, 0);
f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F;
if(ticksPassed < 20) f = 0.0F;
int infuseX = 176 + (getOtherStacks(i).get(0).item.isItemEqual(new ItemStack(Mekanism.CompressedCarbon)) ? 4 : 0);
int infuseX = 176 + 26 + (getOtherStacks(i).get(0).item.isItemEqual(new ItemStack(Mekanism.CompressedCarbon)) ? 4 : 0);
int infuseY = getOtherStacks(i).get(0).item.isItemEqual(new ItemStack(Mekanism.CompressedCarbon)) ? 0 : 52;
drawProgressBar(guimanager, 2, 22, infuseX, infuseY, 4, 52, f, 3);
drawProgressBar(guimanager, 2, 12, infuseX, infuseY, 4, 52, f, 3);
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
drawProgressBar(guimanager, 160, 12, 176, 0, 4, 52, f, 3);
drawProgressBar(guimanager, 160, 12, 176 + 26, 0, 4, 52, f, 3);
}
@Override

View file

@ -26,7 +26,7 @@ import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.2.3", dependencies = "required-after:Mekanism")
@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.3.0", dependencies = "required-after:Mekanism")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class MekanismTools
{