当前位置: 首页>>代码示例>>Java>>正文


Java IWrenchable.setFacing方法代码示例

本文整理汇总了Java中ic2.api.tile.IWrenchable.setFacing方法的典型用法代码示例。如果您正苦于以下问题:Java IWrenchable.setFacing方法的具体用法?Java IWrenchable.setFacing怎么用?Java IWrenchable.setFacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ic2.api.tile.IWrenchable的用法示例。


在下文中一共展示了IWrenchable.setFacing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rotateBlock

import ic2.api.tile.IWrenchable; //导入方法依赖的package包/类
@Override
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
	if (axis == ForgeDirection.UNKNOWN) return false;

	TileEntity tileEntity = worldObj.getBlockTileEntity(x, y, z);

	if (tileEntity instanceof IWrenchable) {
		IWrenchable te = (IWrenchable)tileEntity;

		int newFacing = ForgeDirection.getOrientation(te.getFacing()).getRotation(axis).ordinal();

		if (te.wrenchCanSetFacing(null, newFacing)) {
			te.setFacing((short)newFacing);
		}
	}

	return false;
}
 
开发者ID:Gaarnik,项目名称:bsamod,代码行数:19,代码来源:ThermalGeneratorMachBlock.java

示例2: isWrenchClicked

import ic2.api.tile.IWrenchable; //导入方法依赖的package包/类
public static boolean isWrenchClicked(TileEntity tileEntity, EntityPlayer player, int side) {
	if (player != null && tileEntity != null) {
		ItemStack equipped = player.getCurrentEquippedItem();

		if (equipped != null) {
			boolean ic2Wrench = IC2NuclearControl.instance.crossIc2.isWrench(equipped);
			boolean bcWrench = IC2NuclearControl.instance.crossBC.isWrench(equipped, tileEntity, player);// TODO: DMF
			if (player.isSneaking() && tileEntity instanceof IRotation) {
				if (ic2Wrench || bcWrench) {
					if (bcWrench) {
						IC2NuclearControl.instance.crossBC.useWrench(equipped, tileEntity, player);
					}

					if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
						((IRotation) tileEntity).rotate();
					}
					return true;
				}
			}else if (bcWrench && tileEntity instanceof IWrenchable){
				IWrenchable wrenchable = (IWrenchable) tileEntity;

				if (player.isSneaking()) {
					side += side % 2 * -2 + 1;
				}

				if (wrenchable.wrenchCanSetFacing(player, side)) {  //TODO: yo Xbony2, the thing with wrenches only working BC wise... right here!
					IC2NuclearControl.instance.crossBC.useWrench(equipped, tileEntity, player);
					if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
						wrenchable.setFacing((short) side);
					}
					return true;
				}
			}
		}
	}
	return false;
}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:38,代码来源:WrenchHelper.java

示例3: onBlockPlacedBy

import ic2.api.tile.IWrenchable; //导入方法依赖的package包/类
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack item, int metadata) {
	TileEntity block = world.getTileEntity(x, y, z);
	int side = metadata >> 8;
	metadata = metadata & 0xff;
	if (metadata > BlockDamages.DAMAGE_MAX) {
		metadata = 0;
	}

	if (block instanceof IWrenchable) {
		IWrenchable wrenchable = (IWrenchable) block;
		wrenchable.setFacing((short) side);
		if (player != null && !isSolidBlockRequired(metadata)) {
			int rotationSegment = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
			if (player.rotationPitch >= 65) {
				wrenchable.setFacing((short) 1);
			} else if (player.rotationPitch <= -65) {
				wrenchable.setFacing((short) 0);
			} else {
				switch (rotationSegment) {
				case 0:
					wrenchable.setFacing((short) 2);
					break;
				case 1:
					wrenchable.setFacing((short) 5);
					break;
				case 2:
					wrenchable.setFacing((short) 3);
					break;
				case 3:
					wrenchable.setFacing((short) 4);
					break;
				default:
					wrenchable.setFacing((short) 0);
					break;
				}
			}
		}
	}
}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:40,代码来源:BlockNuclearControlMain.java


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