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


Java BlockPos.subtract方法代码示例

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


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

示例1: postAddition

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void postAddition(World world, BlockPos pos, Random random) {
	pos = pos.subtract(originAddition);
	world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[random.nextInt(4)]), 3);
	if(world instanceof WorldServer && world.getTileEntity(pos) != null)
	{
		TileEntityChest chest = (TileEntityChest)world.getTileEntity(pos);
		chest.setInventorySlotContents(13, HarshenUtils.getItemsFromLootTable(world, HarshenLootTables.shrine).get(0));
		for(ItemStack stack : HarshenUtils.getItemsFromLootPool(world, HarshenLootTables.shrine, "extras"))
			for(int count = 0; count < stack.getCount(); count++)
			{
				int slot = new Random().nextInt(27);
				while(chest.getStackInSlot(slot).getItem() != Item.getItemFromBlock(Blocks.AIR))
					slot = new Random().nextInt(27);
				ItemStack stack1 = stack.copy();
				stack1.setCount(1);
				chest.setInventorySlotContents(slot, stack1);
			}
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:21,代码来源:Shrine.java

示例2: linkToFlag

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
 * Tries to link this flag with the flag at the given position. May override existing links.
 * 
 * @param flagPos - The other flag's {@link net.minecraft.util.math.BlockPos position}.
 */
public void linkToFlag(BlockPos flagPos) {

	/* Check whether new position has a survey flag tile. */
	TileEntity tile = worldObj.getTileEntity(flagPos); 
	if (tile instanceof TileEntitySurveyFlag) {

		TileEntitySurveyFlag tileFlag = (TileEntitySurveyFlag) tile;

		/* If a link exists, clear it. */
		if (linkedCurve != null) {
			tile = worldObj.getTileEntity(linkedCurve.endPos.add(this.pos));
			if (tile instanceof TileEntitySurveyFlag) {
				((TileEntitySurveyFlag) tile).clearFlagLinking();	
			}
		}

		/* Create new link and synchronise. */
		linkedCurve = new OFTCurve(flagPos.subtract(this.pos), rotation*45, tileFlag.rotation*45);
		OFT.OFTNet.sendToAll(new TileEntitySyncPacket(this));
	}
}
 
开发者ID:DonBruce64,项目名称:OpenFlexiTrack,代码行数:27,代码来源:TileEntitySurveyFlag.java

示例3: onBlockPlacedBy

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState s, EntityLivingBase placer, ItemStack stack) {
	if(!world.isRemote) {
		BlockPos vec = new BlockPos(8, 8, 8);
		BlockPos from = pos.add(vec);
		BlockPos to = pos.subtract(vec);
		getTile(TileHyperConductor.class, world, pos).ifPresent(tile -> {
			BlockPos.getAllInBox(from, to).forEach(tile::addElectron);
		});
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:12,代码来源:BlockHyperConductor.java

示例4: onBlockAdded

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
	if(!world.isRemote) {
		BlockPos vec = new BlockPos(8, 8, 8);
		BlockPos from = pos.add(vec);
		BlockPos to = pos.subtract(vec);
		BlockPos.getAllInBox(from, to).forEach(p ->
				getTile(TileHyperConductor.class, world, p).ifPresent(conductor -> conductor.addElectron(pos))
		);
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:12,代码来源:BlockElectron.java

示例5: calculateConnectedPos

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public BlockPos calculateConnectedPos(PlacementSettings placementIn, BlockPos p_186262_2_, PlacementSettings p_186262_3_, BlockPos p_186262_4_)
{
    BlockPos blockpos = transformedBlockPos(placementIn, p_186262_2_);
    BlockPos blockpos1 = transformedBlockPos(p_186262_3_, p_186262_4_);
    return blockpos.subtract(blockpos1);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:7,代码来源:HarshenTemplate.java


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