Merge branch 'development' into 1.8
Conflicts: src/main/java/mekanism/common/tile/TileEntitySalinationController.java src/main/java/mekanism/common/util/MekanismUtils.java src/main/java/mekanism/generators/common/block/BlockGenerator.java
This commit is contained in:
commit
514b6962d2
12 changed files with 138 additions and 231 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;
|
||||
}
|
||||
|
|
|
@ -756,7 +756,6 @@ public class BlockBasic extends Block
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -140,7 +140,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()))
|
||||
{
|
||||
|
@ -151,66 +151,41 @@ 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)
|
||||
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(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z))
|
||||
{
|
||||
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);
|
||||
dismantleBlock(world, x, y, z, false);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import mekanism.common.MekanismBlocks;
|
|||
import mekanism.common.base.ISustainedInventory;
|
||||
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;
|
||||
|
@ -30,8 +32,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class BlockGasTank extends BlockContainer
|
||||
{
|
||||
public Random machineRand = new Random();
|
||||
|
||||
public BlockGasTank()
|
||||
{
|
||||
super(Material.iron);
|
||||
|
@ -80,7 +80,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()))
|
||||
{
|
||||
|
@ -93,46 +93,27 @@ 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(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);
|
||||
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);
|
||||
dismantleBlock(world, x, y, z, false);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -667,7 +667,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()))
|
||||
{
|
||||
|
@ -686,57 +686,39 @@ 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(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);
|
||||
|
||||
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:
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
change = dir.getOpposite().ordinal();
|
||||
break;
|
||||
}
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
change = dir.getOpposite().ordinal();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.Mekanism;
|
||||
import mekanism.common.base.IInvConfiguration;
|
||||
|
@ -30,7 +31,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;
|
||||
|
@ -47,19 +48,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
|
||||
|
@ -70,20 +58,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)
|
||||
{
|
||||
|
@ -111,12 +86,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)
|
||||
{
|
||||
int itemAmount = 0;
|
||||
IInventory inv = (IInventory)tile;
|
||||
|
||||
if(!(inv instanceof TileEntityElectricChest) || (((TileEntityElectricChest)inv).canAccess()))
|
||||
|
@ -173,7 +159,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import mekanism.common.Tier;
|
|||
import mekanism.common.base.ITileNetwork;
|
||||
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;
|
||||
|
@ -464,7 +466,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,6 +18,7 @@ import mekanism.api.Coord4D;
|
|||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.IMekWrench;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.util.EnergyUtils;
|
||||
|
@ -73,9 +74,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
|
||||
|
@ -1272,6 +1276,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"),
|
||||
|
|
|
@ -296,7 +296,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()))
|
||||
{
|
||||
|
@ -313,7 +313,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())
|
||||
{
|
||||
|
@ -321,25 +323,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);
|
||||
|
@ -349,7 +336,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
|
||||
if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(GeneratorsBlocks.Generator, 1, 2)))
|
||||
{
|
||||
if(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != facing)
|
||||
if(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -437,8 +424,6 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
{
|
||||
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;
|
||||
|
@ -467,7 +452,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)
|
||||
{
|
||||
|
|
|
@ -291,6 +291,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"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -466,10 +466,10 @@ gui.digitalMiner.missingBlock=Missing block
|
|||
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