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


Java Template.BlockInfo方法代码示例

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


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

示例1: processBlock

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
@Nullable
public Template.BlockInfo processBlock(World world, BlockPos pos, Template.BlockInfo blockInfo)
{
	Template.BlockInfo newBlockInfo;
	
    //if (blockInfo.blockState.getBlock() == ModBlocks.DUNGEON_BRICK)
    //{
    //	newBlockInfo = new Template.BlockInfo(pos, Blocks.PLANKS.getDefaultState(), blockInfo.tileentityData);
    //}
    //else
    //{
    	newBlockInfo = blockInfo;
    //}
	
	return this.chance < 1.0F && this.random.nextFloat() > this.chance ? null : newBlockInfo;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:17,代码来源:DungeonBlockProcessor.java

示例2: renderIntoWorld

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
public void renderIntoWorld(World world, BlockPos basePos, float partialTicks)
{
	if(!world.isRemote)
		return;
	if(blocks.size() > 30000)
        return;
	for(Template.BlockInfo block : blocks){
		if(block.blockState.getBlock() != Blocks.AIR)
			HarshenClientUtils.renderGhostBlock(block.blockState, basePos.add(block.pos), false, partialTicks);
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:12,代码来源:HarshenTemplateRenderer.java

示例3: getDataBlocks

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn)
{
    Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap();
    StructureBoundingBox structureboundingbox = placementIn.getBoundingBox();

    for (Template.BlockInfo template$blockinfo : this.blocks)
    {
        BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos);

        if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos))
        {
            IBlockState iblockstate = template$blockinfo.blockState;

            if (iblockstate.getBlock() instanceof BlockStructure && template$blockinfo.tileentityData != null)
            {
                TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode"));

                if (tileentitystructure$mode == TileEntityStructure.Mode.DATA)
                {
                    map.put(blockpos, template$blockinfo.tileentityData.getString("metadata"));
                }
            }
        }
    }

    return map;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:28,代码来源:HarshenTemplate.java

示例4: isStructureComplete

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
default boolean isStructureComplete(World world, BlockPos pos) {
	for (Template.BlockInfo info : getStructure().blockInfos()) {
		if (info.blockState == null) continue;
		if (info.blockState.getMaterial() == Material.AIR || info.blockState.getBlock() == Blocks.STRUCTURE_VOID)
			continue;

		BlockPos realPos = info.pos.add(pos).subtract(offsetToCenter());
		IBlockState state = world.getBlockState(realPos);
		if (state != info.blockState) {

			if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
				continue;
			}

			if (info.blockState.getBlock() instanceof BlockStairs && state.getBlock() instanceof BlockStairs
					&& info.blockState.getBlock() == state.getBlock()
					&& info.blockState.getValue(BlockStairs.HALF) == state.getValue(BlockStairs.HALF)
					&& info.blockState.getValue(BlockStairs.SHAPE) == state.getValue(BlockStairs.SHAPE)) {
				if (info.blockState.getValue(BlockStairs.FACING) != state.getValue(BlockStairs.FACING))
					world.setBlockState(realPos, info.blockState);
				continue;
			}
			return false;
		}
	}
	return true;
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:28,代码来源:IStructure.java

示例5: getErroredBlocks

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
default HashSet<BlockPos> getErroredBlocks(World world, BlockPos pos) {
	HashSet<BlockPos> set = new HashSet<>();

	for (Template.BlockInfo info : getStructure().blockInfos()) {
		if (info.blockState == null) continue;
		if (info.blockState.getMaterial() == Material.AIR || info.blockState.getBlock() == Blocks.STRUCTURE_VOID)
			continue;

		BlockPos realPos = info.pos.add(pos).subtract(offsetToCenter());
		IBlockState state = world.getBlockState(realPos);
		if (state != info.blockState) {

			if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
				continue;
			}

			if (info.blockState.getBlock() instanceof BlockStairs && state.getBlock() instanceof BlockStairs
					&& info.blockState.getBlock() == state.getBlock()
					&& info.blockState.getValue(BlockStairs.HALF) == state.getValue(BlockStairs.HALF)
					&& info.blockState.getValue(BlockStairs.SHAPE) == state.getValue(BlockStairs.SHAPE)) {
				continue;
			}
			set.add(realPos);
		}
	}
	return set;
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:28,代码来源:IStructure.java

示例6: takeBlocksFromWorld

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
/**
 * takes blocks from the world and puts the data them into this template
 */
public void takeBlocksFromWorld(World worldIn, BlockPos actualPosition, BlockPos startPos, BlockPos endPos, boolean takeEntities, @Nullable Block toIgnore)
{
    if (endPos.getX() >= 1 && endPos.getY() >= 1 && endPos.getZ() >= 1)
    {
        BlockPos blockpos = startPos.add(endPos).add(-1, -1, -1);
        List<Template.BlockInfo> list = Lists.<Template.BlockInfo>newArrayList();
        List<Template.BlockInfo> list1 = Lists.<Template.BlockInfo>newArrayList();
        List<Template.BlockInfo> list2 = Lists.<Template.BlockInfo>newArrayList();
        BlockPos blockpos1 = new BlockPos(Math.min(startPos.getX(), blockpos.getX()), Math.min(startPos.getY(), blockpos.getY()), Math.min(startPos.getZ(), blockpos.getZ()));
        BlockPos blockpos2 = new BlockPos(Math.max(startPos.getX(), blockpos.getX()), Math.max(startPos.getY(), blockpos.getY()), Math.max(startPos.getZ(), blockpos.getZ()));
        this.size = endPos;
        this.pos = actualPosition;

        for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos1, blockpos2))
        {
            BlockPos blockpos3 = blockpos$mutableblockpos.subtract(blockpos1);
            IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

            if (toIgnore == null || toIgnore != iblockstate.getBlock())
            {
                TileEntity tileentity = worldIn.getTileEntity(blockpos$mutableblockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
                    nbttagcompound.removeTag("x");
                    nbttagcompound.removeTag("y");
                    nbttagcompound.removeTag("z");
                    list1.add(new Template.BlockInfo(blockpos3, iblockstate, nbttagcompound));
                }
                else if (!iblockstate.isFullBlock() && !iblockstate.isFullCube())
                {
                    list2.add(new Template.BlockInfo(blockpos3, iblockstate, (NBTTagCompound)null));
                }
                else
                {
                    list.add(new Template.BlockInfo(blockpos3, iblockstate, (NBTTagCompound)null));
                }
            }
        }

        this.blocks.clear();
        this.blocks.addAll(list);
        this.blocks.addAll(list1);
        this.blocks.addAll(list2);

        if (takeEntities)
        {
            this.takeEntitiesFromWorld(worldIn, blockpos1, blockpos2.add(1, 1, 1));
        }
        else
        {
            this.entities.clear();
        }
    }
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:60,代码来源:HarshenTemplate.java

示例7: writeToNBT

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
{
    BasicPalette template$basicpalette = new BasicPalette();
    NBTTagList nbttaglist = new NBTTagList();

    for (Template.BlockInfo template$blockinfo : this.blocks)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setTag("pos", this.writeInts(template$blockinfo.pos.getX(), template$blockinfo.pos.getY(), template$blockinfo.pos.getZ()));
        nbttagcompound.setInteger("state", template$basicpalette.idFor(template$blockinfo.blockState));

        if (template$blockinfo.tileentityData != null)
        {
            nbttagcompound.setTag("nbt", template$blockinfo.tileentityData);
        }

        nbttaglist.appendTag(nbttagcompound);
    }

    NBTTagList nbttaglist1 = new NBTTagList();

    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setTag("pos", this.writeDoubles(template$entityinfo.pos.x, template$entityinfo.pos.y, template$entityinfo.pos.z));
        nbttagcompound1.setTag("blockPos", this.writeInts(template$entityinfo.blockPos.getX(), template$entityinfo.blockPos.getY(), template$entityinfo.blockPos.getZ()));

        if (template$entityinfo.entityData != null)
        {
            nbttagcompound1.setTag("nbt", template$entityinfo.entityData);
        }

        nbttaglist1.appendTag(nbttagcompound1);
    }

    NBTTagList nbttaglist2 = new NBTTagList();

    for (IBlockState iblockstate : template$basicpalette)
    {
        nbttaglist2.appendTag(NBTUtil.writeBlockState(new NBTTagCompound(), iblockstate));
    }

    nbt.setTag("palette", nbttaglist2);
    nbt.setTag("blocks", nbttaglist);
    nbt.setTag("entities", nbttaglist1);
    nbt.setTag("size", this.writeInts(this.size.getX(), this.size.getY(), this.size.getZ()));
    nbt.setTag("pos", this.writeInts(this.pos.getX(), this.pos.getY(), this.pos.getZ()));
    nbt.setString("author", this.author);
    nbt.setInteger("DataVersion", 1241);
    net.minecraftforge.fml.common.FMLCommonHandler.instance().getDataFixer().writeVersionData(nbt);
    return nbt;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:53,代码来源:HarshenTemplate.java

示例8: tickStructure

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
default boolean tickStructure(World world, EntityPlayer player, BlockPos pos) {
	if (world.isRemote) return true;

	for (Template.BlockInfo info : getStructure().blockInfos()) {
		if (info.blockState == null) continue;

		BlockPos realPos = info.pos.add(pos).subtract(offsetToCenter());
		IBlockState state = world.getBlockState(realPos);
		if (state.getBlock() != info.blockState.getBlock()) {

			if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
				continue;
			}

			if (player.isCreative()) {
				world.setBlockState(realPos, info.blockState);
			} else {
				if (world.isAirBlock(realPos)) {
					ItemStack requiredStack = new ItemStack(info.blockState.getBlock());
					ItemStack stack = findItemInventoryFromItem(player, requiredStack);

					if (stack.isEmpty()) {
						ItemStack outputItem = craftItemFromInventory(player, requiredStack);

						if (outputItem.isEmpty()) continue;
						outputItem.shrink(1);
						player.inventory.addItemStackToInventory(outputItem);
						player.inventory.markDirty();
						world.setBlockState(realPos, info.blockState);
						return true;
					} else {
						stack.shrink(1);
						world.setBlockState(realPos, info.blockState);
						return true;
					}
				}
			}
		} else if (world.getBlockState(realPos) != info.blockState) {
			if (player.isCreative() || !info.blockState.getMaterial().isLiquid()) {
				world.setBlockState(realPos, info.blockState);
				return true;
			} else {
				FluidStack fluidStack = new FluidStack(FluidRegistry.lookupFluidForBlock(info.blockState.getBlock()), 1);
				ItemStack fluidBucket = findItemInventoryFromItem(player, FluidUtil.getFilledBucket(fluidStack));
				if (!fluidBucket.isEmpty()) {
					fluidBucket.shrink(1);
					player.addItemStackToInventory(new ItemStack(Items.BUCKET));
					player.inventory.markDirty();
					world.setBlockState(realPos, info.blockState);
					return true;
				}
			}
		}
	}
	return true;
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:57,代码来源:IStructure.java

示例9: ComponentStructureList

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
public ComponentStructureList(Structure structure) {
	super(0, 0, 200, 300);
	Deque<Block> sorted = new ArrayDeque<>();
	HashMap<Block, Integer> ingredients = new HashMap<>();
	HashMap<Block, IBlockState> access = new HashMap<>();

	for (Template.BlockInfo info : structure.blockInfos()) {
		if (info.blockState.getBlock() == Blocks.AIR) continue;

		ingredients.putIfAbsent(info.blockState.getBlock(), 0);
		ingredients.put(info.blockState.getBlock(), ingredients.get(info.blockState.getBlock()) + 1);
		access.putIfAbsent(info.blockState.getBlock(), info.blockState);

		if (!sorted.contains(info.blockState.getBlock())) sorted.add(info.blockState.getBlock());
	}


	ComponentVoid recipe = new ComponentVoid(0, 0, 200, 300);
	recipe.getTransform().setScale(2);
	add(recipe);

	ComponentText text = new ComponentText(0, 3, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.TOP);
	text.setSize(new Vec2d(200, 16));
	text.getText().setValue(" " + LibrarianLib.PROXY.translate("wizardry.misc.structure_materials"));
	recipe.add(text);

	ComponentSprite lineBreak = new ComponentSprite(BookGui.LINE_BREAK, (int) (getSize().getX() / 2.0 - 177.0 / 2.0), 30, 177, 2);
	add(lineBreak);

	int i = 0;
	int row = 0;
	while (!sorted.isEmpty() && sorted.peek() != null) {

		Block nextBlock = sorted.pop();
		ItemStack stack;
		if (FluidRegistry.lookupFluidForBlock(nextBlock) != null) {
			stack = FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.lookupFluidForBlock(nextBlock), 1));
			stack = new ItemStack(stack.getItem(), ingredients.get(nextBlock), stack.getMetadata(), stack.getTagCompound());
		} else {
			NonNullList<ItemStack> itemStacks = NonNullList.create();
			nextBlock.getDrops(itemStacks, structure.getBlockAccess(), null, access.get(nextBlock), 0);
			if (itemStacks.isEmpty())
				stack = new ItemStack(nextBlock, ingredients.get(nextBlock));
			else {
				stack = itemStacks.get(0);
				stack.setCount(ingredients.get(nextBlock));
			}
		}

		ComponentStack componentStack = new ComponentStack(i * 16, 20 + row * 16);
		componentStack.getStack().setValue(stack);
		recipe.add(componentStack);

		if (i++ > 4) {
			i = 0;
			row++;
		}
	}
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:60,代码来源:ComponentStructureList.java

示例10: test

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
public void test() {

		Template.BlockInfo template$blockinfo1 = null;
		BlockPos blockpos = null;
		World world = null;

		TileEntity tileEntity2 = TileEntity.create(world, template$blockinfo1.tileentityData);

		world.setTileEntity(blockpos, tileEntity2);
	}
 
开发者ID:modmuss50,项目名称:StructureUtils,代码行数:11,代码来源:StructureTransformer.java


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