• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ITurtleAccess类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中dan200.computercraft.api.turtle.ITurtleAccess的典型用法代码示例。如果您正苦于以下问题:Java ITurtleAccess类的具体用法?Java ITurtleAccess怎么用?Java ITurtleAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITurtleAccess类属于dan200.computercraft.api.turtle包,在下文中一共展示了ITurtleAccess类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: update

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的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 )");
	}
}
 
开发者ID:c-rizz,项目名称:ChunkyPeripherals,代码行数:20,代码来源:ChunkyUpgrade.java


示例2: useTool

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@Override
public TurtleCommandResult useTool(ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction)
{
	return TurtleCommandResult.failure();
	/*
	if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT)//on Client getPeripheral doesn't work (CC1.63pr3)
		return TurtleCommandResult.failure();
	
	if(verb==TurtleVerb.Dig)
	{
		IPeripheral p = turtle.getPeripheral(side);
		
		if(direction>1)//se la direzione non è su o giù
			direction = 2;
		ITurtleCommand dig = new MinyChunkyPeripheral.DigCommand(direction);
		
		return dig.execute(turtle);
	}
	else
	{
		return TurtleCommandResult.failure("Unsupported action");
	}
	*/
}
 
开发者ID:c-rizz,项目名称:ChunkyPeripherals,代码行数:25,代码来源:MinyChunkyUpgrade.java


示例3: PeripheralBarrel

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public PeripheralBarrel(ITurtleAccess turtle, TurtleSide side) {
	this.turtle = turtle;
	this.side = side;
	NBTTagCompound tag = turtle.getUpgradeNBTData(side);
	if (tag.getInteger("maxSize") > 0)
		MAX_SIZE = tag.getInteger("maxSize");
	if (tag.getInteger("stackSize") > 0)
		STACK_SIZE = tag.getInteger("stackSize");
	CURRENT_USAGE = tag.getInteger("currentUsage");
	if (tag.getBoolean("isKnown"))
       {
           ITEM_TYPE_STORED = Item.getItemById(tag.getInteger("itemID"));
           ITEM_META_STORED = tag.getInteger("stackMeta");
       }
	checkUsageStats();
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:17,代码来源:PeripheralBarrel.java


示例4: update

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@Override
public void update(ITurtleAccess turtle, TurtleSide side) {
	if (!Config.enableRidableTurtle) {
		return;
	}
	World world = turtle.getWorld();
	if (!world.isRemote) {
		try {
			getEntity(turtle);
		} catch (Exception e) {
			EntityRidableTurtle ridableTurtle = new EntityRidableTurtle(world);
			ridableTurtle.setPosition(turtle.getPosition().posX + 0.5, turtle.getPosition().posY,
					turtle.getPosition().posZ + 0.5);
			ridableTurtle.setTurtle(turtle);
			world.spawnEntityInWorld(ridableTurtle);
		}
	}
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:19,代码来源:TurtleRidable.java


示例5: attackEntity

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@Override
protected ArrayList<ItemStack> attackEntity(ITurtleAccess turtle, Entity entity) throws TurtleFailureAttack {
    final IInventory inv = turtle.getInventory();
    final int selected = turtle.getSelectedSlot();
    final ItemStack currStack = inv.getStackInSlot(selected);
    if (currStack == null || currStack.stackSize <= 0) {
        throw new TurtleFailureAttack("selected slot empty");
    }
    final EntityAnimal animal = (EntityAnimal) entity;
    if (animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(currStack)) {
        animal.setTarget(null); // remove anything they're following
        animal.func_146082_f(null); // set it in love
        --currStack.stackSize;
        if (currStack.stackSize == 0) {
            inv.setInventorySlotContents(selected, null);
        }
    }
    return null;
}
 
开发者ID:theoriginalbit,项目名称:MoarPeripherals,代码行数:20,代码来源:UpgradeFeeder.java


示例6: teleportTo

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@LuaFunction
@MultiReturn
public Object[] teleportTo(int x, int y, int z) {
    // look for the Turtle above
    final ITurtleAccess turtle = TurtleUtil.getITurtle(worldObj, xCoord, yCoord + 1, zCoord);
    // if there was a turtle
    if (turtle != null) {
        // make sure it can teleport there
        if (!worldObj.isAirBlock(x, y, z)) {
            return new Object[]{false, "Teleport failed"};
        }
        // check there is enough fuel to teleport
        int requiredFuel = requiredFuelInternal(turtle, x, y, z);
        if (requiredFuel > turtle.getFuelLevel()) {
            return new Object[]{false, "Not enough fuel"};
        }
        // consume the fuel and teleport the Turtle
        turtle.consumeFuel(requiredFuel);
        turtle.teleportTo(worldObj, x, y, z);
        // show teleport particles and play teleport sounds at both sides
        doTeleportFX(new ChunkCoordinates(x, y, z));
        return new Object[]{true};
    }
    // no turtle
    return new Object[]{false, "No Turtle found above the teleport"};
}
 
开发者ID:theoriginalbit,项目名称:MoarPeripherals,代码行数:27,代码来源:TileTurtleTeleport.java


示例7: WirelessChunkyPeripheral

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public WirelessChunkyPeripheral(ITurtleAccess t, TurtleSide side)
{
	super(t);
	
	Class wirelessModemClass = null;
	ITurtleUpgrade turtleModemObject = (ITurtleUpgrade) CCReflectionHelper.runMainCCClassMethod("getTurtleUpgrade", 1);
	wirelessModemSubPeripheral = turtleModemObject.createPeripheral(t,side);
	
	methodsNumber = wirelessModemSubPeripheral.getMethodNames().length;
	
}
 
开发者ID:c-rizz,项目名称:ChunkyPeripherals,代码行数:12,代码来源:WirelessChunkyPeripheral.java


示例8: update

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的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 )");
	}
}
 
开发者ID:c-rizz,项目名称:ChunkyPeripherals,代码行数:29,代码来源:WirelessChunkyUpgrade.java


示例9: getIcon

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@Override
public IIcon getIcon(ITurtleAccess turtle, TurtleSide side)
{
	if(side==TurtleSide.Left)
		return iconLeft;
	else
		return iconRight;
}
 
开发者ID:c-rizz,项目名称:ChunkyPeripherals,代码行数:9,代码来源:MinyChunkyUpgrade.java


示例10: onMessage

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@Override
public IMessage onMessage(SynthResponsePacket message, MessageContext ctx) {
	if (message.side == null)
		((TileEntitySpeaker) message.world.getTileEntity(message.x, message.y, message.z)).onSpeechCompletion(message.text, null);
	else
		try {
			ITurtleAccess turtle = ReflectionHelper.getTurtle(message.world.getTileEntity(message.x, message.y, message.z));
			((TileEntitySpeaker)turtle.getPeripheral(message.side)).onSpeechCompletion(message.text, null);
		} catch (Exception e) {
			e.printStackTrace();
		}
	return null;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:14,代码来源:SynthResponsePacket.java


示例11: onMessage

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@Override
public IMessage onMessage(AudioResponsePacket message, MessageContext ctx) {
	if (message.side == null)
		((TileEntitySpeaker) message.world.getTileEntity(message.x, message.y, message.z)).onSpeechCompletion(message.text, message.lang);
	else
		try {
			ITurtleAccess turtle = ReflectionHelper.getTurtle(message.world.getTileEntity(message.x, message.y, message.z));
			((TileEntitySpeaker)turtle.getPeripheral(message.side)).onSpeechCompletion(message.text, message.lang);
		} catch (Exception e) {
			e.printStackTrace();
		}
	return null;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:14,代码来源:AudioResponsePacket.java


示例12: harvestBlock

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public static List<ItemStack> harvestBlock(ITurtleAccess turtle, FakeTurtlePlayer player, int dir, ItemStack itemToUse) {
	int x = turtle.getPosition().posX+Facing.offsetsXForSide[dir];
	int y = turtle.getPosition().posY+Facing.offsetsYForSide[dir];
	int z = turtle.getPosition().posZ+Facing.offsetsZForSide[dir];
	if (!turtle.getWorld().isAirBlock(x,y,z)) {
		Block block = turtle.getWorld().getBlock(x,y,z);
		player.setCurrentItemOrArmor(0, itemToUse);
		if (block.getBlockHardness(turtle.getWorld(), x,y,z) >= 0 && block.canHarvestBlock(player, block.getDamageValue(turtle.getWorld(),x,y,z))) {
			List<ItemStack> items = block.getDrops(turtle.getWorld(),x,y,z, block.getDamageValue(turtle.getWorld(),x,y,z), 0);
			turtle.getWorld().setBlockToAir(x,y,z);
			return items;
		}
	}
	return null;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:16,代码来源:TurtleUtil.java


示例13: getEntitiesNearTurtle

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public static List<Entity> getEntitiesNearTurtle(ITurtleAccess turtle, FakeTurtlePlayer player, int dir) {
	int x = turtle.getPosition().posX+Facing.offsetsXForSide[dir];
	int y = turtle.getPosition().posY+Facing.offsetsYForSide[dir];
	int z = turtle.getPosition().posZ+Facing.offsetsZForSide[dir];
	AxisAlignedBB box = AxisAlignedBB.getBoundingBox(x, y, z, x+1.0D, y+1.0D, z+1.0D);
	return turtle.getWorld().getEntitiesWithinAABBExcludingEntity(player, box);
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:8,代码来源:TurtleUtil.java


示例14: addToInv

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public static void addToInv(ITurtleAccess turtle, ItemStack stack) {
	boolean drop = true;
	IInventory inv = turtle.getInventory();
	ChunkCoordinates coords = turtle.getPosition();
	for (int i = 0; i < inv.getSizeInventory(); i++) {
		ItemStack currentStack = inv.getStackInSlot(i);
		if (currentStack == null) {
			inv.setInventorySlotContents(i, stack);
			drop = false;
			break;
		}
		if (currentStack.isStackable() && currentStack.isItemEqual(stack)) {
			int space = currentStack.getMaxStackSize() - currentStack.stackSize;
			if (stack.stackSize > space) {
				currentStack.stackSize = currentStack.getMaxStackSize();
				stack.stackSize -= space;
				drop = true;
			} else {
				currentStack.stackSize += stack.stackSize;
				stack.stackSize = 0;
				drop = false;
				break;
			}
		}
	}
	if (drop) {
		int dir = turtle.getDirection();
		turtle.getWorld().spawnEntityInWorld(new EntityItem(turtle.getWorld(), coords.posX+Facing.offsetsXForSide[dir], coords.posY+Facing.offsetsYForSide[dir]+1, coords.posZ+Facing.offsetsZForSide[dir], stack.copy()));
	}
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:31,代码来源:TurtleUtil.java


示例15: getPeripheral

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public static <T> T getPeripheral(ITurtleAccess turtle, Class<T> clazz) {
	for (TurtleSide side : EnumSet.allOf(TurtleSide.class)) {
		IPeripheral peripheral = turtle.getPeripheral(side);
		if (peripheral != null && clazz.isAssignableFrom(peripheral.getClass())) 
			return (T)peripheral;
	}
	
	return null;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:10,代码来源:TurtleUtil.java


示例16: getPeripheralSide

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public static TurtleSide getPeripheralSide(ITurtleAccess turtle, Class clazz) {
	for (TurtleSide side : EnumSet.allOf(TurtleSide.class)) {
		IPeripheral peripheral = turtle.getPeripheral(side);
		if (peripheral != null && clazz.isAssignableFrom(peripheral.getClass())) 
			return side;
	}
	
	return null;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:10,代码来源:TurtleUtil.java


示例17: getTurtle

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public static ITurtleAccess getTurtle(TileEntity te) throws Exception {
	if (te instanceof ITurtleAccess)
		return (ITurtleAccess) te;
	Class teClass = te.getClass();
	if (teClass.getName().equals("dan200.computercraft.shared.turtle.blocks.TileTurtleExpanded") || teClass.getName().equals("dan200.computercraft.shared.turtle.blocks.TileTurtleAdvanced") || teClass.getName().equals("dan200.computercraft.shared.turtle.blocks.TileTurtle")) {
		Method getAccess = teClass.getMethod("getAccess", new Class[0]);
		ITurtleAccess turtle = (ITurtleAccess)getAccess.invoke(te, new Object[0]);
		if (turtle != null)
			return turtle;
	}
	return null;
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:13,代码来源:ReflectionHelper.java


示例18: update

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
@Override
public void update(ITurtleAccess turtle, TurtleSide side) {
	IPeripheral peripheral = turtle.getPeripheral(side);
	if (peripheral instanceof TileEntityNoteBlock) {
           ((TileEntityNoteBlock) peripheral).updateEntity(true);
       }
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:8,代码来源:TurtleNoteBlock.java


示例19: PeripheralTank

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public PeripheralTank(ITurtleAccess turtle, TurtleSide side) {
	this.turtle = turtle;
	this.side = side;

	if (!turtle.getWorld().isRemote) {
		NBTTagCompound turtleTag = turtle.getUpgradeNBTData(side);
		NBTTagCompound tankData = turtleTag.getCompoundTag("TankData");
		if (tankData != null) {
			fluidTank.readFromNBT(tankData);
		}
	}

}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:14,代码来源:PeripheralTank.java


示例20: PeripheralXP

import dan200.computercraft.api.turtle.ITurtleAccess; //导入依赖的package包/类
public PeripheralXP(ITurtleAccess turtleAccess, TurtleSide side) {
	turtle = turtleAccess;
	this.side = side;
	NBTTagCompound tag = turtle.getUpgradeNBTData(side);
	experience = tag.getInteger("experience");
	experienceRemainder = tag.getInteger("experienceRemainder");
	experienceLevel = tag.getInteger("experienceLevel");
	random.setSeed(tag.getLong("rndSeed"));
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:10,代码来源:PeripheralXP.java



注:本文中的dan200.computercraft.api.turtle.ITurtleAccess类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExtensionRegistry类代码示例发布时间:2022-05-23
下一篇:
Java UniqueCoordinateArrayFilter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap