本文整理汇总了Java中dan200.computercraft.api.peripheral.IPeripheral类的典型用法代码示例。如果您正苦于以下问题:Java IPeripheral类的具体用法?Java IPeripheral怎么用?Java IPeripheral使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPeripheral类属于dan200.computercraft.api.peripheral包,在下文中一共展示了IPeripheral类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.COMPUTERCRAFT)
public boolean equals(IPeripheral other) {
if (other == null) {
return false;
}
if (this == other) {
return true;
}
if (other instanceof TileEntity) {
TileEntity tother = (TileEntity) other;
return tother.getWorld().equals(getWorld()) && tother.getPos().equals(getPos());
}
return false;
}
示例2: update
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public void update(ITurtleAccess turtle, TurtleSide side)
{
//CRMod.infoLog("chunky.update(): getUpgrade="+turtle.getUpgrade(side));
if(turtle.getWorld().isRemote)//on Client getPeripheral doesn't work (CC1.63pr3)
return;
IPeripheral p = turtle.getPeripheral(side);
if( p instanceof ChunkyPeripheral)
{
((ChunkyPeripheral) p).update();
}
else
{
if(p!=null)
ChunkyPeripherals.logger.error("update called on a turtle without chunky module ( p is "+p.getClass().getName()+")");
else
ChunkyPeripherals.logger.error("update called on a turtle without chunky module ( p is null )");
}
}
示例3: syncToInfo
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
public void syncToInfo() {
computerInfo.label = computer.getLabel();
computerInfo.id = computer.getID();
for (int i = 0; i < computerInfo.sides.length; i++) {
Side side = computerInfo.sides[i];
side.redstoneInput = computer.getRedstoneOutput(i);
side.bundledInput = computer.getBundledRedstoneOutput(i);
IPeripheral peripheral = computer.getPeripheral(i);
if (peripheral == null) {
side.peripheral = null;
} else {
side.peripheral = peripheral.getType();
}
}
}
示例4: getPeripheral
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public IPeripheral getPeripheral(World world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
ICounterContainer container = null;
if (tile instanceof ICounterContainer)
container = (ICounterContainer) tile;
else {
for (ICounterFinder finder : CountCraft.instance.finders) {
ICounterContainer containerFrom = finder.getCounterContainerFrom(tile);
if (containerFrom != null)
container = containerFrom;
}
}
if (container != null)
return new CounterPeripheralWrapper(container);
return null;
}
示例5: getPeripheral
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public IPeripheral getPeripheral( final World world, final int x, final int y, final int z, final int side )
{
try
{
// Get the tile entity at that position
TileEntity te = world.getTileEntity( x, y, z );
// Is the entity an Essentia Provider?
if( te instanceof TileEssentiaProvider )
{
// Create the peripheral
return new EssentiaProviderPeripheral( world, x, y, z );
}
}
catch( Exception e )
{
// Silently ignore
}
return null;
}
示例6: invalidate
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public void invalidate() {
super.invalidate();
if (!worldObj.isRemote) {
ItemStack drop = new ItemStack(ModBlocks.peripheralContainer);
if (peripheralsContained.size() > 0) {
NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag);
drop.stackTagCompound = tag;
List<String> text = new ArrayList<String>();
text.add(Colors.RESET.toString()+Colors.UNDERLINE+"Contained Peripherals:");
for (int id : NBTHelper.getIntArray(drop, "ids")) {
Block peripheral = Block.getBlockById(id);
IPeripheral iPeripheral = (IPeripheral) peripheral.createTileEntity(null, 0);
text.add(Colors.RESET+iPeripheral.getType());
}
NBTHelper.setInfo(drop, text);
}
worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord, yCoord+1, zCoord, drop.copy()));
}
}
示例7: shouldTrackWithThisEntry
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public boolean shouldTrackWithThisEntry(IBlockAccess world, BlockPos pos, IBlockState state, TileEntity te) {
if (state.getBlock() instanceof IPeripheralProvider) {
IPeripheral peripheral = ((IPeripheralProvider) state.getBlock()).getPeripheral(te.getWorld(), pos, EnumFacing.DOWN);
return peripheral != null && peripheral.getMethodNames().length != 0;
} else {
return false;
}
}
示例8: addInformation
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public void addInformation(World world, BlockPos pos, TileEntity te, List<String> infoList) {
infoList.add("blockTracker.info.peripheral.title");
infoList.add("blockTracker.info.peripheral.availableMethods");
IPeripheral peripheral = ((IPeripheralProvider) world.getBlockState(pos).getBlock()).getPeripheral(world, pos, EnumFacing.DOWN);
if (peripheral != null) {
for (String method : peripheral.getMethodNames()) {
infoList.add("-" + method);
}
}
}
示例9: getPeripheral
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
/**
* Produce an peripheral implementation from a block location.
*
* @return a peripheral, or null if there is not a peripheral here you'd like to handle.
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
*/
@Override
@Optional.Method(modid = ModIds.COMPUTERCRAFT)
public IPeripheral getPeripheral(World world, BlockPos pos, EnumFacing side) {
TileEntity te = world.getTileEntity(pos);
return te instanceof IPeripheral ? (IPeripheral) te : null;
}
示例10: getPeripheral
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Optional.Method(modid = "ComputerCraft")
@Override
public IPeripheral getPeripheral(World world, BlockPos pos, EnumFacing side) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof TileEntityTankComputer)
return (IPeripheral) tile;
return null;
}
示例11: getPeripheral
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Optional.Method(modid = Configs.COMPUTERCRAFT)
@Override
public IPeripheral getPeripheral(World world, BlockPos pos, EnumFacing side) {
TileEntity tilee = world.getTileEntity(pos);
if (tilee instanceof TileEntityMonitor) {
TileEntityMonitor te = ((TileEntityMonitor) tilee);
return te.direction == side.ordinal() ? null : te;
}
return null;
}
示例12: getPeripheral
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Optional.Method(modid = "ComputerCraft")
@Override
public IPeripheral getPeripheral(World world, int x, int y, int z, int side) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityRadio)
return (IPeripheral)te;
return null;
}
示例13: getPeripheral
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
@Method(modid = ComputerCraft.MOD_ID)
public IPeripheral getPeripheral(World world, int x, int y, int z, int side) {
TileEntity t = world.getTileEntity(x, y, z);
if (t != null && (t instanceof TileController || t instanceof TileNetworkInterface || t instanceof TileDialingDevice || t instanceof TileTransferEnergy || t instanceof TileTransferFluid || t instanceof TileTransferItem))
return (IPeripheral) t;
return null;
}
示例14: update
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public void update(ITurtleAccess turtle, TurtleSide side)
{
//update the chunky part of the peripheral
super.update(turtle,side);
//do what dan does
if(turtle.getWorld().isRemote)
return;
IPeripheral p = turtle.getPeripheral(side);
if( p!=null && p instanceof WirelessChunkyPeripheral)
{
Object subPeripheral = ((WirelessChunkyPeripheral)p).getSubPeripheral();
if((Boolean) CCReflectionHelper.invokeMethod(subPeripheral, true, "pollChanged"))
{
turtle.getUpgradeNBTData(side).setBoolean("active", (Boolean) CCReflectionHelper.invokeMethod(subPeripheral, true, "isActive"));
turtle.updateUpgradeNBTData(side);
}
}
else
{
if(p!=null)
ChunkyPeripherals.logger.error("update called on a turtle without wireless chunky module ( p is "+p.getClass().getName()+")");
else
ChunkyPeripherals.logger.error("update called on a turtle without wireless chunky module ( p is null )");
}
}
示例15: equals
import dan200.computercraft.api.peripheral.IPeripheral; //导入依赖的package包/类
@Override
public boolean equals(IPeripheral other)
{
if(other instanceof ChunkyPeripheral)
{
ChunkyPeripheral p2 = (ChunkyPeripheral)other;
return p2.turtle.getPosition().equals(turtle.getPosition());
}
return false;
}