类net.minecraft.util.math.BlockBox源码实例Demo

下面列出了怎么用net.minecraft.util.math.BlockBox的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Galacticraft-Rewoven   文件: MoonVillageStart.java
@Override
protected void setBoundingBoxFromChildren() {
    super.setBoundingBoxFromChildren();
    BlockBox var10000 = this.boundingBox;
    var10000.minX -= 12;
    var10000 = this.boundingBox;
    var10000.minY -= 12;
    var10000 = this.boundingBox;
    var10000.minZ -= 12;
    var10000 = this.boundingBox;
    var10000.maxX += 12;
    var10000 = this.boundingBox;
    var10000.maxY += 12;
    var10000 = this.boundingBox;
    var10000.maxZ += 12;
}
 
源代码2 项目: the-hallow   文件: LargeSkeletalTreeFeature.java
protected boolean generateBranch(Set<BlockPos> set, ModifiableTestableWorld world, Random random, BlockPos pos, BlockBox mibb, int maxBranchouts, Direction lastDir) {
	int baseHeight = random.nextInt(4) + 2;
	
	for (int int_4 = 0; int_4 < baseHeight; ++int_4) {
		BlockPos blockPos = pos.up(int_4 + 1);
		if (!isSurroundedByAir(world, blockPos, null)) {
			return true;
		}
		addLog(set, world, blockPos, Direction.Axis.Y, mibb);
	}
	
	int int_5 = random.nextInt(4) + 1;
	int int_1 = 8;
	
	if (maxBranchouts > 0)
		for (int int_6 = 0; int_6 < int_5; ++int_6) {
			Direction direction_1 = Direction.Type.HORIZONTAL.random(random);
			if (direction_1 == lastDir) continue;
			BlockPos blockPos_4 = pos.up(baseHeight).offset(direction_1);
			if (Math.abs(blockPos_4.getX() - pos.getX()) < int_1 && Math.abs(blockPos_4.getZ() - pos.getZ()) < int_1 && isAir(world, blockPos_4) && isAir(world, blockPos_4.down()) && isSurroundedByAir(world, blockPos_4, direction_1.getOpposite())) {
				addLog(set, world, blockPos_4, direction_1.getAxis(), mibb);
				generateBranch(set, world, random, blockPos_4, mibb, maxBranchouts - 1, direction_1.getOpposite());
			}
		}
	return true;
}
 
源代码3 项目: the-hallow   文件: SmallSkeletalTreeFeature.java
@Override
public boolean generate(ModifiableTestableWorld world, Random random, BlockPos pos, Set<BlockPos> logPositions, Set<BlockPos> leavesPositions, BlockBox blockBox, TreeFeatureConfig config) {
	if (!isPlantableOn(world, pos.down())) {
		return false;
	}
	int y;
	for (y = 0; y < random.nextInt(5) + 3; y++) {
		addLog(logPositions, world, pos.offset(Direction.UP, y), Direction.Axis.Y, blockBox);
	}
	if (random.nextBoolean()) {
		Direction direction = Direction.Type.HORIZONTAL.random(random);
		BlockPos top = pos.offset(Direction.UP, y);
		for (int i = 1; i < random.nextInt(3); i++) {
			addLog(logPositions, world, top.offset(direction, i), direction.getAxis(), blockBox);
		}
	}
	return true;
}
 
源代码4 项目: fabric-carpet   文件: FeatureGenerator.java
public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature<?> structure, boolean computeBox)
{
    ChunkGenerator<?> generator = world.getChunkManager().getChunkGenerator();
    if (!generator.getBiomeSource().hasStructureFeature(structure))
        return null;
    BiomeAccess biomeAccess = world.getBiomeAccess().withSource(generator.getBiomeSource());
    ChunkRandom chunkRandom = new ChunkRandom();
    ChunkPos chunkPos = new ChunkPos(pos);
    Biome biome = biomeAccess.getBiome(new BlockPos(chunkPos.getStartX() + 9, 0, chunkPos.getStartZ() + 9));
    if (structure.shouldStartAt(biomeAccess, generator, chunkRandom, chunkPos.x, chunkPos.z, biome))
    {
        if (!computeBox) return StructureStart.DEFAULT;
        StructureManager manager = world.getSaveHandler().getStructureManager();
        StructureStart structureStart3 = structure.getStructureStartFactory().create(structure, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, generator.getSeed());
        structureStart3.initialize(generator, manager, chunkPos.x, chunkPos.z, biome);
        if (!structureStart3.hasChildren()) return null;
        return structureStart3;
    }
    return null;
}
 
源代码5 项目: fabric-carpet   文件: CarpetExpression.java
private static Value structureToValue(StructureStart structure)
{
    if (structure == null || structure == StructureStart.DEFAULT) return Value.NULL;
    List<Value> pieces = new ArrayList<>();
    for (StructurePiece piece : structure.getChildren())
    {
        BlockBox box = piece.getBoundingBox();
        pieces.add(ListValue.of(
                new StringValue( NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_PIECE.getId(piece.getType()))),
                (piece.getFacing()== null)?Value.NULL: new StringValue(piece.getFacing().getName()),
                ListValue.fromTriple(box.minX, box.minY, box.minZ),
                ListValue.fromTriple(box.maxX, box.maxY, box.maxZ)
        ));
    };
    BlockBox boundingBox = structure.getBoundingBox();
    Map<Value, Value> ret = new HashMap<>();
    ret.put(new StringValue("box"), ListValue.of(
            ListValue.fromTriple(boundingBox.minX, boundingBox.minY, boundingBox.minZ),
            ListValue.fromTriple(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ)
    ));
    ret.put(new StringValue("pieces"), ListValue.wrap(pieces));
    return MapValue.wrap(ret);
}
 
源代码6 项目: the-hallow   文件: LargeDeadwoodTreeFeature.java
private void addLog(Set<BlockPos> posSet, ModifiableTestableWorld world, BlockPos pos, BlockBox bb) {
	if (canTreeReplace(world, pos)) {
		this.setBlockState(world, pos, LOG, bb);
		posSet.add(pos.toImmutable());
	}
	
}
 
源代码7 项目: the-hallow   文件: LargeDeadwoodTreeFeature.java
private void addLeaves(ModifiableTestableWorld world, int x, int y, int z, BlockBox bb, Set<BlockPos> posSet) {
	BlockPos pos = new BlockPos(x, y, z);
	if (isAir(world, pos)) {
		this.setBlockState(world, pos, LEAVES, bb);
		posSet.add(pos.toImmutable());
	}
	
}
 
源代码8 项目: fabric-carpet   文件: StructureFeatureMixin.java
private StructureStart forceStructureStart(IWorld worldIn, ChunkGenerator <? extends ChunkGeneratorConfig > generator, Random rand, long packedChunkPos)
{
    ChunkPos chunkpos = new ChunkPos(packedChunkPos);
    StructureStart structurestart;

    Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false);

    if (ichunk != null)
    {
        structurestart = ichunk.getStructureStart(this.getName());

        if (structurestart != null && structurestart != StructureStart.DEFAULT)
        {
            return structurestart;
        }
    }
    Biome biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
    StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,generator.getSeed());
    structurestart1.initialize(generator, ((ServerWorld)worldIn).getStructureManager() , chunkpos.x, chunkpos.z, biome_1);
    structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;

    if (structurestart.hasChildren())
    {
        worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart(this.getName(), structurestart);
    }

    //long2objectmap.put(packedChunkPos, structurestart);
    return structurestart;
}
 
源代码9 项目: Galacticraft-Rewoven   文件: MoonVillageStart.java
public MoonVillageStart(StructureFeature<StructurePoolFeatureConfig> structureFeature, int chunkX, int chunkZ, BlockBox blockBox, int i, long l) {
    super(structureFeature, chunkX, chunkZ, blockBox, i, l);
}
 
源代码10 项目: Galacticraft-Rewoven   文件: MoonVillagePiece.java
public MoonVillagePiece(StructureManager structureManager, StructurePoolElement structurePoolElement, BlockPos blockPos, int i, BlockRotation blockRotation, BlockBox blockBox) {
    super(GalacticraftStructurePieceTypes.MOON_VILLAGE, structureManager, structurePoolElement, blockPos, i, blockRotation, blockBox);
}
 
源代码11 项目: the-hallow   文件: LargeSkeletalTreeFeature.java
private void addLog(Set<BlockPos> set, ModifiableTestableWorld modifiableTestableWorld, BlockPos blockPos, Direction.Axis axis, BlockBox mutableIntBoundingBox) {
	if (canTreeReplace(modifiableTestableWorld, blockPos)) {
		set.add(blockPos);
		this.setBlockState(modifiableTestableWorld, blockPos, LOG.with(PillarBlock.AXIS, axis), mutableIntBoundingBox);
	}
}
 
源代码12 项目: the-hallow   文件: LargeSkeletalTreeFeature.java
@Override
protected boolean generate(ModifiableTestableWorld world, Random random, BlockPos pos, Set<BlockPos> logPositions, Set<BlockPos> leavesPositions, BlockBox blockBox, TreeFeatureConfig config) {
	if (!isPlantableOn(world, pos.down())) return false;
	generateBranch(logPositions, world, random, pos, blockBox, random.nextInt(4), null);
	return true;
}
 
源代码13 项目: the-hallow   文件: SmallSkeletalTreeFeature.java
private void addLog(Set<BlockPos> set, ModifiableTestableWorld modifiableTestableWorld, BlockPos blockPos, Direction.Axis axis, BlockBox mutableIntBoundingBox) {
	if (canTreeReplace(modifiableTestableWorld, blockPos)) {
		set.add(blockPos);
		this.setBlockState(modifiableTestableWorld, blockPos, LOG.with(PillarBlock.AXIS, axis), mutableIntBoundingBox);
	}
}
 
源代码14 项目: fabric-carpet   文件: ScriptCommand.java
private static int scriptScan(CommandContext<ServerCommandSource> context, BlockPos origin, BlockPos a, BlockPos b, String expr)
{
    ServerCommandSource source = context.getSource();
    CarpetScriptHost host = getHost(context);
    BlockBox area = new BlockBox(a, b);
    CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
    int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ();
    if (int_1 > CarpetSettings.fillLimit)
    {
        Messenger.m(source, "r too many blocks to evaluate: " + int_1);
        return 1;
    }
    int successCount = 0;
    CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
    try
    {
        for (int x = area.minX; x <= area.maxX; x++)
        {
            for (int y = area.minY; y <= area.maxY; y++)
            {
                for (int z = area.minZ; z <= area.maxZ; z++)
                {
                    try
                    {
                        if (cexpr.fillAndScanCommand(host, x, y, z)) successCount++;
                    }
                    catch (ArithmeticException ignored)
                    {
                    }
                }
            }
        }
    }
    catch (CarpetExpressionException exc)
    {
        host.handleErrorWithStack("Error while processing command", exc);
        return 0;
    }
    finally
    {
        CarpetSettings.impendingFillSkipUpdates = false;
    }
    Messenger.m(source, "w Expression successful in " + successCount + " out of " + int_1 + " blocks");
    return successCount;

}
 
源代码15 项目: fabric-carpet   文件: StructureFeatureMixin.java
@Override
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator, boolean wireOnly)
{
    if (world.isClient())
        return false;
    CarpetSettings.skipGenerationChecks = true;
    try
    {
        Random rand = new Random(world.getRandom().nextInt());
        int j = pos.getX() >> 4;
        int k = pos.getZ() >> 4;
        long chId = ChunkPos.toLong(j, k);
        StructureStart structurestart = forceStructureStart(world, generator, rand, chId);
        if (structurestart == StructureStart.DEFAULT)
        {
            return false;
        }
        //generator.ge   getStructurePositionToReferenceMap(this).computeIfAbsent(chId,
        //    (x) -> new LongOpenHashSet()).add(chId);
        world.getChunk(j, k).addStructureReference(this.getName(), chId);  //, ChunkStatus.STRUCTURE_STARTS

        BlockBox box = structurestart.getBoundingBox();
        if (!wireOnly)
        {
            structurestart.generateStructure(world, generator, rand,
                new BlockBox(
                            pos.getX() - this.getRadius() * 16,
                            pos.getZ() - this.getRadius() * 16,
                            pos.getX() + (this.getRadius() + 1) * 16,
                            pos.getZ() + (1 + this.getRadius()) * 16),
                    new ChunkPos(j, k)
            );
        }
        //structurestart.notifyPostProcessAt(new ChunkPos(j, k));

        int i = getRadius();
        for (int k1 = j - i; k1 <= j + i; ++k1)
        {
            for (int l1 = k - i; l1 <= k + i; ++l1)
            {
                if (k1 == j && l1 == k) continue;
                long nbchkid = ChunkPos.toLong(k1, l1);
                if (box.intersectsXZ(k1<<4, l1<<4, (k1<<4) + 15, (l1<<4) + 15))
                {
                    //generator.getStructurePositionToReferenceMap(this).computeIfAbsent(nbchkid, (__) -> new LongOpenHashSet()).add(chId);
                    world.getChunk(k1, l1).addStructureReference(this.getName(), chId); //, ChunkStatus.STRUCTURE_STARTS
                    //structurestart.  notifyPostProcessAt(new ChunkPos(k1, l1));
                }
            }
        }
    }
    catch (Exception booboo)
    {
        CarpetSettings.LOG.error("Unknown Exception while plopping structure: "+booboo);
        booboo.printStackTrace();
        return false;
    }
    finally
    {
        CarpetSettings.skipGenerationChecks = false;
    }
    return true;
}
 
 类所在包
 类方法
 同包方法