Add CC IPeripheralProvider to Bounding, EnergyCube and Generator blocks
This commit is contained in:
parent
799f49d9b6
commit
91dbb7fcd6
|
@ -13,10 +13,16 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockBounding extends Block
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
|
||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheralProvider", modid = "ComputerCraft")
|
||||
public class BlockBounding extends Block implements IPeripheralProvider
|
||||
{
|
||||
public BlockBounding()
|
||||
{
|
||||
|
@ -52,11 +58,11 @@ public class BlockBounding extends Block
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z)
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
|
||||
{
|
||||
try {
|
||||
TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(x, y, z);
|
||||
return world.getBlock(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ).removedByPlayer(world, player, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ);
|
||||
return world.getBlock(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ).removedByPlayer(world, player, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, willHarvest);
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -122,4 +128,18 @@ public class BlockBounding extends Block
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "ComputerCraft")
|
||||
public IPeripheral getPeripheral(World world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te != null && te instanceof IPeripheral)
|
||||
{
|
||||
return (IPeripheral)te;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,12 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -46,7 +50,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public class BlockEnergyCube extends BlockContainer
|
||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheralProvider", modid = "ComputerCraft")
|
||||
public class BlockEnergyCube extends BlockContainer implements IPeripheralProvider
|
||||
{
|
||||
public IIcon[][] icons = new IIcon[256][256];
|
||||
|
||||
|
@ -354,4 +359,18 @@ public class BlockEnergyCube extends BlockContainer
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "ComputerCraft")
|
||||
public IPeripheral getPeripheral(World world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te != null && te instanceof IPeripheral)
|
||||
{
|
||||
return (IPeripheral)te;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -647,4 +647,18 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "ComputerCraft")
|
||||
public IPeripheral getPeripheral(World world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te != null && te instanceof IPeripheral)
|
||||
{
|
||||
return (IPeripheral)te;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue