mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 15:33:06 +00:00
Build Craft API is no longer required and is not distributed with EIO
This commit is contained in:
commit
c82ac56a5a
43 files changed
+810
-497
No files matched your search
@@ -26,7 +26,6 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetOmniNode;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
@@ -55,6 +54,8 @@ import crazypants.enderio.conduit.redstone.IRedstoneConduit;
|
||||
import crazypants.enderio.item.ItemConduitProbe;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.util.Util;
|
||||
|
||||
@@ -421,7 +422,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
}
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
@@ -445,8 +446,8 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
//add facade
|
||||
return handleFacadeClick(world, x, y, z, player, bundle, stack);
|
||||
|
||||
} else if(ConduitUtil.isConduitEquipped(player)) {
|
||||
// Add conduit
|
||||
} else if(ConduitUtil.isConduitEquipped(player)) {
|
||||
// Add conduit
|
||||
if(player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
@@ -459,8 +460,8 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
if(handleConduitProbeClick(world, x, y, z, player, bundle, stack)) {
|
||||
return true;
|
||||
}
|
||||
} else if(ConduitUtil.isToolEquipped(player) && player.isSneaking()) {
|
||||
// Break conduit with tool
|
||||
} else if(ToolUtil.isToolEquipped(player) && player.isSneaking()) {
|
||||
// Break conduit with tool
|
||||
if(handleWrenchClick(world, x, y, z, player)) {
|
||||
return true;
|
||||
}
|
||||
@@ -533,14 +534,12 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
}
|
||||
|
||||
private boolean handleWrenchClick(World world, int x, int y, int z, EntityPlayer player) {
|
||||
if(player.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) player.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(player, x, y, z)) {
|
||||
ITool tool = ToolUtil.getEquippedTool(player);
|
||||
if(tool != null) {
|
||||
if(tool.canUse(player.getCurrentEquippedItem(), player, x, y, z)) {
|
||||
if(!world.isRemote) {
|
||||
removedByPlayer(world, player, x, y, z);
|
||||
if(player.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) player.getCurrentEquippedItem().getItem()).wrenchUsed(player, x, y, z);
|
||||
}
|
||||
tool.used(player.getCurrentEquippedItem(), player, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -548,14 +547,14 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean handleConduitProbeClick(World world, int x, int y, int z, EntityPlayer player, IConduitBundle bundle, ItemStack stack) {
|
||||
private boolean handleConduitProbeClick(World world, int x, int y, int z, EntityPlayer player, IConduitBundle bundle, ItemStack stack) {
|
||||
if(stack.getItemDamage() != 1) {
|
||||
return false; //not in copy paste mode
|
||||
}
|
||||
}
|
||||
RaytraceResult rr = doRayTrace(world, x, y, z, player);
|
||||
if(rr == null || rr.component == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ItemConduitProbe.copyPasteSettings(player, stack, bundle, rr.component.dir);
|
||||
}
|
||||
|
||||
@@ -638,7 +637,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) {
|
||||
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) {
|
||||
TileEntity conduit = world.getTileEntity(x, y, z);
|
||||
if(conduit instanceof IConduitBundle) {
|
||||
((IConduitBundle) conduit).onNeighborChange(world, x, y, z, tileX, tileY, tileZ);
|
||||
@@ -819,7 +818,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
return 0;
|
||||
}
|
||||
IConduitBundle cb = (IConduitBundle)te;
|
||||
IConduitBundle cb = (IConduitBundle) te;
|
||||
return cb.getFacadeMetadata();
|
||||
}
|
||||
|
||||
@@ -829,7 +828,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
return this;
|
||||
}
|
||||
IConduitBundle cb = (IConduitBundle)te;
|
||||
IConduitBundle cb = (IConduitBundle) te;
|
||||
Block res = cb.getFacadeId();
|
||||
if(res == null) {
|
||||
return this;
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -45,6 +44,7 @@ import crazypants.enderio.conduit.redstone.IRedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneConduitNetwork;
|
||||
import crazypants.enderio.conduit.redstone.Signal;
|
||||
import crazypants.enderio.machine.RedstoneControlMode;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.DyeColor;
|
||||
|
||||
@@ -177,7 +177,7 @@ public class ConduitUtil {
|
||||
}
|
||||
|
||||
public static boolean isFacadeHidden(IConduitBundle bundle, EntityPlayer player) {
|
||||
return bundle.getFacadeId() != null && (isToolEquipped(player) || isConduitEquipped(player) || isProbeEquipped(player));
|
||||
return bundle.getFacadeId() != null && (ToolUtil.isToolEquipped(player) || isConduitEquipped(player) || isProbeEquipped(player));
|
||||
}
|
||||
|
||||
public static ConduitDisplayMode getDisplayMode(EntityPlayer player) {
|
||||
@@ -246,21 +246,6 @@ public class ConduitUtil {
|
||||
return equipped.getItem() instanceof IConduitItem;
|
||||
}
|
||||
|
||||
public static boolean isToolEquipped(EntityPlayer player) {
|
||||
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
|
||||
if(player == null) {
|
||||
return false;
|
||||
}
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if(equipped == null) {
|
||||
return false;
|
||||
}
|
||||
if(MpsUtil.instance.isPowerFistEquiped(equipped)) {
|
||||
return MpsUtil.instance.isOmniToolActive(equipped);
|
||||
}
|
||||
return equipped.getItem() instanceof IToolWrench;
|
||||
}
|
||||
|
||||
public static boolean isProbeEquipped(EntityPlayer player) {
|
||||
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
|
||||
if(player == null) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public abstract class AbstractGasTankConduit extends AbstractGasConduit {
|
||||
@@ -25,7 +26,7 @@ public abstract class AbstractGasTankConduit extends AbstractGasConduit {
|
||||
return false;
|
||||
}
|
||||
AbstractGasTankConduitNetwork<? extends AbstractGasTankConduit> network = getTankNetwork();
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(ToolUtil.isToolEquipped(player)) {
|
||||
|
||||
if(!getBundle().getEntity().getWorldObj().isRemote) {
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ import mekanism.api.gas.IGasHandler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
|
||||
@@ -261,11 +259,6 @@ public class GasConduitNetwork extends AbstractGasTankConduitNetwork<GasConduit>
|
||||
}
|
||||
TileEntity te = w.getTileEntity(bc.x, bc.y, bc.z);
|
||||
if(te instanceof IGasHandler) {
|
||||
if(te instanceof IPipeTile) {
|
||||
if(((IPipeTile) te).getPipeType() != PipeType.FLUID) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (IGasHandler) te;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package crazypants.enderio.conduit.gas;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.util.BlockCoord;
|
||||
@@ -48,11 +45,6 @@ public final class GasUtil {
|
||||
|
||||
public static IGasHandler getGasHandler(TileEntity te) {
|
||||
if(te instanceof IGasHandler) {
|
||||
if(te instanceof IPipeTile) {
|
||||
if(((IPipeTile) te).getPipeType() != PipeType.FLUID) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (IGasHandler) te;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -30,6 +30,7 @@ import crazypants.enderio.conduit.item.filter.IItemFilter;
|
||||
import crazypants.enderio.conduit.item.filter.ItemFilter;
|
||||
import crazypants.enderio.item.PacketConduitProbe;
|
||||
import crazypants.enderio.machine.RedstoneControlMode;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.DyeColor;
|
||||
@@ -203,7 +204,7 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
PacketConduitProbe.sendInfoMessage(player, this, null);
|
||||
}
|
||||
return true;
|
||||
} else if(ConduitUtil.isToolEquipped(player)) {
|
||||
} else if(ToolUtil.isToolEquipped(player)) {
|
||||
if(!getBundle().getEntity().getWorldObj().isRemote) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
|
||||
@@ -14,6 +14,7 @@ import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
@@ -31,7 +32,7 @@ public abstract class AbstractTankConduit extends AbstractLiquidConduit {
|
||||
return false;
|
||||
}
|
||||
AbstractTankConduitNetwork<? extends AbstractTankConduit> network = getTankNetwork();
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(ToolUtil.isToolEquipped(player)) {
|
||||
|
||||
if(!getBundle().getEntity().getWorldObj().isRemote) {
|
||||
|
||||
|
||||
@@ -4,19 +4,17 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.FluidUtil;
|
||||
|
||||
public class AdvancedLiquidConduitNetwork extends AbstractTankConduitNetwork<AdvancedLiquidConduit> {
|
||||
|
||||
@@ -295,16 +293,7 @@ public class AdvancedLiquidConduitNetwork extends AbstractTankConduitNetwork<Adv
|
||||
if(w == null) {
|
||||
return null;
|
||||
}
|
||||
TileEntity te = w.getTileEntity(bc.x, bc.y, bc.z);
|
||||
if(te instanceof IFluidHandler) {
|
||||
if(te instanceof IPipeTile) {
|
||||
if(((IPipeTile) te).getPipeType() != PipeType.FLUID) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (IFluidHandler) te;
|
||||
}
|
||||
return null;
|
||||
return FluidUtil.getFluidHandler(w.getTileEntity(bc.x, bc.y, bc.z));
|
||||
}
|
||||
|
||||
public IFluidHandler getTankContainer(AdvancedLiquidConduit con, ForgeDirection dir) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
@@ -74,7 +75,7 @@ public class EnderLiquidConduit extends AbstractLiquidConduit {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(ToolUtil.isToolEquipped(player)) {
|
||||
|
||||
if(!getBundle().getEntity().getWorldObj().isRemote) {
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
@@ -222,7 +223,7 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
|
||||
@Override
|
||||
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
|
||||
super.onBlockActivated(player, res, all);
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(ToolUtil.isToolEquipped(player)) {
|
||||
if(!getBundle().getEntity().getWorldObj().isRemote) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
|
||||
@@ -36,6 +36,7 @@ import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.power.IPowerInterface;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.DyeColor;
|
||||
@@ -133,7 +134,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
} else if(col != null && res.component != null && isColorBandRendered(res.component.dir)) {
|
||||
setExtractionSignalColor(res.component.dir, col);
|
||||
return true;
|
||||
} else if(ConduitUtil.isToolEquipped(player)) {
|
||||
} else if(ToolUtil.isToolEquipped(player)) {
|
||||
if(!getBundle().getEntity().getWorldObj().isRemote) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
|
||||
@@ -32,6 +32,8 @@ import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.RedstoneControlMode;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
@@ -83,7 +85,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
if(col != null && res.component != null) {
|
||||
setSignalColor(res.component.dir, col);
|
||||
return true;
|
||||
} else if(ConduitUtil.isToolEquipped(player)) {
|
||||
} else if(ToolUtil.isToolEquipped(player)) {
|
||||
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package crazypants.enderio.fluid;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import buildcraft.api.fuels.BuildcraftFuelRegistry;
|
||||
import buildcraft.api.fuels.ICoolant;
|
||||
import buildcraft.api.fuels.IFuel;
|
||||
import crazypants.enderio.fluid.FluidFuelRegister.CoolantImpl;
|
||||
import crazypants.enderio.fluid.FluidFuelRegister.FuelImpl;
|
||||
|
||||
public class BuildCraftFluidRegister implements IFluidRegister {
|
||||
|
||||
public BuildCraftFluidRegister() throws Exception {
|
||||
//Make it go splat in object construction if an older version of
|
||||
//build craft is installed
|
||||
Class.forName("buildcraft.api.fuels.BuildcraftFuelRegistry");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCoolant(Fluid fluid, float degreesCoolingPerMB) {
|
||||
if(BuildcraftFuelRegistry.coolant != null && BuildcraftFuelRegistry.coolant.getCoolant(fluid) == null) {
|
||||
BuildcraftFuelRegistry.coolant.addCoolant(fluid, degreesCoolingPerMB);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidCoolant getCoolant(Fluid fluid) {
|
||||
if(fluid != null && BuildcraftFuelRegistry.coolant != null) {
|
||||
ICoolant bcCool = BuildcraftFuelRegistry.coolant.getCoolant(fluid);
|
||||
if(bcCool != null) {
|
||||
return new CoolantBC(bcCool);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidCoolant getCoolant(FluidStack fluid) {
|
||||
if(fluid == null || fluid.getFluid() == null) {
|
||||
return null;
|
||||
}
|
||||
return getCoolant(fluid.getFluid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFuel(Fluid fluid, int powerPerCycleRF, int totalBurnTime) {
|
||||
if(BuildcraftFuelRegistry.fuel != null && BuildcraftFuelRegistry.fuel.getFuel(fluid) == null) {
|
||||
BuildcraftFuelRegistry.fuel.addFuel(fluid, powerPerCycleRF, totalBurnTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidFuel getFuel(Fluid fluid) {
|
||||
if(fluid == null) {
|
||||
return null;
|
||||
}
|
||||
if(BuildcraftFuelRegistry.fuel != null) {
|
||||
IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(fluid);
|
||||
if(bcFuel != null) {
|
||||
return new FuelBC(bcFuel);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidFuel getFuel(FluidStack fluid) {
|
||||
if(fluid == null || fluid.getFluid() == null) {
|
||||
return null;
|
||||
}
|
||||
return getFuel(fluid.getFluid());
|
||||
}
|
||||
|
||||
private static class FuelBC extends FuelImpl {
|
||||
|
||||
FuelBC(IFuel fuel) {
|
||||
super(fuel.getFluid(), fuel.getPowerPerCycle(), fuel.getTotalBurningTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class CoolantBC extends CoolantImpl {
|
||||
|
||||
CoolantBC(ICoolant coolant) {
|
||||
//NB: in the current BC impl the temperature to getDegreesCoolingPerMB is ignored
|
||||
super(coolant.getFluid(), coolant.getDegreesCoolingPerMB(100));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +1,104 @@
|
||||
package crazypants.enderio.fluid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import buildcraft.api.fuels.BuildcraftFuelRegistry;
|
||||
import buildcraft.api.fuels.ICoolant;
|
||||
import buildcraft.api.fuels.IFuel;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.Log;
|
||||
|
||||
|
||||
public class FluidFuelRegister {
|
||||
public class FluidFuelRegister implements IFluidRegister {
|
||||
|
||||
public static final FluidFuelRegister instance = new FluidFuelRegister();
|
||||
|
||||
|
||||
private final Map<String, IFluidCoolant> coolants = new HashMap<String, IFluidCoolant>();
|
||||
private final Map<String, IFluidFuel> fuels = new HashMap<String, IFluidFuel>();
|
||||
|
||||
private FluidFuelRegister() {
|
||||
addCoolant(FluidRegistry.WATER, 0.0023f);
|
||||
|
||||
private final List<IFluidRegister> otherRegisters = new ArrayList<IFluidRegister>();
|
||||
|
||||
private FluidFuelRegister() {
|
||||
addCoolant(FluidRegistry.WATER, 0.0023f);
|
||||
if(Loader.isModLoaded("BuildCraft|Energy")) {
|
||||
try {
|
||||
IFluidRegister reg = (IFluidRegister) Class.forName("crazypants.enderio.fluid.BuildCraftFluidRegister").newInstance();
|
||||
otherRegisters.add(reg);
|
||||
} catch (Exception e) {
|
||||
Log.error("FluidFuelRegister: Error occured registering build craft fuels: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addCoolant(Fluid fluid, float degreesCoolingPerMB) {
|
||||
@Override
|
||||
public void addCoolant(Fluid fluid, float degreesCoolingPerMB) {
|
||||
if(fluid == null || coolants.get(fluid.getName()) != null) {
|
||||
return;
|
||||
}
|
||||
coolants.put(fluid.getName(), new Coolant(fluid, degreesCoolingPerMB));
|
||||
if(BuildcraftFuelRegistry.coolant != null && BuildcraftFuelRegistry.coolant.getCoolant(fluid) == null) {
|
||||
BuildcraftFuelRegistry.coolant.addCoolant(fluid, degreesCoolingPerMB);
|
||||
}
|
||||
coolants.put(fluid.getName(), new CoolantImpl(fluid, degreesCoolingPerMB));
|
||||
for (IFluidRegister reg : otherRegisters) {
|
||||
reg.addCoolant(fluid, degreesCoolingPerMB);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IFluidCoolant getCoolant(Fluid fluid) {
|
||||
if(fluid == null) {
|
||||
return null;
|
||||
}
|
||||
IFluidCoolant res = coolants.get(fluid.getName());
|
||||
if(res == null && !coolants.containsKey(fluid.getName()) && BuildcraftFuelRegistry.coolant != null) {
|
||||
ICoolant bcCool = BuildcraftFuelRegistry.coolant.getCoolant(fluid);
|
||||
if(bcCool != null) {
|
||||
res = new CoolantBC(bcCool);
|
||||
if(res == null && !coolants.containsKey(fluid.getName())) {
|
||||
for (IFluidRegister reg : otherRegisters) {
|
||||
res = reg.getCoolant(fluid);
|
||||
if(res != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
coolants.put(fluid.getName(), res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IFluidCoolant getCoolant(FluidStack fluid) {
|
||||
if(fluid == null || fluid.getFluid() == null) {
|
||||
return null;
|
||||
}
|
||||
return getCoolant(fluid.getFluid());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void addFuel(Fluid fluid, int powerPerCycleRF, int totalBurnTime) {
|
||||
if(fluid == null || fuels.get(fluid.getName()) != null) {
|
||||
return;
|
||||
}
|
||||
fuels.put(fluid.getName(), new Fuel(fluid, powerPerCycleRF, totalBurnTime));
|
||||
if(BuildcraftFuelRegistry.fuel != null && BuildcraftFuelRegistry.fuel.getFuel(fluid) == null) {
|
||||
BuildcraftFuelRegistry.fuel.addFuel(fluid, powerPerCycleRF, totalBurnTime);
|
||||
}
|
||||
fuels.put(fluid.getName(), new FuelImpl(fluid, powerPerCycleRF, totalBurnTime));
|
||||
for (IFluidRegister reg : otherRegisters) {
|
||||
reg.addFuel(fluid, powerPerCycleRF, totalBurnTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidFuel getFuel(Fluid fluid) {
|
||||
if(fluid == null) {
|
||||
return null;
|
||||
}
|
||||
IFluidFuel res = fuels.get(fluid.getName());
|
||||
if(res == null && !fuels.containsKey(fluid.getName()) && BuildcraftFuelRegistry.fuel != null) {
|
||||
IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(fluid);
|
||||
if(bcFuel != null) {
|
||||
res = new FuelBC(bcFuel);
|
||||
if(res == null && !fuels.containsKey(fluid.getName())) {
|
||||
for (IFluidRegister reg : otherRegisters) {
|
||||
res = reg.getFuel(fluid);
|
||||
if(res != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fuels.put(fluid.getName(), res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IFluidFuel getFuel(FluidStack fluid) {
|
||||
if(fluid == null || fluid.getFluid() == null) {
|
||||
return null;
|
||||
@@ -87,13 +106,13 @@ public class FluidFuelRegister {
|
||||
return getFuel(fluid.getFluid());
|
||||
}
|
||||
|
||||
private static class Fuel implements IFluidFuel {
|
||||
|
||||
public static class FuelImpl implements IFluidFuel {
|
||||
|
||||
private final Fluid fluid;
|
||||
private final int powerPerCycle;
|
||||
private final int totalBurningTime;
|
||||
|
||||
Fuel(Fluid fluid, int powerPerCycle, int totalBurningTime) {
|
||||
public FuelImpl(Fluid fluid, int powerPerCycle, int totalBurningTime) {
|
||||
this.fluid = fluid;
|
||||
this.powerPerCycle = powerPerCycle;
|
||||
this.totalBurningTime = totalBurningTime;
|
||||
@@ -113,45 +132,28 @@ public class FluidFuelRegister {
|
||||
public int getPowerPerCycle() {
|
||||
return powerPerCycle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class FuelBC extends Fuel {
|
||||
|
||||
FuelBC(IFuel fuel) {
|
||||
super(fuel.getFluid(), fuel.getPowerPerCycle(), fuel.getTotalBurningTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class Coolant implements IFluidCoolant {
|
||||
|
||||
public static class CoolantImpl implements IFluidCoolant {
|
||||
|
||||
private final Fluid fluid;
|
||||
private final float degreesCoolingPerMB;
|
||||
|
||||
Coolant(Fluid fluid, float degreesCoolingPerMB) {
|
||||
|
||||
public CoolantImpl(Fluid fluid, float degreesCoolingPerMB) {
|
||||
this.fluid = fluid;
|
||||
this.degreesCoolingPerMB = degreesCoolingPerMB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid getFluid() {
|
||||
public Fluid getFluid() {
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDegreesCoolingPerMB(float heat) {
|
||||
return degreesCoolingPerMB;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CoolantBC extends Coolant {
|
||||
|
||||
CoolantBC(ICoolant coolant) {
|
||||
//NB: in the current BC impl the temperature to getDegreesCoolingPerMB is ignored
|
||||
super(coolant.getFluid(), coolant.getDegreesCoolingPerMB(100));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package crazypants.enderio.fluid;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFluidRegister {
|
||||
|
||||
IFluidFuel getFuel(FluidStack fluid);
|
||||
|
||||
IFluidFuel getFuel(Fluid fluid);
|
||||
|
||||
void addFuel(Fluid fluid, int powerPerCycleRF, int totalBurnTime);
|
||||
|
||||
IFluidCoolant getCoolant(FluidStack fluid);
|
||||
|
||||
IFluidCoolant getCoolant(Fluid fluid);
|
||||
|
||||
void addCoolant(Fluid fluid, float degreesCoolingPerMB);
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import cofh.api.item.IToolHammer;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
public interface IYetaWrench extends IToolWrench, IToolHammer{
|
||||
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cofh.api.block.IDismantleable;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -20,15 +19,20 @@ import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
|
||||
public class ItemYetaWrench extends Item implements IYetaWrench, IResourceTooltipProvider {
|
||||
public class ItemYetaWrench extends Item implements ITool, IResourceTooltipProvider, InvocationHandler {
|
||||
|
||||
public static ItemYetaWrench create() {
|
||||
if(Config.useSneakMouseWheelYetaWrench) {
|
||||
PacketHandler.INSTANCE.registerMessage(YetaWrenchPacketProcessor.class, YetaWrenchPacketProcessor.class, PacketHandler.nextID(), Side.SERVER);
|
||||
}
|
||||
ItemYetaWrench result = new ItemYetaWrench();
|
||||
result.init();
|
||||
result = ToolUtil.addInterfaces(result);
|
||||
//result.init();
|
||||
GameRegistry.registerItem(result, ModObject.itemYetaWrench.unlocalisedName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -38,9 +42,9 @@ public class ItemYetaWrench extends Item implements IYetaWrench, IResourceToolti
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
GameRegistry.registerItem(this, ModObject.itemYetaWrench.unlocalisedName);
|
||||
}
|
||||
// protected void init() {
|
||||
// //GameRegistry.registerItem(this, ModObject.itemYetaWrench.unlocalisedName);
|
||||
// }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -80,43 +84,30 @@ public class ItemYetaWrench extends Item implements IYetaWrench, IResourceToolti
|
||||
return true;
|
||||
}
|
||||
|
||||
/* IYetaWrench */
|
||||
|
||||
@Override
|
||||
public boolean canWrench(EntityPlayer player, int x, int y, int z) {
|
||||
return isUsable(player.getCurrentEquippedItem(), player, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrenchUsed(EntityPlayer player, int x, int y, int z) {
|
||||
toolUsed(player.getCurrentEquippedItem(), player, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isUsable(ItemStack item, EntityLivingBase user, int x, int y, int z) {
|
||||
public boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z) {
|
||||
Block block = user.worldObj.getBlock(x, y, z);
|
||||
if (user.isSneaking() && block instanceof IDismantleable && user instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) user;
|
||||
IDismantleable machine = (IDismantleable) block;
|
||||
if (machine.canDismantle(player, player.worldObj, x, y, z) && !player.worldObj.isRemote) {
|
||||
machine.dismantleBlock(player, player.worldObj, x, y, z, false);
|
||||
}
|
||||
}
|
||||
public void used(ItemStack stack, EntityPlayer player, int x, int y, int z) {
|
||||
}
|
||||
|
||||
|
||||
/* IResourceTooltipProvider */
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
System.out.println("ItemYetaWrench.invoke: method = " + method.getName());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -29,13 +28,14 @@ import crazypants.enderio.ClientProxy;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.enderio.waila.IWailaInfoProvider;
|
||||
|
||||
public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> extends BlockContainer implements IGuiHandler, IResourceTooltipProvider, IWailaInfoProvider {
|
||||
public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> extends BlockContainer implements IGuiHandler, IResourceTooltipProvider,
|
||||
IWailaInfoProvider {
|
||||
|
||||
public static int renderId;
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
|
||||
protected AbstractMachineBlock(ModObject mo, Class<T> teClass) {
|
||||
this(mo, teClass, new Material(MapColor.ironColor));
|
||||
}
|
||||
@@ -96,23 +96,17 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
|
||||
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer)) {
|
||||
if(entityPlayer.isSneaking() && entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
removedByPlayer(world, entityPlayer, x, y, z);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
((AbstractMachineEntity)te).toggleIoModeForFace(ForgeDirection.getOrientation(side));
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
if(ToolUtil.breakBlockWithTool(this, world, x, y, z, entityPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ITool tool = ToolUtil.getEquippedTool(entityPlayer);
|
||||
if(tool != null && !entityPlayer.isSneaking()) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
((AbstractMachineEntity) te).toggleIoModeForFace(ForgeDirection.getOrientation(side));
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,8 +123,6 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata) {
|
||||
@@ -161,7 +153,6 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
|
||||
registerOverlayIcons(iIconRegister);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -171,7 +162,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
overlayIconPushPull = iIconRegister.registerIcon("enderio:machineOverlayPushPull");
|
||||
overlayIconDisabled = iIconRegister.registerIcon("enderio:machineOverlayDisabled");
|
||||
overlayIconNone = iIconRegister.registerIcon("enderio:machineOverlayNone");
|
||||
selectedFaceIcon= iIconRegister.registerIcon("enderio:machineOverlaySelectedFace");
|
||||
selectedFaceIcon = iIconRegister.registerIcon("enderio:machineOverlaySelectedFace");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -253,7 +244,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
|
||||
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
@@ -265,7 +256,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
AbstractMachineEntity te = (AbstractMachineEntity) world.getTileEntity(x, y, z);
|
||||
AbstractMachineEntity te = (AbstractMachineEntity) world.getTileEntity(x, y, z);
|
||||
te.setFacing(getFacingForHeading(heading));
|
||||
te.readFromItemStack(stack);
|
||||
if(world.isRemote) {
|
||||
@@ -281,10 +272,10 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
case 1:
|
||||
return 5;
|
||||
case 2:
|
||||
return 3;
|
||||
return 3;
|
||||
case 3:
|
||||
default:
|
||||
return 4;
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,10 +338,11 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {}
|
||||
|
||||
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultDisplayMask(World world, int x, int y, int z) {
|
||||
return IWailaInfoProvider.ALL_BITS;
|
||||
|
||||
@@ -7,23 +7,17 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.vacuum.BlockVacuumChest;
|
||||
import crazypants.enderio.machine.vacuum.ContainerVacuumChest;
|
||||
import crazypants.enderio.machine.vacuum.GuiVacuumChest;
|
||||
import crazypants.enderio.machine.vacuum.TileVacuumChest;
|
||||
import crazypants.enderio.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTooltipProvider {
|
||||
@@ -41,13 +35,13 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
setBlockTextureName("enderio:blockEnchanter");
|
||||
setLightOpacity(4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
protected void init() {
|
||||
super.init();
|
||||
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_ENCHANTER, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
@@ -68,7 +62,7 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(world.isRemote) {
|
||||
return;
|
||||
}
|
||||
@@ -78,17 +72,13 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
|
||||
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer)) {
|
||||
if(entityPlayer.isSneaking() && entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
removedByPlayer(world, entityPlayer, x, y, z, false);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ITool tool = ToolUtil.getEquippedTool(entityPlayer);
|
||||
if(tool != null) {
|
||||
if(entityPlayer.isSneaking() && tool.canUse(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z)) {
|
||||
removedByPlayer(world, entityPlayer, x, y, z, false);
|
||||
tool.used(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(entityPlayer.isSneaking()) {
|
||||
return false;
|
||||
@@ -98,7 +88,7 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean harvested) {
|
||||
if(!world.isRemote) {
|
||||
@@ -106,7 +96,7 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
if(te instanceof TileEnchanter) {
|
||||
TileEnchanter enchanter = (TileEnchanter) te;
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
ItemStack itemStack = new ItemStack(this);
|
||||
ItemStack itemStack = new ItemStack(this);
|
||||
float f = 0.7F;
|
||||
double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
@@ -114,7 +104,7 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
|
||||
|
||||
if(enchanter.getStackInSlot(0) != null) {
|
||||
Util.dropItems(world, enchanter.getStackInSlot(0), x, y, z, true);
|
||||
}
|
||||
@@ -128,12 +118,12 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random p_149745_1_) {
|
||||
public int quantityDropped(Random p_149745_1_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@@ -141,7 +131,7 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
@@ -165,6 +155,7 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
|
||||
super.breakBlock(world, x, y, z, block, p_149749_6_);
|
||||
world.removeTileEntity(x, y, z);
|
||||
|
||||
@@ -3,7 +3,6 @@ package crazypants.enderio.machine.hypercube;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -19,7 +18,6 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -27,12 +25,12 @@ import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.IoMode;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.SubChannel;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTooltipProvider {
|
||||
@@ -41,11 +39,11 @@ public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTo
|
||||
|
||||
public static BlockHyperCube create() {
|
||||
|
||||
PacketHandler.INSTANCE.registerMessage(PacketChannelList.class,PacketChannelList.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketChannelList.class, PacketChannelList.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketClientState.class, PacketClientState.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketAddRemoveChannel.class,PacketAddRemoveChannel.class,PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketAddRemoveChannel.class,PacketAddRemoveChannel.class,PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketStoredPower.class,PacketStoredPower.class,PacketHandler.nextID(),Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketAddRemoveChannel.class, PacketAddRemoveChannel.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketAddRemoveChannel.class, PacketAddRemoveChannel.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketStoredPower.class, PacketStoredPower.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
|
||||
BlockHyperCube result = new BlockHyperCube();
|
||||
result.init();
|
||||
@@ -258,17 +256,8 @@ public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTo
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) {
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
removedByPlayer(world, entityPlayer, x, y, z);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(ToolUtil.breakBlockWithTool(this, world, x, y, z, entityPlayer)) {
|
||||
return true;
|
||||
}
|
||||
if(entityPlayer.isSneaking()) {
|
||||
return false;
|
||||
@@ -283,6 +272,8 @@ public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTo
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerHyperCube();
|
||||
@@ -303,6 +294,7 @@ public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTo
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
|
||||
super.breakBlock(world, x, y, z, block, p_149749_6_);
|
||||
world.removeTileEntity(x, y, z);
|
||||
|
||||
@@ -15,13 +15,13 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cofh.api.item.IToolHammer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
|
||||
public class BlockElectricLight extends BlockEio {
|
||||
@@ -174,19 +174,23 @@ public class BlockElectricLight extends BlockEio {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
Item equipped = stack.getItem();
|
||||
if ((equipped instanceof IToolWrench || equipped instanceof IToolHammer) && player.isSneaking() && !world.isRemote) {
|
||||
ITool tool = ToolUtil.getEquippedTool(player);
|
||||
if(tool != null && tool.canUse(stack, player, x, y, z) && player.isSneaking() && !world.isRemote) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileElectricLight) {
|
||||
((TileElectricLight) te).onBlockRemoved();
|
||||
world.setBlockToAir(x, y, z);
|
||||
dropBlockAsItem(world, x, y, z, createDrop((TileElectricLight) te));
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
dropBlockAsItem(world, x, y, z, createDrop((TileElectricLight) te));
|
||||
}
|
||||
tool.used(stack, player, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -29,12 +28,12 @@ import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.enderio.waila.IWailaInfoProvider;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Lang;
|
||||
@@ -120,17 +119,8 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
|
||||
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) {
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
removedByPlayer(world, entityPlayer, x, y, z);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(ToolUtil.breakBlockWithTool(this, world, x, y, z, entityPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(entityPlayer.isSneaking()) {
|
||||
@@ -141,7 +131,7 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer)) {
|
||||
if(ToolUtil.isToolEquipped(entityPlayer)) {
|
||||
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(side);
|
||||
TileCapacitorBank tcb = (TileCapacitorBank) te;
|
||||
|
||||
@@ -21,9 +21,9 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.reservoir.TileReservoir.Pos;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.FluidUtil;
|
||||
import crazypants.util.Util;
|
||||
@@ -124,7 +124,7 @@ public class BlockReservoir extends BlockContainer implements IResourceTooltipPr
|
||||
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
|
||||
return true;
|
||||
|
||||
} else if(ConduitUtil.isToolEquipped(entityPlayer) && tank.isMultiblock()) {
|
||||
} else if(ToolUtil.isToolEquipped(entityPlayer) && tank.isMultiblock()) {
|
||||
tank.setAutoEject(!tank.isAutoEject());
|
||||
for (BlockCoord bc : tank.multiblock) {
|
||||
world.markBlockForUpdate(bc.x, bc.y, bc.z);
|
||||
|
||||
@@ -14,13 +14,13 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.enderio.waila.IWailaInfoProvider;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.util.Util;
|
||||
@@ -54,10 +54,9 @@ public class BlockSolarPanel extends BlockEio implements IResourceTooltipProvide
|
||||
GameRegistry.registerTileEntity(teClass, name + "TileEntity");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int damageDropped(int damage) {
|
||||
public int damageDropped(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@@ -73,22 +72,16 @@ public class BlockSolarPanel extends BlockEio implements IResourceTooltipProvide
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) {
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
if(!world.isRemote && !entityPlayer.capabilities.isCreativeMode) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
ItemStack is = new ItemStack(this,1,meta);
|
||||
Util.dropItems(world, is, x, y, z, true);
|
||||
}
|
||||
removedByPlayer(world, entityPlayer, x, y, z);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
ITool tool = ToolUtil.getEquippedTool(entityPlayer);
|
||||
if(tool != null && entityPlayer.isSneaking() && tool.canUse(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z)) {
|
||||
if(!world.isRemote && !entityPlayer.capabilities.isCreativeMode) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
ItemStack is = new ItemStack(this, 1, meta);
|
||||
Util.dropItems(world, is, x, y, z, true);
|
||||
}
|
||||
removedByPlayer(world, entityPlayer, x, y, z);
|
||||
tool.used(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -132,25 +125,27 @@ public class BlockSolarPanel extends BlockEio implements IResourceTooltipProvide
|
||||
setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
|
||||
super.breakBlock(world, x, y, z, block, p_149749_6_);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileEntitySolarPanel) {
|
||||
TileEntitySolarPanel solar = (TileEntitySolarPanel) te;
|
||||
float efficiency = solar.calculateLightRatio();
|
||||
|
||||
tooltip.add(String.format("%s : %s%.0f%%", EnumChatFormatting.WHITE + Lang.localize("tooltip.efficiency") + EnumChatFormatting.RESET, EnumChatFormatting.WHITE, efficiency * 100));
|
||||
if(te instanceof TileEntitySolarPanel) {
|
||||
TileEntitySolarPanel solar = (TileEntitySolarPanel) te;
|
||||
float efficiency = solar.calculateLightRatio();
|
||||
|
||||
tooltip.add(String.format("%s : %s%.0f%%", EnumChatFormatting.WHITE + Lang.localize("tooltip.efficiency") + EnumChatFormatting.RESET,
|
||||
EnumChatFormatting.WHITE, efficiency * 100));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@ package crazypants.enderio.machine.vacuum;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -14,18 +10,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.power.BlockItemCapacitorBank;
|
||||
import crazypants.enderio.machine.power.ContainerCapacitorBank;
|
||||
import crazypants.enderio.machine.power.GuiCapacitorBank;
|
||||
import crazypants.enderio.machine.power.TileCapacitorBank;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
|
||||
public class BlockVacuumChest extends BlockEio implements IGuiHandler, IResourceTooltipProvider {
|
||||
|
||||
@@ -51,17 +42,8 @@ public class BlockVacuumChest extends BlockEio implements IGuiHandler, IResource
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
|
||||
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer)) {
|
||||
if(entityPlayer.isSneaking() && entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
removedByPlayer(world, entityPlayer, x, y, z, false);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(ToolUtil.breakBlockWithTool(this, world, x, y, z, entityPlayer)) {
|
||||
return true;
|
||||
}
|
||||
if(entityPlayer.isSneaking()) {
|
||||
return false;
|
||||
@@ -144,6 +126,7 @@ public class BlockVacuumChest extends BlockEio implements IGuiHandler, IResource
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
|
||||
super.breakBlock(world, x, y, z, block, p_149749_6_);
|
||||
world.removeTileEntity(x, y, z);
|
||||
|
||||
@@ -7,73 +7,64 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockWirelessCharger extends BlockEio implements IResourceTooltipProvider /*IGuiHandler*/ {
|
||||
public class BlockWirelessCharger extends BlockEio implements IResourceTooltipProvider /* IGuiHandler */{
|
||||
|
||||
public static BlockWirelessCharger create() {
|
||||
|
||||
|
||||
PacketHandler.INSTANCE.registerMessage(PacketStoredEnergy.class, PacketStoredEnergy.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
|
||||
|
||||
BlockWirelessCharger res = new BlockWirelessCharger();
|
||||
res.init();
|
||||
return res;
|
||||
}
|
||||
|
||||
public static int renderId = 0;
|
||||
|
||||
|
||||
private IIcon centerOn;
|
||||
private IIcon centerOff;
|
||||
|
||||
protected BlockWirelessCharger() {
|
||||
super(ModObject.blockWirelessCharger.unlocalisedName, TileWirelessCharger.class);
|
||||
super(ModObject.blockWirelessCharger.unlocalisedName, TileWirelessCharger.class);
|
||||
setLightOpacity(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
|
||||
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer)) {
|
||||
if(entityPlayer.isSneaking() && entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
if(!world.isRemote) {
|
||||
Util.dropItems(world, new ItemStack(this), x, y, z, true);
|
||||
}
|
||||
breakBlock(world, x, y, z, this, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ITool tool = ToolUtil.getEquippedTool(entityPlayer);
|
||||
if(tool != null && entityPlayer.isSneaking() && tool.canUse(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z)) {
|
||||
if(!world.isRemote) {
|
||||
Util.dropItems(world, new ItemStack(this), x, y, z, true);
|
||||
}
|
||||
breakBlock(world, x, y, z, this, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
tool.used(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iIconRegister) {
|
||||
public void registerBlockIcons(IIconRegister iIconRegister) {
|
||||
centerOn = iIconRegister.registerIcon("enderio:blockWirelessChargerOn");
|
||||
centerOff = iIconRegister.registerIcon("enderio:blockWirelessChargerOff");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int p_149673_5_) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileWirelessCharger) {
|
||||
TileWirelessCharger twc = (TileWirelessCharger)te;
|
||||
TileWirelessCharger twc = (TileWirelessCharger) te;
|
||||
if(twc.getEnergyStored() > 0) {
|
||||
return centerOn;
|
||||
}
|
||||
@@ -83,7 +74,7 @@ public class BlockWirelessCharger extends BlockEio implements IResourceTooltipPr
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
return centerOff;
|
||||
}
|
||||
|
||||
@@ -96,7 +87,7 @@ public class BlockWirelessCharger extends BlockEio implements IResourceTooltipPr
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@@ -105,27 +96,27 @@ public class BlockWirelessCharger extends BlockEio implements IResourceTooltipPr
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(te instanceof TileWire) {
|
||||
// return new ContainerVacuumChest(player, player.inventory, (TileVacuumChest) te);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(te instanceof TileVacuumChest) {
|
||||
// return new GuiVacuumChest(player, player.inventory, (TileVacuumChest) te);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// @Override
|
||||
// public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(te instanceof TileWire) {
|
||||
// return new ContainerVacuumChest(player, player.inventory, (TileVacuumChest) te);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(te instanceof TileVacuumChest) {
|
||||
// return new GuiVacuumChest(player, player.inventory, (TileVacuumChest) te);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,7 @@ package crazypants.enderio.power;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import crazypants.enderio.config.Config;
|
||||
|
||||
public class PowerHandlerUtil {
|
||||
|
||||
@@ -13,13 +11,6 @@ public class PowerHandlerUtil {
|
||||
if(o instanceof IEnergyHandler) {
|
||||
return new PowerInterfaceRF((IEnergyHandler) o);
|
||||
}
|
||||
|
||||
if(Config.powerConduitOutputMJ) {
|
||||
if(o instanceof IPowerReceptor) {
|
||||
return new PowerInterfaceBC((IPowerReceptor) o);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
package crazypants.enderio.power;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
|
||||
public class PowerInterfaceBC implements IPowerInterface {
|
||||
|
||||
private IPowerReceptor bcPower;
|
||||
|
||||
public PowerInterfaceBC(IPowerReceptor powerReceptor) {
|
||||
bcPower = powerReceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDelegate() {
|
||||
return bcPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConduitConnect(ForgeDirection direction) {
|
||||
if(bcPower instanceof IPipeTile) {
|
||||
IPipeTile pipeTile = (IPipeTile) bcPower;
|
||||
return pipeTile.getPipeType() == PipeType.POWER;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection dir) {
|
||||
if(bcPower != null) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr != null) {
|
||||
return (int)(pr.getEnergyStored() * 10);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection dir) {
|
||||
if(bcPower != null && !(bcPower instanceof IPowerEmitter)) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr != null) {
|
||||
return (int)(pr.getMaxEnergyStored() * 10);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPowerRequest(ForgeDirection dir) {
|
||||
if(bcPower != null) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr == null || pr.getType() == Type.ENGINE) {
|
||||
return 0;
|
||||
}
|
||||
return (int)( pr.powerRequest() * 10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinEnergyReceived(ForgeDirection dir) {
|
||||
if(bcPower != null) {
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(dir);
|
||||
if(pr == null) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (pr.getMinEnergyReceived() * 10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recieveEnergy(ForgeDirection opposite, int canOffer) {
|
||||
if(bcPower != null) {
|
||||
if(bcPower instanceof IPowerEmitter) {
|
||||
return 0;
|
||||
}
|
||||
PowerReceiver pr = bcPower.getPowerReceiver(opposite);
|
||||
if(pr == null) {
|
||||
return 0;
|
||||
}
|
||||
double offer = Math.min(pr.powerRequest(), canOffer / 10f);
|
||||
double used = pr.receiveEnergy(Type.PIPE, offer, opposite);
|
||||
return (int) (used * 10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.transceiver.Channel;
|
||||
@@ -31,6 +30,7 @@ import crazypants.enderio.machine.transceiver.ChannelType;
|
||||
import crazypants.enderio.machine.transceiver.ServerChannelRegister;
|
||||
import crazypants.enderio.machine.transceiver.TileTransceiver;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.util.MetadataUtil;
|
||||
import crazypants.util.RoundRobinIterator;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class BlockEnderRail extends BlockRail implements IResourceTooltipProvide
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(ToolUtil.isToolEquipped(player)) {
|
||||
if(!world.isRemote) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
meta = MetadataUtil.setBit(3, !MetadataUtil.isBitSet(3, meta), meta);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
public class BuildCraftToolProvider implements IToolProvider, IToolImpl {
|
||||
|
||||
private BCWrench wrench = new BCWrench();
|
||||
|
||||
public BuildCraftToolProvider() throws Exception {
|
||||
//Do a check for so we throw an exception in the constructor if we dont have the
|
||||
// wrench class
|
||||
Class.forName("buildcraft.api.tools.IToolWrench");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITool getTool(ItemStack stack) {
|
||||
if(MpsUtil.instance.isPowerFistEquiped(stack) && !MpsUtil.instance.isOmniToolActive(stack)) {
|
||||
return null;
|
||||
}
|
||||
if(stack.getItem() instanceof IToolWrench) {
|
||||
return wrench;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getInterface() {
|
||||
return IToolWrench.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handleMethod(ITool yetaWrench, Method method, Object[] args) {
|
||||
if("canWrench".equals(method.getName())) {
|
||||
return true;
|
||||
} else if("wrenchUsed".equals(method.getName())) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class BCWrench implements ITool {
|
||||
|
||||
@Override
|
||||
public boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z) {
|
||||
return ((IToolWrench) stack.getItem()).canWrench(player, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void used(ItemStack stack, EntityPlayer player, int x, int y, int z) {
|
||||
((IToolWrench) stack.getItem()).wrenchUsed(player, x, y, z);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public interface ITool {
|
||||
|
||||
boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z);
|
||||
|
||||
void used(ItemStack stack, EntityPlayer player, int x, int y, int z);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public interface IToolImpl {
|
||||
|
||||
Class<?> getInterface();
|
||||
|
||||
Object handleMethod(ITool yetaWrench, Method method, Object[] args);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IToolProvider {
|
||||
|
||||
ITool getTool(ItemStack stack);
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package crazypants.enderio.conduit;
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cofh.api.block.IDismantleable;
|
||||
import cofh.api.item.IToolHammer;
|
||||
|
||||
public class TEToolProvider implements IToolProvider, IToolImpl {
|
||||
|
||||
private TEHammer wrench = new TEHammer();
|
||||
|
||||
@Override
|
||||
public ITool getTool(ItemStack stack) {
|
||||
if(stack.getItem() instanceof IToolHammer) {
|
||||
return wrench;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class TEHammer implements ITool {
|
||||
|
||||
@Override
|
||||
public boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z) {
|
||||
return ((IToolHammer) stack.getItem()).isUsable(stack, player, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void used(ItemStack stack, EntityPlayer player, int x, int y, int z) {
|
||||
((IToolHammer) stack.getItem()).toolUsed(stack, player, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getInterface() {
|
||||
return IToolHammer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handleMethod(ITool yetaWrench, Method method, Object[] args) {
|
||||
if("isUsable".equals(method.getName())) {
|
||||
return true;
|
||||
} else if("toolUsed".equals(method.getName())) {
|
||||
toolUsed((ItemStack) args[0], (EntityLivingBase) args[1], (Integer) args[2], (Integer) args[3], (Integer) args[4]);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z) {
|
||||
Block block = user.worldObj.getBlock(x, y, z);
|
||||
if(user.isSneaking() && block instanceof IDismantleable && user instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) user;
|
||||
IDismantleable machine = (IDismantleable) block;
|
||||
if(machine.canDismantle(player, player.worldObj, x, y, z) && !player.worldObj.isRemote) {
|
||||
machine.dismantleBlock(player, player.worldObj, x, y, z, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.sf.cglib.proxy.Enhancer;
|
||||
import net.sf.cglib.proxy.MethodInterceptor;
|
||||
import net.sf.cglib.proxy.MethodProxy;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.item.ItemYetaWrench;
|
||||
|
||||
public class ToolUtil {
|
||||
|
||||
public static boolean isToolEquipped(EntityPlayer player) {
|
||||
return getInstance().isToolEquippedImpl(player);
|
||||
}
|
||||
|
||||
public static ITool getEquippedTool(EntityPlayer player) {
|
||||
return getInstance().getEquippedToolImpl(player);
|
||||
}
|
||||
|
||||
public static ItemYetaWrench addInterfaces(ItemYetaWrench item) {
|
||||
return getInstance().addInterfacesImpl(item);
|
||||
}
|
||||
|
||||
public static boolean breakBlockWithTool(Block block, World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
ITool tool = ToolUtil.getEquippedTool(entityPlayer);
|
||||
if(tool != null && entityPlayer.isSneaking() && tool.canUse(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z)) {
|
||||
block.removedByPlayer(world, entityPlayer, x, y, z);
|
||||
tool.used(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ToolUtil instance;
|
||||
|
||||
private static ToolUtil getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new ToolUtil();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final List<IToolProvider> toolProviders = new ArrayList<IToolProvider>();
|
||||
private final List<IToolImpl> toolImpls = new ArrayList<IToolImpl>();
|
||||
|
||||
private ToolUtil() {
|
||||
|
||||
try {
|
||||
Object obj = Class.forName("crazypants.enderio.tool.BuildCraftToolProvider").newInstance();
|
||||
toolProviders.add((IToolProvider) obj);
|
||||
toolImpls.add((IToolImpl) obj);
|
||||
} catch (Exception e) {
|
||||
Log.warn("Could not find Build Craft Wrench definition. Wrench integration with other mods may fail");
|
||||
}
|
||||
|
||||
toolProviders.add(new TEToolProvider());
|
||||
toolImpls.add(new TEToolProvider());
|
||||
|
||||
}
|
||||
|
||||
public void registerToolProvider(IToolProvider toolProvider) {
|
||||
toolProviders.add(toolProvider);
|
||||
}
|
||||
|
||||
private boolean isToolEquippedImpl(EntityPlayer player) {
|
||||
return getEquippedToolImpl(player) != null;
|
||||
}
|
||||
|
||||
private ITool getEquippedToolImpl(EntityPlayer player) {
|
||||
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
|
||||
if(player == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if(equipped == null) {
|
||||
return null;
|
||||
}
|
||||
if(equipped.getItem() instanceof ITool) {
|
||||
return (ITool) equipped.getItem();
|
||||
}
|
||||
return getToolImpl(equipped);
|
||||
|
||||
}
|
||||
|
||||
private ITool getToolImpl(ItemStack equipped) {
|
||||
for (IToolProvider provider : toolProviders) {
|
||||
ITool result = provider.getTool(equipped);
|
||||
if(result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemYetaWrench addInterfacesImpl(ItemYetaWrench item) {
|
||||
Enhancer e = new Enhancer();
|
||||
YetaWrenchProxy proxy = new YetaWrenchProxy(item, toolImpls);
|
||||
e.setCallback(proxy);
|
||||
e.setSuperclass(item.getClass());
|
||||
e.setInterceptDuringConstruction(false);
|
||||
Class[] interfaces = new Class[toolImpls.size()];
|
||||
int i = 0;
|
||||
for (IToolImpl tool : toolImpls) {
|
||||
interfaces[i] = tool.getInterface();
|
||||
++i;
|
||||
}
|
||||
e.setInterfaces(interfaces);
|
||||
ItemYetaWrench proxifiedObj = (ItemYetaWrench) e.create();
|
||||
|
||||
return proxifiedObj;
|
||||
}
|
||||
|
||||
public static class YetaWrenchProxy implements MethodInterceptor {
|
||||
|
||||
private ItemYetaWrench item;
|
||||
private Map<Class, IToolImpl> impls;
|
||||
|
||||
private YetaWrenchProxy(ItemYetaWrench item, List<IToolImpl> toolImpls) {
|
||||
this.item = item;
|
||||
impls = new HashMap<Class, IToolImpl>();
|
||||
for (IToolImpl tool : toolImpls) {
|
||||
impls.put(tool.getInterface(), tool);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
|
||||
try {
|
||||
IToolImpl impl = impls.get(method.getDeclaringClass());
|
||||
if(impl != null) {
|
||||
return impl.handleMethod(item, method, args);
|
||||
}
|
||||
method.setAccessible(true);
|
||||
return method.invoke(item, args);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
|
||||
public class BuildcraftUtil implements IItemReceptor, IFluidReceptor {
|
||||
|
||||
static {
|
||||
//Only register if we can actually load the IPipeTile class
|
||||
try {
|
||||
Class.forName("buildcraft.api.transport.IPipeTile");
|
||||
BuildcraftUtil instance = new BuildcraftUtil();
|
||||
ItemUtil.receptors.add(instance);
|
||||
FluidUtil.fluidReceptors.add(instance);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doInsertItem(Object into, ItemStack item, ForgeDirection side) {
|
||||
if(into instanceof IPipeTile) {
|
||||
return ((IPipeTile) into).injectItem(item, true, side);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertIntoObject(Object into, ForgeDirection side) {
|
||||
if(into instanceof IPipeTile) {
|
||||
IPipeTile pipe = (IPipeTile) into;
|
||||
return pipe.getPipeType() == PipeType.ITEM;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidReceptor(IFluidHandler handler) {
|
||||
if(handler instanceof IPipeTile) {
|
||||
IPipeTile pipe = (IPipeTile) handler;
|
||||
return pipe.getPipeType() == PipeType.FLUID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,12 +16,24 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
|
||||
public class FluidUtil {
|
||||
|
||||
public static final List<IFluidReceptor> fluidReceptors = new ArrayList<IFluidReceptor>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("crazypants.util.BuildcraftUtil");
|
||||
} catch (Exception e) {
|
||||
if(Loader.isModLoaded("BuildCraft|Transport")) {
|
||||
Log.warn("ItemUtil: Could not register Build Craft pipe handler. Fluid conduits will show connections to all Build Craft pipes.");
|
||||
} //Don't log if BC isn't installed, but we still check in case another mod is using their API
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<ForgeDirection, IFluidHandler> getNeighbouringFluidHandlers(IBlockAccess world, BlockCoord bc) {
|
||||
Map<ForgeDirection, IFluidHandler> res = new HashMap<ForgeDirection, IFluidHandler>();
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
@@ -49,12 +61,13 @@ public class FluidUtil {
|
||||
|
||||
public static IFluidHandler getFluidHandler(TileEntity te) {
|
||||
if(te instanceof IFluidHandler) {
|
||||
if(te instanceof IPipeTile) {
|
||||
if(((IPipeTile) te).getPipeType() != PipeType.FLUID) {
|
||||
IFluidHandler res = (IFluidHandler) te;
|
||||
for (IFluidReceptor rec : fluidReceptors) {
|
||||
if(!rec.isValidReceptor(res)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (IFluidHandler) te;
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public interface IFluidReceptor {
|
||||
|
||||
boolean isValidReceptor(IFluidHandler handler);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IItemReceptor {
|
||||
|
||||
boolean canInsertIntoObject(Object into, ForgeDirection side);
|
||||
|
||||
int doInsertItem(Object into, ItemStack item, ForgeDirection side);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package crazypants.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryLargeChest;
|
||||
@@ -7,16 +10,29 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import cofh.api.transport.IItemDuct;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.Log;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
public static final List<IItemReceptor> receptors = new ArrayList<IItemReceptor>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("crazypants.util.BuildcraftUtil");
|
||||
} catch (Exception e) {
|
||||
if(Loader.isModLoaded("BuildCraft|Transport")) {
|
||||
Log.warn("ItemUtil: Could not register Build Craft pipe handler. Machines will not be able to output to BC pipes.");
|
||||
} //Don't log if BC isn't installed, but we still check in case another mod is using their API
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDurabilityString(ItemStack item) {
|
||||
if(item == null) {
|
||||
return null;
|
||||
}
|
||||
return Lang.localize("item.darkSteel.tooltip.durability") + " " + (item.getMaxDamage() - item.getItemDamage()) + "/" + item.getMaxDamage();
|
||||
return Lang.localize("item.darkSteel.tooltip.durability") + " " + (item.getMaxDamage() - item.getItemDamage()) + "/" + item.getMaxDamage();
|
||||
}
|
||||
|
||||
public static NBTTagCompound getOrCreateNBT(ItemStack stack) {
|
||||
@@ -36,9 +52,14 @@ public class ItemUtil {
|
||||
return ItemUtil.doInsertItem(getInventory((IInventory) into), item);
|
||||
} else if(into instanceof IItemDuct) {
|
||||
return ItemUtil.doInsertItem((IItemDuct) into, item, side);
|
||||
} else if(into instanceof IPipeTile) {
|
||||
return ((IPipeTile) into).injectItem(item, true, side);
|
||||
}
|
||||
|
||||
for (IItemReceptor rec : receptors) {
|
||||
if(rec.canInsertIntoObject(into, side)) {
|
||||
return rec.doInsertItem(into, item, side);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -119,7 +140,7 @@ public class ItemUtil {
|
||||
toInsert.stackSize = 0;
|
||||
}
|
||||
}
|
||||
if (!inv.isItemValidForSlot(slot, toInsert)) {
|
||||
if(!inv.isItemValidForSlot(slot, toInsert)) {
|
||||
inserted = 0;
|
||||
}
|
||||
|
||||
@@ -166,6 +187,7 @@ public class ItemUtil {
|
||||
|
||||
/**
|
||||
* Checks if items, damage and NBT are equal and the items are stackable.
|
||||
*
|
||||
* @param s1
|
||||
* @param s2
|
||||
* @return
|
||||
@@ -176,12 +198,13 @@ public class ItemUtil {
|
||||
}
|
||||
if(!s1.isItemEqual(s2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ItemStack.areItemStackTagsEqual(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if items, damage and NBT are equal.
|
||||
*
|
||||
* @param s1
|
||||
* @param s2
|
||||
* @return
|
||||
@@ -192,7 +215,7 @@ public class ItemUtil {
|
||||
}
|
||||
if(!s1.isItemEqual(s2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ItemStack.areItemStackTagsEqual(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user