*Fixed Forestry integration.
*Fixed being able to smelt all dusts into Platinum Dust.
*Fixed being able to smelt all ores into Platinum Ingots.
*Fixed Platinum Ore smelting recipe returning 2 Platinum Ingots.
*Fixed crash when using Steve's Stopwatch.
*Fixed client failing and textures glitching when using Steve's
Stopwatch.
*Fixed being able to set machines,' Advanced Solar Generators,' and
Bio-Generators' orientation upwards.
*Made Solar Generators be shaped like slabs.
*Finally cleaned up tool and armor code.
*Started work on Steel Tools and Armor.
*Made client-to-server data transfer only work if Minecraft's snooper
function is enabled.
This commit is contained in:
Aidan Brady 2012-11-28 20:03:55 -05:00
parent 03f701d200
commit 36ea2bdb43
19 changed files with 167 additions and 83 deletions

View file

@ -253,8 +253,8 @@ public class Mekanism
}
//Furnace Recipes
GameRegistry.addSmelting(new ItemStack(OreBlock, 1, 0).itemID, new ItemStack(Ingot, 2, 1), 1.0F);
GameRegistry.addSmelting(new ItemStack(Dust, 1, 2).itemID, new ItemStack(Ingot, 1, 1), 1.0F);
FurnaceRecipes.smelting().addSmelting(oreBlockID, 0, new ItemStack(Ingot, 1, 1), 1.0F);
FurnaceRecipes.smelting().addSmelting(Dust.shiftedIndex, 2, new ItemStack(Ingot, 1, 1), 1.0F);
//Enrichment Chamber Recipes
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Dust, 1, 4), new ItemStack(Item.diamond));

View file

@ -101,7 +101,7 @@ public final class MekanismHooks
return (ItemStack)ret;
}
else {
return null;
throw new Exception();
}
} catch(Exception e) {
System.out.println("[Mekanism] Unable to retrieve IC2 item " + name + ".");
@ -126,7 +126,7 @@ public final class MekanismHooks
return new ItemStack((Item)ret);
}
else {
return null;
throw new Exception();
}
} catch(Exception e) {
System.out.println("[Mekanism] Unable to retrieve IC2 item " + name + ".");
@ -146,7 +146,7 @@ public final class MekanismHooks
return new ItemStack((Item)ret);
}
else {
return null;
throw new Exception();
}
} catch(Exception e) {
System.out.println("[Mekanism] Unable to retrieve Forestry item " + name + ".");

View file

@ -27,7 +27,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
* @author AidanBrady
*
*/
public class MekanismUtils
public final class MekanismUtils
{
/**
* Checks for a new version of Mekanism.

View file

@ -45,7 +45,7 @@ public class PacketHandler implements IPacketHandler
if(packetType == EnumPacketType.TIME.id)
{
System.out.println("[Mekanism] Received time update packet from " + entityplayer.username + ".");
MekanismUtils.setHourForward(FMLServerHandler.instance().getServer().worldServerForDimension(0), dataStream.readInt());
MekanismUtils.setHourForward(entityplayer.worldObj, dataStream.readInt());
}
if(packetType == EnumPacketType.WEATHER.id)
{

View file

@ -101,7 +101,11 @@ public abstract class TileEntityBasicBlock extends TileEntityDisableable impleme
}
initialized = false;
facing = direction;
if(canSetFacing(direction))
{
facing = direction;
}
sendPacket();
@ -111,6 +115,16 @@ public abstract class TileEntityBasicBlock extends TileEntityDisableable impleme
}
initialized = true;
}
/**
* Whether or not this block's orientation can be changed to a specific direction. True by default.
* @param facing - facing to check
* @return if the block's orientation can be changed
*/
public boolean canSetFacing(int facing)
{
return true;
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer)

View file

@ -294,6 +294,12 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
{
return true;
}
@Override
public boolean canSetFacing(int facing)
{
return facing != 0 && facing != 1;
}
@Override
public void attach(IComputerAccess computer, String computerSide) {}

View file

@ -1,5 +1,7 @@
package mekanism.generators.common;
import ic2.api.EnergyNet;
import java.util.List;
import java.util.Random;
@ -124,15 +126,19 @@ public class BlockGenerator extends BlockContainer
{
if(side == 3)
{
return 5;
return 10;
}
else if(side == 1)
{
return 3;
}
else {
else if(side == 0)
{
return 4;
}
else {
return 11;
}
}
else if(meta == 2)
{
@ -184,15 +190,19 @@ public class BlockGenerator extends BlockContainer
{
if(side == tileEntity.facing)
{
return 5;
return 10;
}
else if(side == 1)
{
return 3;
}
else {
else if(side == 0)
{
return 4;
}
else {
return 11;
}
}
else if(metadata == 2)
{
@ -314,6 +324,11 @@ public class BlockGenerator extends BlockContainer
entityItem.motionZ = machineRand.nextGaussian() * motion;
world.spawnEntityInWorld(entityItem);
if(Mekanism.hooks.IC2Loaded)
{
EnergyNet.getForWorld(tileEntity.worldObj).removeTileEntity(tileEntity);
}
if(tileEntity instanceof IMultiBlock)
{
((IMultiBlock)tileEntity).onDestroy(tileEntity);
@ -426,7 +441,7 @@ public class BlockGenerator extends BlockContainer
return null;
}
/*@Override
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
@ -438,7 +453,7 @@ public class BlockGenerator extends BlockContainer
else {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}*/
}
public static enum GeneratorType
{

View file

@ -142,6 +142,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank
return bioFuelSlot.liquidStored*i / bioFuelSlot.MAX_LIQUID;
}
@Override
public boolean canSetFacing(int facing)
{
return facing != 0 && facing != 1;
}
@Override
public void handlePacketData(INetworkManager network, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{

View file

@ -10,6 +10,7 @@ import com.google.common.io.ByteArrayDataInput;
import dan200.computer.api.IComputerAccess;
import mekanism.common.PacketHandler;
import mekanism.generators.common.BlockGenerator.GeneratorType;
import net.minecraft.src.*;
public class TileEntitySolarGenerator extends TileEntityGenerator
@ -34,6 +35,12 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
inventory = new ItemStack[1];
}
@Override
public boolean canSetFacing(int facing)
{
return facing != 0 && facing != 1;
}
@Override
public void onUpdate()
{
@ -64,6 +71,11 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
else {
seesSun = false;
}
if(worldObj.getBlockId(xCoord, yCoord+1, zCoord) == MekanismGenerators.generatorID && worldObj.getBlockMetadata(xCoord, yCoord+1, zCoord) == GeneratorType.SOLAR_GENERATOR.meta)
{
seesSun = false;
}
}
if(canOperate())

View file

@ -7,9 +7,9 @@ import net.minecraft.src.*;
public class ItemMekanismArmor extends ItemArmor
{
public ItemMekanismArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4)
public ItemMekanismArmor(int id, EnumArmorMaterial par2EnumArmorMaterial, int renderIndex, int armorType)
{
super(par1, par2EnumArmorMaterial, par3, par4);
super(id, par2EnumArmorMaterial, renderIndex, armorType);
setCreativeTab(Mekanism.tabMekanism);
}

View file

@ -9,21 +9,21 @@ public class ItemMekanismAxe extends ItemMekanismTool
{
private static Block blocksEffectiveAgainst[];
public ItemMekanismAxe(int par1, EnumToolMaterial par2EnumToolMaterial)
public ItemMekanismAxe(int id, EnumToolMaterial enumtoolmaterial)
{
super(par1, 3, par2EnumToolMaterial, blocksEffectiveAgainst);
super(id, 3, enumtoolmaterial, blocksEffectiveAgainst);
}
@Override
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
public float getStrVsBlock(ItemStack itemstack, Block block)
{
if (par2Block != null && par2Block.blockMaterial == Material.wood)
if (block != null && block.blockMaterial == Material.wood)
{
return efficiencyOnProperMaterial;
}
else
{
return super.getStrVsBlock(par1ItemStack, par2Block);
return super.getStrVsBlock(itemstack, block);
}
}

View file

@ -13,27 +13,27 @@ import net.minecraftforge.event.entity.player.UseHoeEvent;
public class ItemMekanismHoe extends ItemMekanism
{
protected EnumToolMaterial theToolMaterial;
protected EnumToolMaterial toolMaterial;
public ItemMekanismHoe(int id, EnumToolMaterial par2EnumToolMaterial)
public ItemMekanismHoe(int id, EnumToolMaterial enumtoolmaterial)
{
super(id);
theToolMaterial = par2EnumToolMaterial;
toolMaterial = enumtoolmaterial;
maxStackSize = 1;
setMaxDamage(par2EnumToolMaterial.getMaxUses());
setMaxDamage(enumtoolmaterial.getMaxUses());
setCreativeTab(CreativeTabs.tabTools);
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ)
{
if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
if (!entityplayer.canPlayerEdit(x, y, z, side, itemstack))
{
return false;
}
else
{
UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
@ -41,38 +41,38 @@ public class ItemMekanismHoe extends ItemMekanism
if (event.getResult() == Result.ALLOW)
{
par1ItemStack.damageItem(1, par2EntityPlayer);
itemstack.damageItem(1, entityplayer);
return true;
}
int var11 = par3World.getBlockId(par4, par5, par6);
int var12 = par3World.getBlockId(par4, par5 + 1, par6);
int blockID = world.getBlockId(x, y, z);
int aboveBlockID = world.getBlockId(x, y + 1, z);
if ((par7 == 0 || var12 != 0 || var11 != Block.grass.blockID) && var11 != Block.dirt.blockID)
if ((side == 0 || aboveBlockID != 0 || blockID != Block.grass.blockID) && blockID != Block.dirt.blockID)
{
return false;
}
else
{
Block var13 = Block.tilledField;
par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var13.stepSound.getStepSound(), (var13.stepSound.getVolume() + 1.0F) / 2.0F, var13.stepSound.getPitch() * 0.8F);
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);
if (par3World.isRemote)
if (world.isRemote)
{
return true;
}
else
{
par3World.setBlockWithNotify(par4, par5, par6, var13.blockID);
par1ItemStack.damageItem(1, par2EntityPlayer);
world.setBlockWithNotify(x, y, z, block.blockID);
itemstack.damageItem(1, entityplayer);
return true;
}
}
}
}
@SideOnly(Side.CLIENT)
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;

View file

@ -94,7 +94,7 @@ public class ItemMekanismKnife extends ItemMekanism
}
@Override
public boolean onBlockDestroyed(ItemStack itemstack, World world, int i, int j, int k, int l, EntityLiving entityliving)
public boolean onBlockDestroyed(ItemStack itemstack, World world, int x, int y, int z, int side, EntityLiving entityliving)
{
itemstack.damageItem(blockDamage, entityliving);
return true;

View file

@ -10,62 +10,62 @@ public class ItemMekanismPickaxe extends ItemMekanismTool
{
private static Block blocksEffectiveAgainst[];
public ItemMekanismPickaxe(int par1, EnumToolMaterial par2EnumToolMaterial)
public ItemMekanismPickaxe(int id, EnumToolMaterial enumtoolmaterial)
{
super(par1, 2, par2EnumToolMaterial, blocksEffectiveAgainst);
super(id, 2, enumtoolmaterial, blocksEffectiveAgainst);
}
@Override
public boolean canHarvestBlock(Block par1Block)
public boolean canHarvestBlock(Block block)
{
if (par1Block == Block.obsidian)
if (block == Block.obsidian)
{
return toolMaterial.getHarvestLevel() == 3;
}
if (par1Block == Block.blockDiamond || par1Block == Block.oreDiamond)
if (block == Block.blockDiamond || block == Block.oreDiamond)
{
return toolMaterial.getHarvestLevel() >= 2;
}
if (par1Block == Block.blockGold || par1Block == Block.oreGold)
if (block == Block.blockGold || block == Block.oreGold)
{
return toolMaterial.getHarvestLevel() >= 2;
}
if (par1Block == Block.blockSteel || par1Block == Block.oreIron)
if (block == Block.blockSteel || block == Block.oreIron)
{
return toolMaterial.getHarvestLevel() >= 1;
}
if (par1Block == Block.blockLapis || par1Block == Block.oreLapis)
if (block == Block.blockLapis || block == Block.oreLapis)
{
return toolMaterial.getHarvestLevel() >= 1;
}
if (par1Block == Block.oreRedstone || par1Block == Block.oreRedstoneGlowing)
if (block == Block.oreRedstone || block == Block.oreRedstoneGlowing)
{
return toolMaterial.getHarvestLevel() >= 2;
}
if (par1Block.blockMaterial == Material.rock)
if (block.blockMaterial == Material.rock)
{
return true;
}
return par1Block.blockMaterial == Material.iron;
return block.blockMaterial == Material.iron;
}
@Override
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
public float getStrVsBlock(ItemStack itemstack, Block block)
{
if (par2Block != null && (par2Block.blockMaterial == Material.iron || par2Block.blockMaterial == Material.rock))
if (block != null && (block.blockMaterial == Material.iron || block.blockMaterial == Material.rock))
{
return efficiencyOnProperMaterial;
}
else
{
return super.getStrVsBlock(par1ItemStack, par2Block);
return super.getStrVsBlock(itemstack, block);
}
}

View file

@ -8,20 +8,20 @@ public class ItemMekanismSpade extends ItemMekanismTool
{
private static Block blocksEffectiveAgainst[];
public ItemMekanismSpade(int par1, EnumToolMaterial par2EnumToolMaterial)
public ItemMekanismSpade(int id, EnumToolMaterial enumtoolmaterial)
{
super(par1, 1, par2EnumToolMaterial, blocksEffectiveAgainst);
super(id, 1, enumtoolmaterial, blocksEffectiveAgainst);
}
@Override
public boolean canHarvestBlock(Block par1Block)
public boolean canHarvestBlock(Block block)
{
if (par1Block == Block.snow)
if (block == Block.snow)
{
return true;
}
return par1Block == Block.blockSnow;
return block == Block.blockSnow;
}
static

View file

@ -19,19 +19,19 @@ public class ItemMekanismSword extends ItemMekanism
private int weaponDamage;
private final EnumToolMaterial toolMaterial;
public ItemMekanismSword(int par1, EnumToolMaterial par2EnumToolMaterial)
public ItemMekanismSword(int id, EnumToolMaterial enumtoolmaterial)
{
super(par1);
toolMaterial = par2EnumToolMaterial;
super(id);
toolMaterial = enumtoolmaterial;
maxStackSize = 1;
setMaxDamage(par2EnumToolMaterial.getMaxUses());
weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity();
setMaxDamage(enumtoolmaterial.getMaxUses());
weaponDamage = 4 + enumtoolmaterial.getDamageVsEntity();
}
@Override
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
public float getStrVsBlock(ItemStack itemstack, Block block)
{
return par2Block.blockID != Block.web.blockID ? 1.5F : 15F;
return block.blockID != Block.web.blockID ? 1.5F : 15F;
}
@Override
@ -41,21 +41,21 @@ public class ItemMekanismSword extends ItemMekanism
}
@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
public boolean hitEntity(ItemStack itemstack, EntityLiving entityplayer, EntityLiving entityliving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
itemstack.damageItem(1, entityliving);
return true;
}
@Override
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
public boolean onBlockDestroyed(ItemStack itemstack, World world, int x, int y, int z, int facing, EntityLiving entityplayer)
{
par1ItemStack.damageItem(2, par7EntityLiving);
itemstack.damageItem(2, entityplayer);
return true;
}
@Override
public int getDamageVsEntity(Entity par1Entity)
public int getDamageVsEntity(Entity entity)
{
return weaponDamage;
}
@ -67,28 +67,28 @@ public class ItemMekanismSword extends ItemMekanism
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
public EnumAction getItemUseAction(ItemStack itemstack)
{
return EnumAction.block;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
public int getMaxItemUseDuration(ItemStack itemstack)
{
return 0x11940;
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack));
return itemstack;
}
@Override
public boolean canHarvestBlock(Block par1Block)
public boolean canHarvestBlock(Block block)
{
return par1Block.blockID == Block.web.blockID;
return block.blockID == Block.web.blockID;
}
@Override

View file

@ -31,14 +31,16 @@ public class MekanismTools
//Enums: Tools
public static EnumToolMaterial toolOBSIDIAN = EnumHelper.addToolMaterial("OBSIDIAN", 3, 2500, 20F, 10, 50);
public static EnumToolMaterial toolOBSIDIAN2 = EnumHelper.addToolMaterial("OBSIDIAN2", 3, 3000, 25F, 10, 100);
public static EnumToolMaterial toolLAZULI = EnumHelper.addToolMaterial("LAZULI", 2, 200, 5.0F, 0, 22);
public static EnumToolMaterial toolLAZULI2 = EnumHelper.addToolMaterial("LAZULI2", 2, 250, 6.0F, 4, 50);
public static EnumToolMaterial toolLAZULI = EnumHelper.addToolMaterial("LAZULI", 2, 200, 5F, 2, 22);
public static EnumToolMaterial toolLAZULI2 = EnumHelper.addToolMaterial("LAZULI2", 2, 250, 6F, 4, 50);
public static EnumToolMaterial toolPLATINUM = EnumHelper.addToolMaterial("PLATINUM", 2, 500, 10F, 4, 30);
public static EnumToolMaterial toolPLATINUM2 = EnumHelper.addToolMaterial("PLATINUM2", 3, 700, 12F, 5, 40);
public static EnumToolMaterial toolREDSTONE = EnumHelper.addToolMaterial("REDSTONE", 2, 250, 10F, 6, 50);
public static EnumToolMaterial toolREDSTONE2 = EnumHelper.addToolMaterial("REDSTONE2", 2, 400, 12F, 6, 60);
public static EnumToolMaterial toolGLOWSTONE = EnumHelper.addToolMaterial("GLOWSTONE", 2, 300, 14, 5, 80);
public static EnumToolMaterial toolGLOWSTONE2 = EnumHelper.addToolMaterial("GLOWSTONE2", 2, 450, 18, 5, 100);
public static EnumToolMaterial toolGLOWSTONE = EnumHelper.addToolMaterial("GLOWSTONE", 2, 300, 14F, 5, 80);
public static EnumToolMaterial toolGLOWSTONE2 = EnumHelper.addToolMaterial("GLOWSTONE2", 2, 450, 18F, 5, 100);
public static EnumToolMaterial toolSTEEL = EnumHelper.addToolMaterial("STEEL", 3, 850, 14F, 4, 100);
public static EnumToolMaterial toolSTEEL2 = EnumHelper.addToolMaterial("STEEL2", 3, 1250, 18F, 8, 100);
//Enums: Armor
public static EnumArmorMaterial armorOBSIDIAN = EnumHelper.addArmorMaterial("OBSIDIAN", 50, new int[]{5, 12, 8, 5}, 50);
@ -46,6 +48,7 @@ public class MekanismTools
public static EnumArmorMaterial armorPLATINUM = EnumHelper.addArmorMaterial("PLATINUM", 30, new int[]{4, 10, 7, 4}, 50);
public static EnumArmorMaterial armorREDSTONE = EnumHelper.addArmorMaterial("REDSTONE", 16, new int[]{2, 7, 5, 3}, 50);
public static EnumArmorMaterial armorGLOWSTONE = EnumHelper.addArmorMaterial("GLOWSTONE", 18, new int[]{3, 7, 6, 3}, 50);
public static EnumArmorMaterial armorSTEEL = EnumHelper.addArmorMaterial("STEEL", 40, new int[] {4, 11, 8, 4}, 50);
//Base Items
public static Item WoodPaxel;
@ -124,6 +127,19 @@ public class MekanismTools
public static Item LazuliBoots;
public static Item LazuliKnife;
//Steel Items
public static Item SteelPaxel;
public static Item SteelPickaxe;
public static Item SteelAxe;
public static Item SteelSpade;
public static Item SteelHoe;
public static Item SteelSword;
public static Item SteelHelmet;
public static Item SteelBody;
public static Item SteelLegs;
public static Item SteelBoots;
public static Item SteelKnife;
@Init
public void init(FMLInitializationEvent event)
{
@ -599,8 +615,8 @@ public class MekanismTools
public void addEntities()
{
EntityRegistry.registerModEntity(EntityKnife.class, "Knife", 52, this, 40, 5, true);
EntityRegistry.registerGlobalEntityID(EntityKnife.class, "Knife", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerModEntity(EntityKnife.class, "Knife", 52, this, 40, 5, true);
}
@ForgeSubscribe

View file

@ -91,7 +91,12 @@ public class ClientProxy extends CommonProxy
public void loadUtilities()
{
System.out.println("[Mekanism] Beginning utility initiative...");
new ThreadSendData();
if(FMLClientHandler.instance().getClient().gameSettings.snooperEnabled)
{
new ThreadSendData();
}
System.out.println("[Mekanism] Utility initiative complete.");
}

View file

@ -91,6 +91,16 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
public void renderItem(RenderBlocks renderer, int metadata, Block block)
{
block.setBlockBoundsForItemRender();
if(metadata == GeneratorType.SOLAR_GENERATOR.meta)
{
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.4F, 1.0F);
}
else {
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
renderer.func_83018_a(block);
if (renderer.useInventoryTint)
{