Merge branch 'development'
This commit is contained in:
commit
9d1dcdfc72
16 changed files with 163 additions and 258 deletions
8
src/main/java/mekanism/api/IMekWrench.java
Normal file
8
src/main/java/mekanism/api/IMekWrench.java
Normal 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);
|
||||
}
|
|
@ -84,7 +84,7 @@ public class GasStack
|
|||
GasStack stack = new GasStack();
|
||||
stack.read(nbtTags);
|
||||
|
||||
if(stack.getGas() == null)
|
||||
if(stack.getGas() == null || stack.amount <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -750,11 +750,10 @@ public class BlockBasic extends Block
|
|||
}
|
||||
|
||||
@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)))
|
||||
{
|
||||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z);
|
||||
|
||||
float motion = 0.7F;
|
||||
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)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
@ -821,6 +821,7 @@ public class BlockBasic extends Block
|
|||
return valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
|
|
@ -165,7 +165,7 @@ public class BlockCardboardBox extends BlockContainer
|
|||
}
|
||||
|
||||
@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)))
|
||||
{
|
||||
|
|
|
@ -141,7 +141,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
|||
}
|
||||
|
||||
@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()))
|
||||
{
|
||||
|
@ -152,17 +152,14 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
|||
{
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z);
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
|
||||
{
|
||||
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z))
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
|
@ -170,38 +167,16 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
|||
return true;
|
||||
}
|
||||
|
||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
||||
((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;
|
||||
}
|
||||
int change = ForgeDirection.ROTATION_MATRIX[side][tileEntity.facing];
|
||||
|
||||
tileEntity.setFacing((short)change);
|
||||
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
|
@ -211,12 +186,12 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@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)))
|
||||
{
|
||||
|
@ -327,6 +302,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
@ -345,6 +321,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
|||
return valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
|
|
@ -8,6 +8,8 @@ import mekanism.common.ItemAttacher;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityGasTank;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -31,8 +33,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class BlockGasTank extends BlockContainer
|
||||
{
|
||||
public Random machineRand = new Random();
|
||||
|
||||
public BlockGasTank()
|
||||
{
|
||||
super(Material.iron);
|
||||
|
@ -81,7 +81,7 @@ public class BlockGasTank extends BlockContainer
|
|||
}
|
||||
|
||||
@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()))
|
||||
{
|
||||
|
@ -94,15 +94,12 @@ public class BlockGasTank extends BlockContainer
|
|||
}
|
||||
|
||||
TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z);
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
|
||||
{
|
||||
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z))
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
|
@ -110,32 +107,16 @@ public class BlockGasTank extends BlockContainer
|
|||
return true;
|
||||
}
|
||||
|
||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
||||
((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;
|
||||
}
|
||||
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
|
||||
|
||||
tileEntity.setFacing((short)change);
|
||||
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
|
@ -149,7 +130,7 @@ public class BlockGasTank extends BlockContainer
|
|||
}
|
||||
|
||||
@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)))
|
||||
{
|
||||
|
@ -238,6 +219,7 @@ public class BlockGasTank extends BlockContainer
|
|||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
@ -256,6 +238,7 @@ public class BlockGasTank extends BlockContainer
|
|||
return valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
|
|
@ -641,7 +641,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
}
|
||||
|
||||
@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()))
|
||||
{
|
||||
|
@ -660,9 +660,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
|
||||
{
|
||||
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z))
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
|
||||
{
|
||||
if(entityplayer.isSneaking() && metadata != 13)
|
||||
{
|
||||
|
@ -670,25 +668,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
return true;
|
||||
}
|
||||
|
||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
||||
((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;
|
||||
}
|
||||
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
|
||||
|
||||
if(tileEntity instanceof TileEntityLogisticalSorter)
|
||||
{
|
||||
|
@ -698,7 +681,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
{
|
||||
TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world);
|
||||
|
||||
if(tileEntity instanceof IInventory)
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
change = dir.getOpposite().ordinal();
|
||||
break;
|
||||
|
@ -712,7 +695,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
|
@ -829,7 +811,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
}
|
||||
|
||||
@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)))
|
||||
{
|
||||
|
@ -1280,6 +1262,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
@ -1298,6 +1281,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
return valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Random;
|
|||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.IMekWrench;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.IInvConfiguration;
|
||||
import mekanism.common.Mekanism;
|
||||
|
@ -31,7 +32,7 @@ import cpw.mods.fml.common.Optional.Interface;
|
|||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
@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_ITEM_DUMP = 8;
|
||||
|
@ -48,19 +49,6 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
{
|
||||
super.addInformation(itemstack, entityplayer, list, flag);
|
||||
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
|
||||
|
@ -71,20 +59,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
Block block = world.getBlock(x, y, z);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof IConfigurable)
|
||||
{
|
||||
IConfigurable config = (IConfigurable)tile;
|
||||
|
||||
if(player.isSneaking())
|
||||
{
|
||||
config.onSneakRightClick(player, side);
|
||||
}
|
||||
else {
|
||||
config.onRightClick(player, side);
|
||||
}
|
||||
}
|
||||
|
||||
if(getState(stack) == 0)
|
||||
if(getState(stack) == 0) //Configurate
|
||||
{
|
||||
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 if(getState(stack) == 1)
|
||||
else {
|
||||
return config.onRightClick(player, side);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(getState(stack) == 1) //Empty
|
||||
{
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
int itemAmount = 0;
|
||||
IInventory inv = (IInventory)tile;
|
||||
|
||||
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);
|
||||
List<ForgeDirection> l = Arrays.asList(block.getValidRotations(world, x, y, z));
|
||||
|
@ -189,16 +175,9 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
|
||||
return true;
|
||||
}
|
||||
else if(getState(stack) == 3)
|
||||
else if(getState(stack) == 3) //Wrench
|
||||
{
|
||||
if(!world.isRemote && player.isSneaking())
|
||||
{
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,13 +189,13 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
switch(state)
|
||||
{
|
||||
case 0:
|
||||
return MekanismUtils.localize("tooltip.configurator.modify");
|
||||
return MekanismUtils.localize("tooltip.configurator.configurate");
|
||||
case 1:
|
||||
return MekanismUtils.localize("tooltip.configurator.empty");
|
||||
case 2:
|
||||
return MekanismUtils.localize("tooltip.configurator.wrench");
|
||||
return MekanismUtils.localize("tooltip.configurator.rotate");
|
||||
case 3:
|
||||
return MekanismUtils.localize("tooltip.configurator.link");
|
||||
return MekanismUtils.localize("tooltip.configurator.wrench");
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
|
@ -266,36 +245,6 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
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
|
||||
public boolean canSend(ItemStack itemStack)
|
||||
{
|
||||
|
@ -306,10 +255,22 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
@Method(modid = "BuildCraftAPI|tools")
|
||||
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
|
||||
@Method(modid = "BuildCraftAPI|tools")
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.common.Tier;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.multipart.TransmitterType.Size;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -424,7 +426,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
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;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import net.minecraftforge.fluids.FluidTank;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
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_SOLARS = 4;
|
||||
|
@ -626,18 +626,6 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
|||
return startPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakRightClick(EntityPlayer player, int side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(EntityPlayer player, int side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
{
|
||||
|
|
|
@ -237,17 +237,15 @@ public final class CableUtils
|
|||
{
|
||||
double sent = 0;
|
||||
boolean tryAgain = false;
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
tryAgain = false;
|
||||
|
||||
double prev = sent;
|
||||
sent += emit_do(emitter, outputtingSides, energyToSend-sent, tryAgain);
|
||||
|
||||
if(energyToSend-sent > 0 && sent-prev > 0)
|
||||
{
|
||||
tryAgain = true;
|
||||
}
|
||||
tryAgain = energyToSend-sent > 0 && sent-prev > 0 && i < 100;
|
||||
|
||||
i++;
|
||||
} while(tryAgain);
|
||||
|
||||
emitter.setEnergy(emitter.getEnergy() - sent);
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import mekanism.api.Chunk3D;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IMekWrench;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.EnergyDisplay;
|
||||
|
@ -70,9 +71,12 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
/**
|
||||
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
||||
* @author AidanBrady
|
||||
|
@ -628,7 +632,7 @@ public final class MekanismUtils
|
|||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
GUI("gui"),
|
||||
|
|
|
@ -3,6 +3,7 @@ package mekanism.generators.common.block;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.IMekWrench;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IBoundingBlock;
|
||||
|
@ -12,6 +13,7 @@ import mekanism.common.ISustainedInventory;
|
|||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.ItemAttacher;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.integration.MekanismHooks;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityElectricBlock;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -293,7 +295,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
}
|
||||
|
||||
@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()))
|
||||
{
|
||||
|
@ -310,7 +312,9 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
|
||||
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())
|
||||
{
|
||||
|
@ -318,25 +322,10 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
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;
|
||||
|
||||
switch(tileEntity.facing)
|
||||
{
|
||||
case 3:
|
||||
change = 5;
|
||||
break;
|
||||
case 5:
|
||||
change = 2;
|
||||
break;
|
||||
case 2:
|
||||
change = 4;
|
||||
break;
|
||||
case 4:
|
||||
change = 3;
|
||||
break;
|
||||
}
|
||||
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
|
||||
|
||||
tileEntity.setFacing((short)change);
|
||||
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(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != facing)
|
||||
if(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -430,12 +419,10 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
}
|
||||
|
||||
@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)))
|
||||
{
|
||||
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(x, y, z);
|
||||
|
||||
float motion = 0.7F;
|
||||
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
|
@ -464,7 +451,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
electricItem.setEnergy(itemStack, tileEntity.electricityStored);
|
||||
|
||||
ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem();
|
||||
inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack);
|
||||
inventory.setInventory(tileEntity.getInventory(), itemStack);
|
||||
|
||||
if(tileEntity instanceof ISustainedData)
|
||||
{
|
||||
|
@ -615,6 +602,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
@ -633,6 +621,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
return valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
|
|
@ -290,6 +290,6 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
|||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
fuelTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("fuelTank")));
|
||||
fuelTank.read(itemStack.stackTagCompound.getCompoundTag("fuelTank"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -440,10 +440,10 @@ gui.digitalMiner.inverse=Inverse mode
|
|||
recipe.mekanismShaped=Shaped
|
||||
|
||||
//Item and block tooltip text
|
||||
tooltip.configurator.modify=Modify
|
||||
tooltip.configurator.configurate=Configurate
|
||||
tooltip.configurator.empty=Empty
|
||||
tooltip.configurator.rotate=Rotate
|
||||
tooltip.configurator.wrench=Wrench
|
||||
tooltip.configurator.link=Link
|
||||
tooltip.configurator.pumpReset=Reset Electric Pump calculation
|
||||
tooltip.configurator.toggleDiverter=Diverter mode changed to
|
||||
tooltip.configurator.toggleColor=Color bumped to
|
||||
|
|
Loading…
Reference in a new issue