當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。