Configurator Overhaul. Modes now more accurately descriptive.
Now only configurates in mode 0, mode 1 unchanged, mode 2 only rotates and mode 3 acts as a buildcraft wrench.
This commit is contained in:
parent
39509fc133
commit
e16a39912e
11 changed files with 191 additions and 219 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);
|
||||
}
|
|
@ -152,71 +152,68 @@ 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 = 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 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)))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
@ -94,46 +96,43 @@ 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 = 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -660,57 +660,55 @@ 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 = 0;
|
||||
|
||||
switch(tileEntity.facing)
|
||||
{
|
||||
case 3:
|
||||
change = 5;
|
||||
break;
|
||||
case 5:
|
||||
change = 2;
|
||||
break;
|
||||
case 2:
|
||||
change = 4;
|
||||
break;
|
||||
case 4:
|
||||
change = 3;
|
||||
break;
|
||||
}
|
||||
switch(tileEntity.facing)
|
||||
{
|
||||
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(tileEntity instanceof TileEntityLogisticalSorter)
|
||||
{
|
||||
if(!((TileEntityLogisticalSorter)tileEntity).hasInventory())
|
||||
{
|
||||
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(tileEntity 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.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 {
|
||||
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()))
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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,7 +322,8 @@ 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;
|
||||
|
||||
|
@ -430,12 +435,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 +467,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 +618,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 +637,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);
|
||||
|
|
|
@ -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