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() == Blocks.STRUCTURE_BLOCK && 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;
}
java类net.minecraft.world.gen.structure.StructureBoundingBox的实例源码
Template.java 文件源码
项目:Backmemed
阅读 31
收藏 0
点赞 0
评论 0
Template.java 文件源码
项目:Backmemed
阅读 29
收藏 0
点赞 0
评论 0
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
for (Template.EntityInfo template$entityinfo : this.entities)
{
BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);
if (aabb == null || aabb.isVecInside(blockpos))
{
NBTTagCompound nbttagcompound = template$entityinfo.entityData;
Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
NBTTagList nbttaglist = new NBTTagList();
nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord));
nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord));
nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord));
nbttagcompound.setTag("Pos", nbttaglist);
nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
Entity entity;
try
{
entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
}
catch (Exception var15)
{
entity = null;
}
if (entity != null)
{
float f = entity.getMirroredYaw(mirrorIn);
f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch);
worldIn.spawnEntityInWorld(entity);
}
}
}
}
WorldGenFossils.java 文件源码
项目:Backmemed
阅读 21
收藏 0
点赞 0
评论 0
public boolean generate(World worldIn, Random rand, BlockPos position)
{
Random random = worldIn.getChunkFromBlockCoords(position).getRandomWithSeed(987234911L);
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
Rotation[] arotation = Rotation.values();
Rotation rotation = arotation[random.nextInt(arotation.length)];
int i = random.nextInt(FOSSILS.length);
TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]);
Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]);
ChunkPos chunkpos = new ChunkPos(position);
StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd());
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random);
BlockPos blockpos = template.transformedSize(rotation);
int j = random.nextInt(16 - blockpos.getX());
int k = random.nextInt(16 - blockpos.getZ());
int l = 256;
for (int i1 = 0; i1 < blockpos.getX(); ++i1)
{
for (int j1 = 0; j1 < blockpos.getX(); ++j1)
{
l = Math.min(l, worldIn.getHeight(position.getX() + i1 + j, position.getZ() + j1 + k));
}
}
int k1 = Math.max(l - 15 - random.nextInt(10), 10);
BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation);
placementsettings.setIntegrity(0.9F);
template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
placementsettings.setIntegrity(0.1F);
template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
return true;
}
TileEntityStructure.java 文件源码
项目:Backmemed
阅读 21
收藏 0
点赞 0
评论 0
public boolean detectSize()
{
if (this.mode != TileEntityStructure.Mode.SAVE)
{
return false;
}
else
{
BlockPos blockpos = this.getPos();
int i = 80;
BlockPos blockpos1 = new BlockPos(blockpos.getX() - 80, 0, blockpos.getZ() - 80);
BlockPos blockpos2 = new BlockPos(blockpos.getX() + 80, 255, blockpos.getZ() + 80);
List<TileEntityStructure> list = this.getNearbyCornerBlocks(blockpos1, blockpos2);
List<TileEntityStructure> list1 = this.filterRelatedCornerBlocks(list);
if (list1.size() < 1)
{
return false;
}
else
{
StructureBoundingBox structureboundingbox = this.calculateEnclosingBoundingBox(blockpos, list1);
if (structureboundingbox.maxX - structureboundingbox.minX > 1 && structureboundingbox.maxY - structureboundingbox.minY > 1 && structureboundingbox.maxZ - structureboundingbox.minZ > 1)
{
this.position = new BlockPos(structureboundingbox.minX - blockpos.getX() + 1, structureboundingbox.minY - blockpos.getY() + 1, structureboundingbox.minZ - blockpos.getZ() + 1);
this.size = new BlockPos(structureboundingbox.maxX - structureboundingbox.minX - 1, structureboundingbox.maxY - structureboundingbox.minY - 1, structureboundingbox.maxZ - structureboundingbox.minZ - 1);
this.markDirty();
IBlockState iblockstate = this.world.getBlockState(blockpos);
this.world.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 3);
return true;
}
else
{
return false;
}
}
}
}
MannCoBuilding.java 文件源码
项目:Mods
阅读 22
收藏 0
点赞 0
评论 0
@Override
public Village buildComponent(PieceWeight villagePiece, Start startPiece, List<StructureComponent> pieces,
Random random, int p1, int p2, int p3, EnumFacing facing, int p5) {
StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0,
0, 0, 14, 16, 11, facing);
return canVillageGoDeeper(structureboundingbox)
&& StructureComponent.findIntersecting(pieces, structureboundingbox) == null
? new MannCoBuilding(startPiece, p5, random, structureboundingbox, facing) : null;
}
WorldServer.java 文件源码
项目:CustomWorldGen
阅读 22
收藏 0
点赞 0
评论 0
@Nullable
public List<NextTickListEntry> getPendingBlockUpdates(Chunk chunkIn, boolean p_72920_2_)
{
ChunkPos chunkpos = chunkIn.getChunkCoordIntPair();
int i = (chunkpos.chunkXPos << 4) - 2;
int j = i + 16 + 2;
int k = (chunkpos.chunkZPos << 4) - 2;
int l = k + 16 + 2;
return this.getPendingBlockUpdates(new StructureBoundingBox(i, 0, k, j, 256, l), p_72920_2_);
}
PlacementSettings.java 文件源码
项目:CustomWorldGen
阅读 17
收藏 0
点赞 0
评论 0
@Nullable
public StructureBoundingBox getBoundingBox()
{
if (this.boundingBox == null && this.chunk != null)
{
this.setBoundingBoxFromChunk();
}
return this.boundingBox;
}
PlacementSettings.java 文件源码
项目:CustomWorldGen
阅读 21
收藏 0
点赞 0
评论 0
@Nullable
private StructureBoundingBox getBoundingBoxFromChunk(@Nullable ChunkPos pos)
{
if (pos == null)
{
return null;
}
else
{
int i = pos.chunkXPos * 16;
int j = pos.chunkZPos * 16;
return new StructureBoundingBox(i, 0, j, i + 16 - 1, 255, j + 16 - 1);
}
}
Template.java 文件源码
项目:CustomWorldGen
阅读 27
收藏 0
点赞 0
评论 0
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() == Blocks.STRUCTURE_BLOCK && 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;
}
Template.java 文件源码
项目:CustomWorldGen
阅读 34
收藏 0
点赞 0
评论 0
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
for (Template.EntityInfo template$entityinfo : this.entities)
{
BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);
if (aabb == null || aabb.isVecInside(blockpos))
{
NBTTagCompound nbttagcompound = template$entityinfo.entityData;
Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
NBTTagList nbttaglist = new NBTTagList();
nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord));
nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord));
nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord));
nbttagcompound.setTag("Pos", nbttaglist);
nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
Entity entity;
try
{
entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
}
catch (Exception var15)
{
entity = null;
}
if (entity != null)
{
float f = entity.getMirroredYaw(mirrorIn);
f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch);
worldIn.spawnEntityInWorld(entity);
}
}
}
}