v5.4.1 Release

Final build for 1.4.7.
*Cleaned up imports.
*Added javadocs and cleaned up code.
*API improvements and fixes.
*Changed around packages and finalized API.
*Fixed auto-download feature.
*Removed UE implementation of multiblock, added my own.
*Better Obsidian TNT code.
*Better Atomic Assembler efficiency modes.
*Made gas storage tanks more CPU efficient.
*Better version control.
*Added RecipeHelper for reflective implementations of recipes.
*Reduced Osmium generation.
*Fixed upgrade bug.
*Pressurized Tube doesn't function when receiving a redstone signal.
*Better Advanced Solar Generator code.
*HP information for hoes.
*Lowered chance of mobs spawning with armor.
*InfuseRegistry for adding new infuse objects.
*GasTransmission for external gas transmission.
This commit is contained in:
Aidan Brady 2013-03-11 13:49:01 -04:00
parent e77cc4c379
commit f745e84d31
50 changed files with 619 additions and 266 deletions

View file

@ -1,4 +1,4 @@
package mekanism.common;
package mekanism.api;
/**
* Simple color enum for adding colors to in-game GUI strings of text.

View file

@ -1,11 +1,9 @@
package mekanism.common;
package mekanism.api;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import mekanism.api.EnumGas;
import mekanism.api.IGasAcceptor;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@ -45,7 +43,7 @@ public class GasTransferProtocol
*/
public void loopThrough(TileEntity tile)
{
IGasAcceptor[] acceptors = MekanismUtils.getConnectedAcceptors(tile);
IGasAcceptor[] acceptors = GasTransmission.getConnectedAcceptors(tile);
for(IGasAcceptor acceptor : acceptors)
{
@ -60,7 +58,7 @@ public class GasTransferProtocol
iteratedTubes.add(tile);
TileEntity[] tubes = MekanismUtils.getConnectedTubes(tile);
TileEntity[] tubes = GasTransmission.getConnectedTubes(tile);
for(TileEntity tube : tubes)
{
@ -84,7 +82,6 @@ public class GasTransferProtocol
if(!availableAcceptors.isEmpty())
{
boolean sentRemaining = false;
int divider = availableAcceptors.size();
int remaining = gasToSend % divider;
int sending = (gasToSend-remaining)/divider;

View file

@ -0,0 +1,104 @@
package mekanism.api;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
public class GasTransmission
{
/**
* Gets all the tubes around a tile entity.
* @param tileEntity - center tile entity
* @return array of TileEntities
*/
public static TileEntity[] getConnectedTubes(TileEntity tileEntity)
{
TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.values())
{
if(orientation != ForgeDirection.UNKNOWN)
{
TileEntity tube = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(tube instanceof IPressurizedTube && ((IPressurizedTube)tube).canTransferGas())
{
tubes[orientation.ordinal()] = tube;
}
}
}
return tubes;
}
/**
* Gets all the acceptors around a tile entity.
* @param tileEntity - center tile entity
* @return array of IGasAcceptors
*/
public static IGasAcceptor[] getConnectedAcceptors(TileEntity tileEntity)
{
IGasAcceptor[] acceptors = new IGasAcceptor[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.values())
{
if(orientation != ForgeDirection.UNKNOWN)
{
TileEntity acceptor = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(acceptor instanceof IGasAcceptor)
{
acceptors[orientation.ordinal()] = (IGasAcceptor)acceptor;
}
}
}
return acceptors;
}
/**
* Gets all the tube connections around a tile entity.
* @param tileEntity - center tile entity
* @return array of ITubeConnections
*/
public static ITubeConnection[] getConnections(TileEntity tileEntity)
{
ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.values())
{
if(orientation != ForgeDirection.UNKNOWN)
{
TileEntity connection = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(connection instanceof ITubeConnection)
{
connections[orientation.ordinal()] = (ITubeConnection)connection;
}
}
}
return connections;
}
/**
* Emits a defined gas to the network.
* @param type - gas type to send
* @param amount - amount of gas to send
* @param sender - the sender of the gas
* @param facing - side the sender is outputting from
* @return rejected gas
*/
public static int emitGasToNetwork(EnumGas type, int amount, TileEntity sender, ForgeDirection facing)
{
TileEntity pointer = Vector3.getTileEntityFromSide(sender.worldObj, new Vector3(sender.xCoord, sender.yCoord, sender.zCoord), facing);
if(pointer != null)
{
GasTransferProtocol calculation = new GasTransferProtocol(pointer, type, amount);
return calculation.calculate();
}
return amount;
}
}

View file

@ -2,10 +2,6 @@ package mekanism.api;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import com.google.common.io.ByteArrayDataInput;
/**

View file

@ -0,0 +1,32 @@
package mekanism.api;
import java.lang.reflect.Field;
import java.util.HashMap;
import net.minecraft.item.ItemStack;
public class InfuseRegistry
{
/**
* Registers a block or item that serves as an infuse object. An infuse object will store a certain type and amount of infuse,
* and will deliver this amount to the Metallurgic Infuser's buffer of infuse. The item's stack size will be decremented when
* it is placed in the Metallurgic Infuser's infuse slot, and the machine can accept the type and amount of infuse stored in the
* object.
* @param itemStack - stack the infuse object is linked to -- stack size is ignored
* @param infuseObject - the infuse object with the type and amount data
* @return whether or not the registration was successful
*/
public boolean registerInfuseObject(ItemStack itemStack, InfuseObject infuseObject)
{
try {
Class c = Class.forName("mekanism.common.Mekanism");
Field field = c.getField("infusions");
HashMap<ItemStack, InfuseObject> map = (HashMap<ItemStack, InfuseObject>)field.get(null);
map.put(itemStack, infuseObject);
return true;
} catch(Exception e) {
System.err.println("[Mekanism] Error while adding infuse object: " + e.getMessage());
return false;
}
}
}

View file

@ -1,5 +1,6 @@
package mekanism.api;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -55,6 +56,10 @@ public final class ItemRetriever
{
return new ItemStack((Item)ret, 1);
}
else if(ret instanceof Block)
{
return new ItemStack((Block)ret, 1);
}
else {
return null;
}

View file

@ -0,0 +1,104 @@
package mekanism.api;
import java.lang.reflect.Method;
import net.minecraft.item.ItemStack;
public class RecipeHelper
{
/**
* Add an Enrichment Chamber recipe.
* @param input - input ItemStack
* @param output - output ItemStack
*/
public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.RecipeHandler");
Method m = recipeClass.getMethod("addEnrichmentChamberRecipe", ItemStack.class, ItemStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage());
}
}
/**
* Add an Osmium Compressor recipe.
* @param input - input ItemStack
* @param output - output ItemStack
*/
public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.RecipeHandler");
Method m = recipeClass.getMethod("addOsmiumCompressorRecipe", ItemStack.class, ItemStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage());
}
}
/**
* Add a Combiner recipe.
* @param input - input ItemStack
* @param output - output ItemStack
*/
public static void addCombinerRecipe(ItemStack input, ItemStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.RecipeHandler");
Method m = recipeClass.getMethod("addCombinerRecipe", ItemStack.class, ItemStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage());
}
}
/**
* Add a Crusher recipe.
* @param input - input ItemStack
* @param output - output ItemStack
*/
public static void addCrusherRecipe(ItemStack input, ItemStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.RecipeHandler");
Method m = recipeClass.getMethod("addCrusherRecipe", ItemStack.class, ItemStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage());
}
}
/**
* Add a Purification Chamber recipe.
* @param input - input ItemStack
* @param output - output ItemStack
*/
public static void addPurificationChamberRecipe(ItemStack input, ItemStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.RecipeHandler");
Method m = recipeClass.getMethod("addPurificationChamberRecipe", ItemStack.class, ItemStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage());
}
}
/**
* Add a Metallurgic Infuser recipe.
* @param input - input Infusion
* @param output - output ItemStack
*/
public static void addMetallurgicInfuserRecipe(InfusionInput input, ItemStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.RecipeHandler");
Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfusionInput.class, ItemStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage());
}
}
}

View file

@ -1,6 +1,5 @@
package mekanism.api;
import mekanism.common.EnumColor;
public class SideData
{

View file

@ -32,9 +32,8 @@ public final class TabProxy
{
return (CreativeTabs)ret;
}
else {
return preferred;
}
return preferred;
} catch(Exception e) {
System.err.println("[Mekanism] Error retrieving Mekanism creative tab.");
return preferred;

View file

@ -1,7 +1,7 @@
package mekanism.client;
import mekanism.api.EnumColor;
import mekanism.api.IAccessibleGui;
import mekanism.common.EnumColor;
import mekanism.common.PacketHandler;
import mekanism.common.TileEntityControlPanel;
import net.minecraft.client.gui.GuiButton;

View file

@ -1,6 +1,6 @@
package mekanism.client;
import mekanism.common.EnumColor;
import mekanism.api.EnumColor;
import mekanism.common.Mekanism;
import mekanism.common.MekanismUtils;
import net.minecraft.client.gui.GuiButton;
@ -16,6 +16,7 @@ public class GuiCredits extends GuiScreen {
controlList.clear();
controlList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update"));
controlList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel"));
((GuiButton)controlList.get(0)).enabled = !MekanismUtils.isNotOutdated();
}
@Override
@ -43,11 +44,13 @@ public class GuiCredits extends GuiScreen {
}
if(guibutton.id == 0)
{
if(!MekanismUtils.isLatestVersion())
if(!MekanismUtils.isNotOutdated())
{
updateProgress = "Downloading latest version...";
guibutton.enabled = false;
new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/Mekanism.jar");
new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/Mekanism-v" + Mekanism.latestVersionNumber + ".jar", 0);
new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismGenerators-v" + Mekanism.latestVersionNumber + ".jar", 1);
new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismTools-v" + Mekanism.latestVersionNumber + ".jar", 2);
}
else {
updateProgress = "You already have the latest version.";
@ -75,11 +78,11 @@ public class GuiCredits extends GuiScreen {
{
drawDefaultBackground();
drawCenteredString(fontRenderer, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff);
writeText(EnumColor.GREY + "Your version: " + (MekanismUtils.isLatestVersion() ? Mekanism.versionNumber.toString() : EnumColor.DARK_RED + Mekanism.versionNumber.toString()) + EnumColor.GREY + " -- OUTDATED", 36);
writeText(EnumColor.GREY + "Your version: " + (MekanismUtils.isNotOutdated() ? Mekanism.versionNumber : EnumColor.DARK_RED + Mekanism.versionNumber.toString() + EnumColor.GREY + " -- OUTDATED"), 36);
writeText(EnumColor.GREY + "Newest version: " + Mekanism.latestVersionNumber, 45);
writeText(EnumColor.GREY + "*Developed on Mac OS X 10.8 Mountain Lion", 63);
writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", 72);
writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + Mekanism.recentNews, 81);
writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), 81);
writeText(EnumColor.GREY + updateProgress, 99);
super.drawScreen(i, j, f);
}

View file

@ -1,6 +1,6 @@
package mekanism.client;
import mekanism.common.EnumColor;
import mekanism.api.EnumColor;
import mekanism.common.MekanismUtils;
import mekanism.common.TileEntityTheoreticalElementizer;
import net.minecraft.entity.player.InventoryPlayer;

View file

@ -40,7 +40,7 @@ public class ItemRenderingHandler implements IItemRenderer
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
renderItem((RenderBlocks)data[0], tier == EnergyCubeTier.BASIC ? 0 : (tier == EnergyCubeTier.ADVANCED ? 1 : (tier == EnergyCubeTier.ELITE ? 2 : 0)));
renderItem((RenderBlocks)data[0], tier == EnergyCubeTier.BASIC ? 0 : (tier == EnergyCubeTier.ADVANCED ? 1 : (tier == EnergyCubeTier.ELITE ? 2 : 3)));
}
}
@ -57,7 +57,7 @@ public class ItemRenderingHandler implements IItemRenderer
renderer.setRenderBoundsFromBlock(block);
block.setBlockBoundsForItemRender();
if (renderer.useInventoryTint)
if(renderer.useInventoryTint)
{
int renderColor = block.getRenderColor(metadata);
float red = (float)(renderColor >> 16 & 255) / 255.0F;

View file

@ -6,6 +6,7 @@ import org.lwjgl.opengl.GL11;
import net.minecraftforge.common.ForgeDirection;
import mekanism.api.GasTransmission;
import mekanism.api.IGasAcceptor;
import mekanism.api.ITubeConnection;
import mekanism.common.MekanismUtils;
@ -29,11 +30,11 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
ITubeConnection[] connections = MekanismUtils.getConnections(tileEntity);
ITubeConnection[] connections = GasTransmission.getConnections(tileEntity);
for(ITubeConnection connection : connections)
{
if(connection != null)
if(connection != null)
{
int side = Arrays.asList(connections).indexOf(connection);

View file

@ -73,14 +73,14 @@ public class SoundHandler
}
}
/** Create and return an instance of a Sound.
*
/**
* Create and return an instance of a Sound.
* @param name - unique identifier for this sound
* @param path - bundled path to the sound effect
* @param world - world to play sound in
* @param x - x coord
* @param y - y coord
* @param z - z coord
* @param x - x coordinate
* @param y - y coordinate
* @param z - z coordinate
* @return Sound instance
*/
public Sound getSound(String path, World world, int x, int y, int z)

View file

@ -16,13 +16,15 @@ import net.minecraft.client.Minecraft;
*/
public class ThreadClientUpdate extends Thread
{
private int downloadType;
private int bytesDownloaded;
private int lastBytesDownloaded;
private byte[] buffer = new byte[10240];
private URL url;
public ThreadClientUpdate(String location)
public ThreadClientUpdate(String location, int type)
{
downloadType = type;
try {
url = new URL(location);
setDaemon(true);
@ -35,7 +37,8 @@ public class ThreadClientUpdate extends Thread
@Override
public void run()
{
File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods/Mekanism.jar").toString());
String downloadName = downloadType == 0 ? "" : (downloadType == 1 ? "Generators" : "Tools");
File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods/Mekanism" + downloadName + "-v" + Mekanism.latestVersionNumber + ".jar").toString());
try {
prepareForDownload();
download.createNewFile();
@ -51,10 +54,14 @@ public class ThreadClientUpdate extends Thread
outputStream.close();
stream.close();
GuiCredits.onFinishedDownloading();
System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ").");
finalize();
if(downloadType == 2)
{
GuiCredits.onFinishedDownloading();
System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ").");
}
finalize();
} catch(Throwable e)
{
GuiCredits.onErrorDownloading();
@ -72,17 +79,16 @@ public class ThreadClientUpdate extends Thread
*/
public void prepareForDownload()
{
File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods/Mekanism.jar").toString());
File config = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/config/Mekanism.cfg").toString());
File[] modsList = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods").toString()).listFiles();
if(download.exists())
for(File file : modsList)
{
download.delete();
}
if(config.exists())
{
config.delete();
if(file.getName().startsWith("Mekanism") && file.getName().endsWith(".jar") && !file.getName().contains(Mekanism.latestVersionNumber))
{
file.delete();
}
}
System.out.println("[Mekanism] Preparing to update...");
}
}

View file

@ -0,0 +1,90 @@
package mekanism.common;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockBounding extends Block
{
public BlockBounding(int id)
{
super(id, Material.iron);
setHardness(0.8F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ)
{
TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z);
return Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)].onBlockActivated(world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, entityplayer, facing, playerX, playerY, playerZ);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z);
return Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)].getPickBlock(target, world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ);
}
@Override
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
{
TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z);
if(Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)] != null)
{
return Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)].removeBlockByPlayer(world, player, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ);
}
return false;
}
@Override
public int quantityDropped(Random random)
{
return 0;
}
@Override
public int idDropped(int i, Random random, int j)
{
return 0;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean hasTileEntity(int metadata)
{
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata)
{
return new TileEntityBoundingBlock();
}
}

View file

@ -75,6 +75,11 @@ public class BlockMachine extends BlockContainer implements IDismantleable
}
tileEntity.setFacing((short)change);
if(tileEntity instanceof IBoundingBlock)
{
((IBoundingBlock)tileEntity).onPlace();
}
}
@Override

View file

@ -6,6 +6,7 @@ import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.GasTransmission;
import mekanism.api.IGasAcceptor;
import mekanism.api.ITubeConnection;
import mekanism.client.ClientProxy;
@ -46,7 +47,7 @@ public class BlockPressurizedTube extends Block
if(tileEntity != null)
{
boolean[] connectable = new boolean[] {false, false, false, false, false, false};
ITubeConnection[] connections = MekanismUtils.getConnections(tileEntity);
ITubeConnection[] connections = GasTransmission.getConnections(tileEntity);
for(ITubeConnection connection : connections)
{

View file

@ -3,6 +3,7 @@ package mekanism.common;
import java.util.Arrays;
import java.util.List;
import mekanism.api.EnumColor;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;

View file

@ -63,7 +63,7 @@ public class CommonProxy
Mekanism.oreBlockID = Mekanism.configuration.getBlock("OreBlock", 3002).getInt();
Mekanism.obsidianTNTID = Mekanism.configuration.getBlock("ObsidianTNT", 3003).getInt();
Mekanism.energyCubeID = Mekanism.configuration.getBlock("EnergyCube", 3004).getInt();
Mekanism.nullRenderID = Mekanism.configuration.getBlock("NullRender", 3005).getInt();
Mekanism.boundingBlockID = Mekanism.configuration.getBlock("BoundingBlock", 3005).getInt();
Mekanism.gasTankID = Mekanism.configuration.getBlock("GasTank", 3006).getInt();
Mekanism.pressurizedTubeID = Mekanism.configuration.getBlock("PressurizedTube", 3007).getInt();
Mekanism.extrasEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ExtrasEnabled", true).getBoolean(true);

View file

@ -8,29 +8,31 @@ public class EntityObsidianTNT extends Entity
{
/** How long the fuse is */
public int fuse;
/** Whether or not the TNT has exploded */
private boolean hasExploded = false;
public EntityObsidianTNT(World par1World)
public EntityObsidianTNT(World world)
{
super(par1World);
super(world);
fuse = 0;
preventEntitySpawning = true;
setSize(0.98F, 0.98F);
yOffset = height / 2.0F;
}
public EntityObsidianTNT(World par1World, double par2, double par4, double par6)
public EntityObsidianTNT(World world, double x, double y, double z)
{
this(par1World);
setPosition(par2, par4, par6);
float var8 = (float)(Math.random() * Math.PI * 2);
motionX = (double)(-((float)Math.sin((double)var8)) * 0.02F);
this(world);
setPosition(x, y, z);
float randPi = (float)(Math.random()*Math.PI*2);
motionX = -(Math.sin(randPi))*0.02F;
motionY = 0.2;
motionZ = (double)(-((float)Math.cos((double)var8)) * 0.02F);
motionZ = -(Math.cos(randPi))*0.02F;
fuse = Mekanism.ObsidianTNTDelay;
prevPosX = par2;
prevPosY = par4;
prevPosZ = par6;
prevPosX = x;
prevPosY = y;
prevPosZ = z;
}
@Override
@ -60,22 +62,21 @@ public class EntityObsidianTNT extends Entity
motionY *= 0.98;
motionZ *= 0.98;
if (onGround)
if(onGround)
{
motionX *= 0.7;
motionZ *= 0.7;
motionY *= -0.5;
}
if (fuse-- <= 0)
if(fuse-- <= 0)
{
if (!worldObj.isRemote)
if(!worldObj.isRemote)
{
setDead();
explode();
}
else
{
else {
if(hasExploded)
{
setDead();
@ -85,8 +86,7 @@ public class EntityObsidianTNT extends Entity
}
}
}
else
{
else {
worldObj.spawnParticle("lava", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
}
}

View file

@ -0,0 +1,14 @@
package mekanism.common;
public interface IBoundingBlock
{
/**
* Called when the main block is placed.
*/
public void onPlace();
/**
* Called when any part of the structure is broken.
*/
public void onBreak();
}

View file

@ -2,6 +2,7 @@ package mekanism.common;
import java.util.List;
import mekanism.api.EnumColor;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
@ -43,6 +44,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
else {
hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 4);
}
return false;
}
@ -54,7 +56,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
@Override
public boolean onBlockDestroyed(ItemStack itemstack, World world, int id, int x, int y, int z, EntityLiving entityliving)
{
if ((double)Block.blocksList[id].getBlockHardness(world, x, y, z) != 0.0D)
if(Block.blocksList[id].getBlockHardness(world, x, y, z) != 0.0D)
{
onUse(getEfficiency(itemstack), itemstack);
}
@ -93,10 +95,10 @@ public class ItemAtomicDisassembler extends ItemEnergized
{
if(itemStack.stackTagCompound == null)
{
return 5;
return 2;
}
int efficiency = 5;
int efficiency = 2;
if(itemStack.stackTagCompound.getTag("efficiency") != null)
{
@ -119,26 +121,31 @@ public class ItemAtomicDisassembler extends ItemEnergized
public int getIncremented(int previous)
{
if(previous == 5)
if(previous == 0)
{
return 10;
return 2;
}
else if(previous == 10)
else if(previous == 2)
{
return 25;
return 8;
}
else if(previous == 25)
else if(previous == 8)
{
return 50;
return 24;
}
else if(previous == 50)
else if(previous == 24)
{
return 64;
}
else if(previous == 64)
{
return 100;
}
else if(previous == 100)
{
return 5;
return 0;
}
return 0;
}
}

View file

@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import mekanism.api.EnumColor;
import mekanism.api.IConfigurable;
public class ItemConfigurator extends ItemEnergized

View file

@ -2,6 +2,7 @@ package mekanism.common;
import java.util.List;
import mekanism.api.EnumColor;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -1,5 +1,6 @@
package mekanism.common;
import mekanism.api.EnumColor;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

View file

@ -54,10 +54,8 @@ public class ItemStorageTank extends ItemMekanism implements IStorageTank
public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
{
ItemStorageTank item = ((ItemStorageTank)itemstack.getItem());
item.setGas(itemstack, item.getGasType(itemstack), item.getGas(itemstack));
item.setGasType(itemstack, item.getGasType(itemstack));
if(item.getGas(itemstack) == 0)
if(item.getGas(itemstack) == 0 && item.getGasType(itemstack) != EnumGas.NONE)
{
item.setGasType(itemstack, EnumGas.NONE);
}

View file

@ -11,6 +11,7 @@ import mekanism.api.InfuseObject;
import mekanism.api.InfusionInput;
import mekanism.api.InfusionOutput;
import mekanism.api.InfusionType;
import mekanism.api.RecipeHelper;
import mekanism.api.Tier.EnergyCubeTier;
import mekanism.client.SoundHandler;
import net.minecraft.block.Block;
@ -23,8 +24,6 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.multiblock.BlockMulti;
import universalelectricity.prefab.multiblock.TileEntityMulti;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
@ -52,7 +51,7 @@ import cpw.mods.fml.server.FMLServerHandler;
* @author AidanBrady
*
*/
@Mod(modid = "Mekanism", name = "Mekanism", version = "5.4.0")
@Mod(modid = "Mekanism", name = "Mekanism", version = "5.4.1")
@NetworkMod(channels = {"Mekanism"}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class Mekanism
{
@ -74,7 +73,7 @@ public class Mekanism
public static Configuration configuration;
/** Mekanism version number */
public static Version versionNumber = new Version(5, 4, 0);
public static Version versionNumber = new Version(5, 4, 1);
/** Map of Teleporters */
public static Map<Teleporter.Code, ArrayList<Teleporter.Coords>> teleporters = new HashMap<Teleporter.Code, ArrayList<Teleporter.Coords>>();
@ -110,7 +109,7 @@ public class Mekanism
public static int oreBlockID = 3002;
public static int obsidianTNTID = 3003;
public static int energyCubeID = 3004;
public static int nullRenderID = 3005;
public static int boundingBlockID = 3005;
public static int gasTankID = 3006;
public static int pressurizedTubeID = 3007;
@ -132,17 +131,17 @@ public class Mekanism
public static Item TeleportationCore;
public static Item Configurator;
//Extra Blocks
//Blocks
public static Block BasicBlock;
public static Block MachineBlock;
public static Block OreBlock;
public static Block ObsidianTNT;
public static Block EnergyCube;
public static BlockMulti NullRender;
public static Block BoundingBlock;
public static Block GasTank;
public static Block PressurizedTube;
//MultiID Items
//Multi-ID Items
public static Item Dust;
public static Item Ingot;
public static Item Clump;
@ -399,7 +398,7 @@ public class Mekanism
LanguageRegistry.addName(AtomicCore, "Atomic Core");
LanguageRegistry.addName(ElectricBow, "Electric Bow");
LanguageRegistry.addName(StorageTank, "Hydrogen Tank");
LanguageRegistry.addName(NullRender, "Null Render");
LanguageRegistry.addName(BoundingBlock, "Bounding Block");
LanguageRegistry.addName(GasTank, "Gas Tank");
LanguageRegistry.addName(StorageTank, "Storage Tank");
LanguageRegistry.addName(ControlCircuit, "Control Circuit");
@ -552,13 +551,13 @@ public class Mekanism
OreBlock = new BlockOre(oreBlockID).setBlockName("OreBlock");
EnergyCube = new BlockEnergyCube(energyCubeID).setBlockName("EnergyCube");
ObsidianTNT = new BlockObsidianTNT(obsidianTNTID).setBlockName("ObsidianTNT").setCreativeTab(tabMekanism);
NullRender = (BlockMulti) new BlockMulti(nullRenderID).setBlockName("NullRender");
BoundingBlock = (BlockBounding) new BlockBounding(boundingBlockID).setBlockName("BoundingBlock");
GasTank = new BlockGasTank(gasTankID).setBlockName("GasTank");
PressurizedTube = new BlockPressurizedTube(pressurizedTubeID).setBlockName("PressurizedTube");
//Registrations
GameRegistry.registerBlock(ObsidianTNT, "ObsidianTNT");
GameRegistry.registerBlock(NullRender, "NullRender");
GameRegistry.registerBlock(BoundingBlock, "BoundingBlock");
GameRegistry.registerBlock(GasTank, "GasTank");
GameRegistry.registerBlock(PressurizedTube, "PressurizedTube");
@ -879,7 +878,7 @@ public class Mekanism
GameRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner");
GameRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher");
GameRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube");
GameRegistry.registerTileEntity(TileEntityMulti.class, "MekanismMulti");
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
GameRegistry.registerTileEntity(TileEntityControlPanel.class, "ControlPanel");
GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank");
GameRegistry.registerTileEntity(TileEntitySmeltingFactory.class, "SmeltingFactory");

View file

@ -10,7 +10,9 @@ import java.util.Arrays;
import java.util.Map;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.TileEntityMulti;
import mekanism.api.EnumColor;
import mekanism.api.EnumGas;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
@ -49,7 +51,7 @@ public final class MekanismUtils
{
if(Mekanism.updateNotifications)
{
if(!Mekanism.latestVersionNumber.equals("Error retrieving data."))
if(!Mekanism.latestVersionNumber.equals("null"))
{
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1)
{
@ -79,8 +81,8 @@ public final class MekanismUtils
public static String getLatestVersion()
{
String[] text = getHTML("http://dl.dropbox.com/u/90411166/Mod%20Versions/Mekanism.txt").split(":");
if(!text[0].contains("UTF-8") && !text[0].contains("HTML")) return text[0];
return "Error retrieving data.";
if(!text[0].contains("UTF-8") && !text[0].contains("HTML") && !text[0].contains("http")) return text[0];
return "null";
}
/**
@ -90,8 +92,8 @@ public final class MekanismUtils
public static String getRecentNews()
{
String[] text = getHTML("http://dl.dropbox.com/u/90411166/Mod%20Versions/Mekanism.txt").split(":");
if(text.length > 1 && !text[1].contains("UTF-8") && !text[1].contains("HTML")) return text[1];
return "There is no news to show.";
if(text.length > 1 && !text[1].contains("UTF-8") && !text[1].contains("HTML") && !text[1].contains("http")) return text[1];
return "null";
}
/**
@ -119,7 +121,7 @@ public final class MekanismUtils
}
rd.close();
} catch (Exception e) {
result = "Error retrieving data.";
result = "null";
System.err.println("[Mekanism] An error occured while connecting to URL '" + urlToRead + ".'");
}
return result;
@ -140,6 +142,10 @@ public final class MekanismUtils
}
}
/**
* Sends the defined message to all players.
* @param msg - message to send
*/
public static void sendChatMessageToAllPlayers(String msg)
{
PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(msg));
@ -149,9 +155,9 @@ public final class MekanismUtils
* Checks if the mod is running on the latest version.
* @return if mod is latest version
*/
public static boolean isLatestVersion()
public static boolean isNotOutdated()
{
return Mekanism.versionNumber.toString().equals(Mekanism.latestVersionNumber);
return Mekanism.latestVersionNumber.contains("null") || Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) != -1;
}
/**
@ -412,98 +418,15 @@ public final class MekanismUtils
}
/**
* Gets all the tubes around a tile entity.
* @param tileEntity - center tile entity
* @return array of TileEntities
* Places a fake bounding block at the defined location.
* @param world - world to place block in
* @param x - x coordinate
* @param y - y coordinate
* @param z - z coordinate
*/
public static TileEntity[] getConnectedTubes(TileEntity tileEntity)
public static void makeBoundingBlock(World world, int x, int y, int z, int origX, int origY, int origZ)
{
TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.values())
{
if(orientation != ForgeDirection.UNKNOWN)
{
TileEntity tube = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(tube instanceof IPressurizedTube && ((IPressurizedTube)tube).canTransferGas())
{
tubes[orientation.ordinal()] = tube;
}
}
}
return tubes;
}
/**
* Gets all the acceptors around a tile entity.
* @param tileEntity - center tile entity
* @return array of IGasAcceptors
*/
public static IGasAcceptor[] getConnectedAcceptors(TileEntity tileEntity)
{
IGasAcceptor[] acceptors = new IGasAcceptor[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.values())
{
if(orientation != ForgeDirection.UNKNOWN)
{
TileEntity acceptor = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(acceptor instanceof IGasAcceptor)
{
acceptors[orientation.ordinal()] = (IGasAcceptor)acceptor;
}
}
}
return acceptors;
}
/**
* Gets all the tube connections around a tile entity.
* @param tileEntity - center tile entity
* @return array of ITubeConnections
*/
public static ITubeConnection[] getConnections(TileEntity tileEntity)
{
ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.values())
{
if(orientation != ForgeDirection.UNKNOWN)
{
TileEntity connection = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(connection instanceof ITubeConnection)
{
connections[orientation.ordinal()] = (ITubeConnection)connection;
}
}
}
return connections;
}
/**
* Emits a defined gas to the network.
* @param type - gas type to send
* @param amount - amount of gas to send
* @param sender - the sender of the gas
* @param facing - side the sender is outputting from
* @return rejected gas
*/
public static int emitGasToNetwork(EnumGas type, int amount, TileEntity sender, ForgeDirection facing)
{
TileEntity pointer = Vector3.getTileEntityFromSide(sender.worldObj, new Vector3(sender.xCoord, sender.yCoord, sender.zCoord), facing);
if(pointer != null)
{
GasTransferProtocol calculation = new GasTransferProtocol(pointer, type, amount);
return calculation.calculate();
}
return amount;
world.setBlockWithNotify(x, y, z, Mekanism.BoundingBlock.blockID);
((TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z)).setMainLocation(origX, origY, origZ);
}
}

View file

@ -17,12 +17,12 @@ public class OreHandler implements IWorldGenerator
{
if(!(chunkGenerator instanceof ChunkProviderHell) && !(chunkGenerator instanceof ChunkProviderEnd))
{
for(int i=0;i<12;i++)
for(int i=0;i<8;i++)
{
int randPosX = (chunkX*16) + random.nextInt(16);
int randPosY = random.nextInt(60);
int randPosZ = (chunkZ*16) + random.nextInt(16);
(new WorldGenMinable(new ItemStack(Mekanism.OreBlock, 1, 0).itemID, 12)).generate(world, random, randPosX, randPosY, randPosZ);
(new WorldGenMinable(new ItemStack(Mekanism.OreBlock, 1, 0).itemID, 8)).generate(world, random, randPosX, randPosY, randPosZ);
}
}
}

View file

@ -53,6 +53,7 @@ public class PacketHandler implements IPacketHandler
System.out.println("[Mekanism] Received weather update packet from " + entityplayer.username + ".");
entityplayer.getCurrentEquippedItem().damageItem(4999, entityplayer);
int weatherType = dataStream.readInt();
if(weatherType == EnumWeatherType.CLEAR.id)
{
entityplayer.worldObj.getWorldInfo().setRaining(false);
@ -447,7 +448,7 @@ public class PacketHandler implements IPacketHandler
packet.data = bytes.toByteArray();
packet.length = packet.data.length;
PacketDispatcher.sendPacketToAllAround(x, y, z, 40, id, packet);
System.out.println("[Mekanism] Sent portal FX packet to server.");
System.out.println("[Mekanism] Sent portal FX packet to clients.");
}
/**

View file

@ -70,7 +70,7 @@ public final class RecipeHandler
}
/**
* Adds a Metallurgic Infuser recipe.
* Add a Metallurgic Infuser recipe.
* @param input - input Infusion
* @param output - output ItemStack
*/
@ -147,7 +147,7 @@ public final class RecipeHandler
PURIFICATION_CHAMBER(new HashMap<ItemStack, ItemStack>()),
METALLURGIC_INFUSER(new HashMap<InfusionInput, InfusionOutput>());
private Map recipes;
private HashMap recipes;
private Recipe(HashMap map)
{
@ -159,7 +159,7 @@ public final class RecipeHandler
recipes.put(input, output);
}
public Map get()
public HashMap get()
{
return recipes;
}

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import ic2.api.ElectricItem;
import ic2.api.IElectricItem;
import mekanism.api.EnumColor;
import mekanism.api.SideData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -114,7 +115,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
if(inventory[4] != null)
{
if(inventory[4].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
if(inventory[4].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{

View file

@ -1,5 +1,6 @@
package mekanism.common;
import mekanism.api.EnumColor;
import mekanism.api.SideData;
import mekanism.api.Tier.SmeltingFactoryTier;

View file

@ -0,0 +1,88 @@
package mekanism.common;
import java.util.ArrayList;
import com.google.common.io.ByteArrayDataInput;
import mekanism.api.EnumGas;
import mekanism.api.ITileNetwork;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork
{
public int mainX;
public int mainY;
public int mainZ;
public void setMainLocation(int x, int y, int z)
{
mainX = x;
mainY = y;
mainZ = z;
if(!worldObj.isRemote)
{
PacketHandler.sendTileEntityPacketToClients(this, 0, getNetworkedData(new ArrayList()));
}
}
@Override
public boolean canUpdate()
{
return false;
}
@Override
public void validate()
{
super.validate();
if(worldObj.isRemote)
{
PacketHandler.sendDataRequest(this);
}
}
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
mainX = dataStream.readInt();
mainY = dataStream.readInt();
mainZ = dataStream.readInt();
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
mainX = nbtTags.getInteger("mainX");
mainY = nbtTags.getInteger("mainX");
mainZ = nbtTags.getInteger("mainX");
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("mainX", mainX);
nbtTags.setInteger("mainY", mainY);
nbtTags.setInteger("mainZ", mainZ);
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
data.add(mainX);
data.add(mainY);
data.add(mainZ);
return data;
}
}

View file

@ -2,6 +2,7 @@ package mekanism.common;
import ic2.api.ElectricItem;
import ic2.api.IElectricItem;
import mekanism.api.EnumColor;
import mekanism.api.SideData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -87,7 +88,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
if(inventory[3] != null)
{
if(inventory[3].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
if(inventory[3].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{

View file

@ -1,5 +1,6 @@
package mekanism.common;
import mekanism.api.EnumColor;
import mekanism.api.SideData;
import mekanism.api.Tier.SmeltingFactoryTier;

View file

@ -3,6 +3,7 @@ package mekanism.common;
import java.util.ArrayList;
import mekanism.api.EnumGas;
import mekanism.api.GasTransmission;
import mekanism.api.IGasAcceptor;
import mekanism.api.IGasStorage;
import mekanism.api.IStorageTank;
@ -110,7 +111,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
if(gasStored > 0 && !worldObj.isRemote)
{
setGas(gasType, gasStored - (Math.min(gasStored, output) - MekanismUtils.emitGasToNetwork(gasType, Math.min(gasStored, output), this, ForgeDirection.getOrientation(facing))));
setGas(gasType, gasStored - (Math.min(gasStored, output) - GasTransmission.emitGasToNetwork(gasType, Math.min(gasStored, output), this, ForgeDirection.getOrientation(facing))));
TileEntity tileEntity = Vector3.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing));

View file

@ -10,6 +10,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.EnumColor;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IUpgradeManagement;
@ -200,7 +201,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
if(inventory[0] != null)
{
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{

View file

@ -13,7 +13,7 @@ public class TileEntityPressurizedTube extends TileEntity implements IPressurize
@Override
public boolean canTransferGas()
{
return true;
return !worldObj.isBlockGettingPowered(xCoord, yCoord, zCoord);
}
@Override

View file

@ -7,6 +7,7 @@ import ic2.api.Direction;
import ic2.api.ElectricItem;
import ic2.api.IElectricItem;
import ic2.api.energy.tile.IEnergySink;
import mekanism.api.EnumColor;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IUpgradeManagement;
@ -201,7 +202,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
if(inventory[0] != null)
{
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8)
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
{
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
{

View file

@ -25,6 +25,7 @@ import cpw.mods.fml.server.FMLServerHandler;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
import mekanism.api.EnumColor;
import mekanism.common.Teleporter.Coords;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;

View file

@ -8,6 +8,7 @@ import buildcraft.api.tools.IToolWrench;
import mekanism.api.IActiveState;
import mekanism.api.IEnergyCube;
import mekanism.common.IBoundingBlock;
import mekanism.common.Mekanism;
import mekanism.common.MekanismUtils;
import mekanism.common.TileEntityBasicBlock;
@ -30,9 +31,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import thermalexpansion.api.core.IDismantleable;
import universalelectricity.core.implement.IItemElectric;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IToolConfigurator;
import universalelectricity.prefab.multiblock.IMultiBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -97,7 +96,7 @@ public class BlockGenerator extends BlockContainer implements IDismantleable
int height = Math.round(entityliving.rotationPitch);
int change = 3;
if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && world.getBlockMetadata(x, y, z) != 1)
if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1))
{
if(height >= 65)
{
@ -120,9 +119,9 @@ public class BlockGenerator extends BlockContainer implements IDismantleable
tileEntity.setFacing((short)change);
if(tileEntity instanceof IMultiBlock)
if(tileEntity instanceof IBoundingBlock)
{
((IMultiBlock)tileEntity).onCreate(new Vector3(x, y, z));
((IBoundingBlock)tileEntity).onPlace();
}
}
@ -429,24 +428,9 @@ public class BlockGenerator extends BlockContainer implements IDismantleable
}
}
if(world.getBlockMetadata(x, y, z) == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
if(tileEntity instanceof IBoundingBlock)
{
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));
IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem();
electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem());
world.spawnEntityInWorld(entityItem);
}
if(tileEntity instanceof IMultiBlock)
{
((IMultiBlock)tileEntity).onDestroy(tileEntity);
((IBoundingBlock)tileEntity).onBreak();
}
}
@ -612,7 +596,7 @@ public class BlockGenerator extends BlockContainer implements IDismantleable
@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)) && world.getBlockMetadata(x, y, z) != GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z);

View file

@ -22,7 +22,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.4.0", dependencies = "required-after:Mekanism")
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.4.1", dependencies = "required-after:Mekanism")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class MekanismGenerators
{

View file

@ -1,12 +1,12 @@
package mekanism.generators.common;
import mekanism.common.IBoundingBlock;
import mekanism.common.Mekanism;
import mekanism.common.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.IMultiBlock;
public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IMultiBlock
public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IBoundingBlock
{
public TileEntityAdvancedSolarGenerator()
{
@ -14,21 +14,21 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i
}
@Override
public void onCreate(Vector3 position)
public void onPlace()
{
Mekanism.NullRender.makeFakeBlock(worldObj, new Vector3(xCoord, yCoord+1, zCoord), new Vector3(xCoord, yCoord, zCoord));
MekanismUtils.makeBoundingBlock(worldObj, xCoord, yCoord+1, zCoord, xCoord, yCoord, zCoord);
for(int x=-1;x<=1;x++)
{
for(int z=-1;z<=1;z++)
{
Mekanism.NullRender.makeFakeBlock(worldObj, new Vector3(xCoord+x, yCoord+2, zCoord+z), position);
MekanismUtils.makeBoundingBlock(worldObj, xCoord+x, yCoord+2, zCoord+z, xCoord, yCoord, zCoord);
}
}
}
@Override
public void onDestroy(TileEntity tileEntity)
public void onBreak()
{
worldObj.setBlock(xCoord, yCoord+1, zCoord, 0);
@ -41,17 +41,5 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i
}
worldObj.setBlock(xCoord, yCoord, zCoord, 0);
invalidate();
}
@Override
public boolean onActivated(EntityPlayer entityplayer)
{
if(!entityplayer.isSneaking())
{
entityplayer.openGui(MekanismGenerators.instance, 1, worldObj, xCoord, yCoord, zCoord);
return true;
}
return false;
}
}

View file

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.EnumSet;
import mekanism.api.EnumGas;
import mekanism.api.GasTransmission;
import mekanism.api.IGasAcceptor;
import mekanism.api.IGasStorage;
import mekanism.api.IStorageTank;
@ -72,7 +73,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
public TileEntityElectrolyticSeparator()
{
super("Electrolytic Seperator", 9600);
super("Electrolytic Separator", 9600);
ElectricityConnections.registerConnector(this, EnumSet.allOf(ForgeDirection.class));
inventory = new ItemStack[4];
outputType = EnumGas.HYDROGEN;
@ -90,16 +91,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
setJoules(electricityStored + received);
}
if(hydrogenStored > MAX_GAS)
{
hydrogenStored = MAX_GAS;
}
if(oxygenStored > MAX_GAS)
{
oxygenStored = MAX_GAS;
}
if(!worldObj.isRemote)
{
for(ForgeDirection direction : ForgeDirection.values())
@ -246,7 +237,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
if(outputType != EnumGas.NONE && getGas(outputType) > 0 && !worldObj.isRemote)
{
setGas(outputType, getGas(outputType) - (Math.min(getGas(outputType), output) - MekanismUtils.emitGasToNetwork(outputType, Math.min(getGas(outputType), output), this, ForgeDirection.getOrientation(facing))));
setGas(outputType, getGas(outputType) - (Math.min(getGas(outputType), output) - GasTransmission.emitGasToNetwork(outputType, Math.min(getGas(outputType), output), this, ForgeDirection.getOrientation(facing))));
TileEntity tileEntity = Vector3.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing));

View file

@ -22,7 +22,7 @@ public class NEIMekanismConfig implements IConfigureNEI
API.registerRecipeHandler(new PurificationChamberRecipeHandler());
API.registerUsageHandler(new PurificationChamberRecipeHandler());
API.hideItem(Mekanism.nullRenderID);
API.hideItem(Mekanism.boundingBlockID);
}
@Override

View file

@ -1,5 +1,7 @@
package mekanism.tools.common;
import java.util.List;
import mekanism.common.ItemMekanism;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
@ -36,12 +38,12 @@ public class ItemMekanismHoe extends ItemMekanism
else
{
UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event))
if(MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if (event.getResult() == Result.ALLOW)
if(event.getResult() == Result.ALLOW)
{
itemstack.damageItem(1, entityplayer);
return true;
@ -50,12 +52,11 @@ public class ItemMekanismHoe extends ItemMekanism
int blockID = world.getBlockId(x, y, z);
int aboveBlockID = world.getBlockId(x, y + 1, z);
if ((side == 0 || aboveBlockID != 0 || blockID != Block.grass.blockID) && blockID != Block.dirt.blockID)
if((side == 0 || aboveBlockID != 0 || blockID != Block.grass.blockID) && blockID != Block.dirt.blockID)
{
return false;
}
else
{
else {
Block block = Block.tilledField;
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
@ -63,8 +64,7 @@ public class ItemMekanismHoe extends ItemMekanism
{
return true;
}
else
{
else {
world.setBlockWithNotify(x, y, z, block.blockID);
itemstack.damageItem(1, entityplayer);
return true;
@ -72,6 +72,12 @@ public class ItemMekanismHoe extends ItemMekanism
}
}
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage()));
}
@Override
@SideOnly(Side.CLIENT)

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.4.0", dependencies = "required-after:Mekanism")
@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.4.1", dependencies = "required-after:Mekanism")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class MekanismTools
{
@ -619,7 +619,7 @@ public class MekanismTools
int chance = random.nextInt(100);
int secondChance = random.nextInt(3);
if(chance < 4)
if(chance < 3)
{
if(event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntitySkeleton)
{