Merge branch 'development'

This commit is contained in:
Ben Spiers 2014-09-05 16:48:41 +01:00
commit 9d1dcdfc72
16 changed files with 163 additions and 258 deletions

View file

@ -0,0 +1,8 @@
package mekanism.api;
import net.minecraft.entity.player.EntityPlayer;
public interface IMekWrench
{
public boolean canUseWrench(EntityPlayer player, int x, int y, int z);
}

View file

@ -84,7 +84,7 @@ public class GasStack
GasStack stack = new GasStack(); GasStack stack = new GasStack();
stack.read(nbtTags); stack.read(nbtTags);
if(stack.getGas() == null) if(stack.getGas() == null || stack.amount <= 0)
{ {
return null; return null;
} }

View file

@ -750,11 +750,10 @@ public class BlockBasic extends Block
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{ {
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{ {
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z);
float motion = 0.7F; float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
@ -803,6 +802,7 @@ public class BlockBasic extends Block
} }
} }
@Override
public ForgeDirection[] getValidRotations(World world, int x, int y, int z) public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
@ -821,6 +821,7 @@ public class BlockBasic extends Block
return valid; return valid;
} }
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);

View file

@ -165,7 +165,7 @@ public class BlockCardboardBox extends BlockContainer
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{ {
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{ {

View file

@ -141,7 +141,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float f1, float f2, float f3)
{ {
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
{ {
@ -152,71 +152,46 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
{ {
return true; return true;
} }
else {
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
if(entityplayer.getCurrentEquippedItem() != null) TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z);
if(entityplayer.getCurrentEquippedItem() != null)
{
Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
{ {
Item tool = entityplayer.getCurrentEquippedItem().getItem(); if(entityplayer.isSneaking())
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
{ {
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) dismantleBlock(world, x, y, z, false);
{
if(entityplayer.isSneaking())
{
dismantleBlock(world, x, y, z, false);
return true;
}
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
int change = 0;
switch(tileEntity.facing)
{
case 3:
change = 5;
break;
case 5:
change = 2;
break;
case 2:
change = 4;
break;
case 4:
change = 1;
break;
case 1:
change = 0;
break;
case 0:
change = 3;
break;
}
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
}
}
}
if(tileEntity != null)
{
if(!entityplayer.isSneaking())
{
entityplayer.openGui(Mekanism.instance, 8, world, x, y, z);
return true; return true;
} }
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
int change = ForgeDirection.ROTATION_MATRIX[side][tileEntity.facing];
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
} }
} }
if(tileEntity != null)
{
if(!entityplayer.isSneaking())
{
entityplayer.openGui(Mekanism.instance, 8, world, x, y, z);
return true;
}
}
return false; return false;
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{ {
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{ {
@ -327,6 +302,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
return true; return true;
} }
@Override
public ForgeDirection[] getValidRotations(World world, int x, int y, int z) public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
@ -345,6 +321,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
return valid; return valid;
} }
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);

View file

@ -8,6 +8,8 @@ import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.tile.TileEntityBasicBlock; import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityGasTank; import mekanism.common.tile.TileEntityGasTank;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -31,8 +33,6 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockGasTank extends BlockContainer public class BlockGasTank extends BlockContainer
{ {
public Random machineRand = new Random();
public BlockGasTank() public BlockGasTank()
{ {
super(Material.iron); super(Material.iron);
@ -81,7 +81,7 @@ public class BlockGasTank extends BlockContainer
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float playerX, float playerY, float playerZ)
{ {
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
{ {
@ -94,46 +94,27 @@ public class BlockGasTank extends BlockContainer
} }
TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z); TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
if(entityplayer.getCurrentEquippedItem() != null) if(entityplayer.getCurrentEquippedItem() != null)
{ {
Item tool = entityplayer.getCurrentEquippedItem().getItem(); Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
{ {
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) if(entityplayer.isSneaking())
{ {
if(entityplayer.isSneaking()) dismantleBlock(world, x, y, z, false);
{
dismantleBlock(world, x, y, z, false);
return true;
}
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
int change = 0;
switch(tileEntity.facing)
{
case 3:
change = 5;
break;
case 5:
change = 2;
break;
case 2:
change = 4;
break;
case 4:
change = 3;
break;
}
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true; return true;
} }
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
} }
} }
@ -149,7 +130,7 @@ public class BlockGasTank extends BlockContainer
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{ {
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{ {
@ -238,6 +219,7 @@ public class BlockGasTank extends BlockContainer
return itemStack; return itemStack;
} }
@Override
public ForgeDirection[] getValidRotations(World world, int x, int y, int z) public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
@ -256,6 +238,7 @@ public class BlockGasTank extends BlockContainer
return valid; return valid;
} }
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);

View file

@ -641,7 +641,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float posX, float posY, float posZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float posX, float posY, float posZ)
{ {
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
{ {
@ -660,57 +660,39 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
{ {
Item tool = entityplayer.getCurrentEquippedItem().getItem(); Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
{ {
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) if(entityplayer.isSneaking() && metadata != 13)
{ {
if(entityplayer.isSneaking() && metadata != 13) dismantleBlock(world, x, y, z, false);
{ return true;
dismantleBlock(world, x, y, z, false); }
return true;
}
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
int change = 0; int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
switch(tileEntity.facing) if(tileEntity instanceof TileEntityLogisticalSorter)
{
if(!((TileEntityLogisticalSorter)tileEntity).hasInventory())
{ {
case 3: for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
change = 5;
break;
case 5:
change = 2;
break;
case 2:
change = 4;
break;
case 4:
change = 3;
break;
}
if(tileEntity instanceof TileEntityLogisticalSorter)
{
if(!((TileEntityLogisticalSorter)tileEntity).hasInventory())
{ {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world);
{
TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world);
if(tileEntity instanceof IInventory) if(tile instanceof IInventory)
{ {
change = dir.getOpposite().ordinal(); change = dir.getOpposite().ordinal();
break; break;
}
} }
} }
} }
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
} }
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
} }
} }
@ -829,7 +811,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{ {
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{ {
@ -1280,6 +1262,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
return null; return null;
} }
@Override
public ForgeDirection[] getValidRotations(World world, int x, int y, int z) public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
@ -1298,6 +1281,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
return valid; return valid;
} }
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);

View file

@ -8,6 +8,7 @@ import java.util.Random;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.IConfigurable; import mekanism.api.IConfigurable;
import mekanism.api.IMekWrench;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.common.IInvConfiguration; import mekanism.common.IInvConfiguration;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
@ -31,7 +32,7 @@ import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.Optional.Method;
@Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools") @Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools")
public class ItemConfigurator extends ItemEnergized implements IToolWrench public class ItemConfigurator extends ItemEnergized implements IMekWrench, IToolWrench
{ {
public final int ENERGY_PER_CONFIGURE = 400; public final int ENERGY_PER_CONFIGURE = 400;
public final int ENERGY_PER_ITEM_DUMP = 8; public final int ENERGY_PER_ITEM_DUMP = 8;
@ -48,19 +49,6 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
{ {
super.addInformation(itemstack, entityplayer, list, flag); super.addInformation(itemstack, entityplayer, list, flag);
list.add(EnumColor.PINK + MekanismUtils.localize("gui.state") + ": " + EnumColor.GREY + getStateDisplay(getState(itemstack))); list.add(EnumColor.PINK + MekanismUtils.localize("gui.state") + ": " + EnumColor.GREY + getStateDisplay(getState(itemstack)));
if(getState(itemstack) == 3)
{
if(hasLink(itemstack))
{
Coord4D obj = getLink(itemstack);
list.add(EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.linkMsg") + " " + EnumColor.INDIGO + MekanismUtils.getCoordDisplay(obj) + EnumColor.GREY + ", " + MekanismUtils.localize("tooltip.configurator.dim") + " " + EnumColor.INDIGO + obj.dimensionId);
}
else {
list.add(EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.noLink"));
}
}
} }
@Override @Override
@ -71,20 +59,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
Block block = world.getBlock(x, y, z); Block block = world.getBlock(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IConfigurable) if(getState(stack) == 0) //Configurate
{
IConfigurable config = (IConfigurable)tile;
if(player.isSneaking())
{
config.onSneakRightClick(player, side);
}
else {
config.onRightClick(player, side);
}
}
if(getState(stack) == 0)
{ {
if(tile instanceof IInvConfiguration) if(tile instanceof IInvConfiguration)
{ {
@ -112,12 +87,23 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
} }
} }
} }
else if(tile instanceof IConfigurable)
{
IConfigurable config = (IConfigurable)tile;
if(player.isSneaking())
{
return config.onSneakRightClick(player, side);
}
else {
return config.onRightClick(player, side);
}
}
} }
else if(getState(stack) == 1) else if(getState(stack) == 1) //Empty
{ {
if(tile instanceof IInventory) if(tile instanceof IInventory)
{ {
int itemAmount = 0;
IInventory inv = (IInventory)tile; IInventory inv = (IInventory)tile;
if(!(inv instanceof TileEntityElectricChest) || (((TileEntityElectricChest)inv).canAccess())) if(!(inv instanceof TileEntityElectricChest) || (((TileEntityElectricChest)inv).canAccess()))
@ -174,7 +160,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
} }
} }
} }
else if(getState(stack) == 2) else if(getState(stack) == 2) //Rotate
{ {
ForgeDirection axis = ForgeDirection.getOrientation(side); ForgeDirection axis = ForgeDirection.getOrientation(side);
List<ForgeDirection> l = Arrays.asList(block.getValidRotations(world, x, y, z)); List<ForgeDirection> l = Arrays.asList(block.getValidRotations(world, x, y, z));
@ -189,16 +175,9 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
return true; return true;
} }
else if(getState(stack) == 3) else if(getState(stack) == 3) //Wrench
{ {
if(!world.isRemote && player.isSneaking()) return false;
{
Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId);
player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.setLink") + " " + EnumColor.INDIGO + MekanismUtils.getCoordDisplay(obj) + EnumColor.GREY + ", " + MekanismUtils.localize("tooltip.configurator.dim") + " " + EnumColor.INDIGO + obj.dimensionId));
setLink(stack, obj);
return true;
}
} }
} }
@ -210,13 +189,13 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
switch(state) switch(state)
{ {
case 0: case 0:
return MekanismUtils.localize("tooltip.configurator.modify"); return MekanismUtils.localize("tooltip.configurator.configurate");
case 1: case 1:
return MekanismUtils.localize("tooltip.configurator.empty"); return MekanismUtils.localize("tooltip.configurator.empty");
case 2: case 2:
return MekanismUtils.localize("tooltip.configurator.wrench"); return MekanismUtils.localize("tooltip.configurator.rotate");
case 3: case 3:
return MekanismUtils.localize("tooltip.configurator.link"); return MekanismUtils.localize("tooltip.configurator.wrench");
} }
return "unknown"; return "unknown";
@ -266,36 +245,6 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
return state; return state;
} }
public boolean hasLink(ItemStack itemStack)
{
return getLink(itemStack) != null;
}
public Coord4D getLink(ItemStack itemStack)
{
if(itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("position"))
{
return null;
}
return Coord4D.read(itemStack.getTagCompound().getCompoundTag("position"));
}
public void setLink(ItemStack itemStack, Coord4D obj)
{
if(itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.getTagCompound().setTag("position", obj.write(new NBTTagCompound()));
}
public void clearLink(ItemStack itemStack)
{
itemStack.getTagCompound().removeTag("position");
}
@Override @Override
public boolean canSend(ItemStack itemStack) public boolean canSend(ItemStack itemStack)
{ {
@ -306,10 +255,22 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
@Method(modid = "BuildCraftAPI|tools") @Method(modid = "BuildCraftAPI|tools")
public boolean canWrench(EntityPlayer player, int x, int y, int z) public boolean canWrench(EntityPlayer player, int x, int y, int z)
{ {
return !(player.worldObj.getTileEntity(x, y, z) instanceof TileEntityBasicBlock); return canUseWrench(player, x, y, z);
} }
@Override @Override
@Method(modid = "BuildCraftAPI|tools") @Method(modid = "BuildCraftAPI|tools")
public void wrenchUsed(EntityPlayer player, int x, int y, int z) {} public void wrenchUsed(EntityPlayer player, int x, int y, int z) {}
@Override
public boolean canUseWrench(EntityPlayer player, int x, int y, int z)
{
return getState(player.getCurrentEquippedItem()) == 3;
}
@Override
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player)
{
return getState(player.getCurrentEquippedItem()) == 3;
}
} }

View file

@ -21,6 +21,8 @@ import mekanism.common.Mekanism;
import mekanism.common.Tier; import mekanism.common.Tier;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.multipart.TransmitterType.Size; import mekanism.common.multipart.TransmitterType.Size;
import mekanism.common.util.MekanismUtils;
import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -424,7 +426,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
return false; return false;
} }
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && item.getItem() instanceof IToolWrench && !(item.getItem() instanceof ItemConfigurator) && player.isSneaking()) if(MekanismUtils.hasUsableWrench(player, x(), y(), z()) && player.isSneaking())
{ {
if(!world().isRemote) if(!world().isRemote)
{ {

View file

@ -18,7 +18,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import codechicken.multipart.TileMultipart; import codechicken.multipart.TileMultipart;
public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends PartSidedPipe implements IGridTransmitter<N>, IConfigurable public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends PartSidedPipe implements IGridTransmitter<N>
{ {
public N theNetwork; public N theNetwork;

View file

@ -28,7 +28,7 @@ import net.minecraftforge.fluids.FluidTank;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class TileEntitySalinationController extends TileEntitySalinationTank implements IConfigurable public class TileEntitySalinationController extends TileEntitySalinationTank
{ {
public static final int MAX_BRINE = 10000; public static final int MAX_BRINE = 10000;
public static final int MAX_SOLARS = 4; public static final int MAX_SOLARS = 4;
@ -626,18 +626,6 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
return startPoint; return startPoint;
} }
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
return false;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
@Override @Override
public void handlePacketData(ByteBuf dataStream) public void handlePacketData(ByteBuf dataStream)
{ {

View file

@ -237,17 +237,15 @@ public final class CableUtils
{ {
double sent = 0; double sent = 0;
boolean tryAgain = false; boolean tryAgain = false;
int i = 0;
do { do {
tryAgain = false;
double prev = sent; double prev = sent;
sent += emit_do(emitter, outputtingSides, energyToSend-sent, tryAgain); sent += emit_do(emitter, outputtingSides, energyToSend-sent, tryAgain);
if(energyToSend-sent > 0 && sent-prev > 0) tryAgain = energyToSend-sent > 0 && sent-prev > 0 && i < 100;
{
tryAgain = true; i++;
}
} while(tryAgain); } while(tryAgain);
emitter.setEnergy(emitter.getEnergy() - sent); emitter.setEnergy(emitter.getEnergy() - sent);

View file

@ -15,6 +15,7 @@ import java.util.List;
import mekanism.api.Chunk3D; import mekanism.api.Chunk3D;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.IMekWrench;
import mekanism.api.gas.Gas; import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
import mekanism.common.EnergyDisplay; import mekanism.common.EnergyDisplay;
@ -70,9 +71,12 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameData;
import buildcraft.api.tools.IToolWrench;
/** /**
* Utilities used by Mekanism. All miscellaneous methods are located here. * Utilities used by Mekanism. All miscellaneous methods are located here.
* @author AidanBrady * @author AidanBrady
@ -628,7 +632,7 @@ public final class MekanismUtils
*/ */
public static int getSecondaryEnergyPerTick(IUpgradeManagement mgmt, int def) public static int getSecondaryEnergyPerTick(IUpgradeManagement mgmt, int def)
{ {
return def * (int)Math.pow(Mekanism.maxUpgradeMultiplier, mgmt.getSpeedMultiplier()/8.0); return (int)(def * Math.pow(Mekanism.maxUpgradeMultiplier, mgmt.getSpeedMultiplier()/8.0));
} }
/** /**
@ -1345,6 +1349,16 @@ public final class MekanismUtils
return Item.getIdFromItem(itemStack.getItem()); return Item.getIdFromItem(itemStack.getItem());
} }
public static boolean hasUsableWrench(EntityPlayer player, int x, int y, int z)
{
ItemStack tool = player.getCurrentEquippedItem();
if(tool.getItem() instanceof IMekWrench && ((IMekWrench)tool.getItem()).canUseWrench(player, x, y, z))
return true;
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool.getItem() instanceof IToolWrench && ((IToolWrench)tool.getItem()).canWrench(player, x, y, z))
return true;
return false;
}
public static enum ResourceType public static enum ResourceType
{ {
GUI("gui"), GUI("gui"),

View file

@ -3,6 +3,7 @@ package mekanism.generators.common.block;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import mekanism.api.IMekWrench;
import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IEnergizedItem;
import mekanism.common.IActiveState; import mekanism.common.IActiveState;
import mekanism.common.IBoundingBlock; import mekanism.common.IBoundingBlock;
@ -12,6 +13,7 @@ import mekanism.common.ISustainedInventory;
import mekanism.common.ISustainedTank; import mekanism.common.ISustainedTank;
import mekanism.common.ItemAttacher; import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.integration.MekanismHooks;
import mekanism.common.tile.TileEntityBasicBlock; import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityElectricBlock; import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
@ -293,7 +295,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float playerX, float playerY, float playerZ)
{ {
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
{ {
@ -310,7 +312,9 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
if(entityplayer.getCurrentEquippedItem() != null) if(entityplayer.getCurrentEquippedItem() != null)
{ {
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench")) Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
{ {
if(entityplayer.isSneaking()) if(entityplayer.isSneaking())
{ {
@ -318,25 +322,10 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
return true; return true;
} }
((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
int change = 0; int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
switch(tileEntity.facing)
{
case 3:
change = 5;
break;
case 5:
change = 2;
break;
case 2:
change = 4;
break;
case 4:
change = 3;
break;
}
tileEntity.setFacing((short)change); tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this); world.notifyBlocksOfNeighborChange(x, y, z, this);
@ -346,7 +335,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(MekanismGenerators.Generator, 1, 2))) if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(MekanismGenerators.Generator, 1, 2)))
{ {
if(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != facing) if(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != side)
{ {
return false; return false;
} }
@ -430,12 +419,10 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
} }
@Override @Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{ {
if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
{ {
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(x, y, z);
float motion = 0.7F; float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
@ -464,7 +451,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
electricItem.setEnergy(itemStack, tileEntity.electricityStored); electricItem.setEnergy(itemStack, tileEntity.electricityStored);
ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem();
inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); inventory.setInventory(tileEntity.getInventory(), itemStack);
if(tileEntity instanceof ISustainedData) if(tileEntity instanceof ISustainedData)
{ {
@ -615,6 +602,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
return true; return true;
} }
@Override
public ForgeDirection[] getValidRotations(World world, int x, int y, int z) public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
@ -633,6 +621,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
return valid; return valid;
} }
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);

View file

@ -290,6 +290,6 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
@Override @Override
public void readSustainedData(ItemStack itemStack) public void readSustainedData(ItemStack itemStack)
{ {
fuelTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("fuelTank"))); fuelTank.read(itemStack.stackTagCompound.getCompoundTag("fuelTank"));
} }
} }

View file

@ -440,10 +440,10 @@ gui.digitalMiner.inverse=Inverse mode
recipe.mekanismShaped=Shaped recipe.mekanismShaped=Shaped
//Item and block tooltip text //Item and block tooltip text
tooltip.configurator.modify=Modify tooltip.configurator.configurate=Configurate
tooltip.configurator.empty=Empty tooltip.configurator.empty=Empty
tooltip.configurator.rotate=Rotate
tooltip.configurator.wrench=Wrench tooltip.configurator.wrench=Wrench
tooltip.configurator.link=Link
tooltip.configurator.pumpReset=Reset Electric Pump calculation tooltip.configurator.pumpReset=Reset Electric Pump calculation
tooltip.configurator.toggleDiverter=Diverter mode changed to tooltip.configurator.toggleDiverter=Diverter mode changed to
tooltip.configurator.toggleColor=Color bumped to tooltip.configurator.toggleColor=Color bumped to