下面列出了net.minecraft.util.math.BlockPos#MutableBlockPos ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void decorate(World worldIn, Random rand, BlockPos pos) {
super.decorate(worldIn, rand, pos);
int j, k, l, i1;
if (rand.nextInt(30) == 0) {
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
for (j = 0; j < 5; j++) {
k = pos.getX() + rand.nextInt(16) + 8;
l = rand.nextInt(128);
i1 = pos.getZ() + rand.nextInt(16) + 8;
mutable.setPos(k, l, i1);
WorldGenerator var6 = new WorldGenBush(BlockLoader.TOFUFLOWER);
var6.generate(worldIn, rand, mutable);
}
}
}
/**
* Discover the y coordinate that will serve as the ground level of the supplied BoundingBox. (A median of
* all the levels in the BB's horizontal rectangle).
*/
protected int getAverageGroundLevel(World worldIn, StructureBoundingBox structurebb) {
int i = 0;
int j = 0;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int k = this.boundingBox.minZ; k <= this.boundingBox.maxZ; ++k) {
for (int l = this.boundingBox.minX; l <= this.boundingBox.maxX; ++l) {
blockpos$mutableblockpos.setPos(l, 64, k);
if (structurebb.isVecInside(blockpos$mutableblockpos)) {
i += Math.max(worldIn.getTopSolidOrLiquidBlock(blockpos$mutableblockpos).getY(), worldIn.provider.getAverageGroundLevel() - 1);
++j;
}
}
}
if (j == 0) {
return -1;
} else {
return i / j;
}
}
@Override
public boolean generate(World par1World, Random par2Random, BlockPos pos) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
for (int l = 0; l < 64; ++l)
{
int i1 = x + par2Random.nextInt(8) - par2Random.nextInt(8);
int j1 = y + par2Random.nextInt(4) - par2Random.nextInt(4);
int k1 = z + par2Random.nextInt(8) - par2Random.nextInt(8);
mutable.setPos(i1, j1, k1);
IBlockState state = this.getStateToPlace();
if (par1World.isAirBlock(mutable) && this.plantBlock.canBlockStay(par1World, mutable, state))
{
par1World.setBlockState(mutable, state, 2);
}
}
return true;
}
/**
* Returns the min and max corners of the enclosing box around the given collection of boxes.
* The minimum corner is the left entry and the maximum corner is the right entry of the pair.
* @param boxes
* @return
*/
@Nullable
public static Pair<BlockPos, BlockPos> getEnclosingAreaCornersForRegions(Collection<ISchematicRegion> regions)
{
if (regions.isEmpty())
{
return null;
}
BlockPos.MutableBlockPos posMin = new BlockPos.MutableBlockPos(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
BlockPos.MutableBlockPos posMax = new BlockPos.MutableBlockPos(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
BlockPos.MutableBlockPos posEnd = new BlockPos.MutableBlockPos();
for (ISchematicRegion region : regions)
{
BlockPos pos = region.getPosition();
Vec3i endRel = getRelativeEndPositionFromAreaSize(region.getSize());
posEnd.setPos(pos.getX() + endRel.getX(), pos.getY() + endRel.getY(), pos.getZ() + endRel.getZ());
getMinMaxCoords(posMin, posMax, pos);
getMinMaxCoords(posMin, posMax, posEnd);
}
return Pair.of(posMin.toImmutable(), posMax.toImmutable());
}
private boolean entityFits(Entity entityIn, int x, int y, int z) {
BlockPos.MutableBlockPos mutableblockpos = new BlockPos.MutableBlockPos();
for (int i = x; i < x + entitySizeX; ++i) {
for (int j = y; j < y + entitySizeY; ++j) {
for (int k = z; k < z + entitySizeZ; ++k) {
IBlockState bs = blockaccess.getBlockState(mutableblockpos.setPos(i, j, k));
if (bs.getMaterial() != Material.AIR) {
AxisAlignedBB bb = bs.getCollisionBoundingBox(entityIn.world, mutableblockpos);
if(bb != null) {
return false;
}
}
}
}
}
return true;
}
@Override
public void decorate(World worldIn, Random randomIn, BlockPos pos)
{
super.decorate(worldIn, randomIn, pos);
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
for (int k = 0; k < 1; ++k)
{
int x = pos.getX() + randomIn.nextInt(16) + 8;
int z = pos.getZ() + randomIn.nextInt(16) + 8;
int y = worldIn.getHeight(x, z) - 1;
mutable.setPos(x, y, z);
// TOO LAG
// if (y > 80 && worldIn.getBlockState(mutable).getBlock() == BlockLoader.tofuTerrain)
// {
// if (worldIn.getBlockState(mutable.east()).getBlock() == BlockLoader.tofuTerrain
// && worldIn.getBlockState(mutable.south()).getBlock() == BlockLoader.tofuTerrain
// && worldIn.getBlockState(mutable.west()).getBlock() == BlockLoader.tofuTerrain
// && worldIn.getBlockState(mutable.north()).getBlock() == BlockLoader.tofuTerrain)
// {
// int h = randomIn.nextInt(3) + 3;
// for (int i = 0; i < h; i++)
// {
// worldIn.setBlockState(new BlockPos(mutable.setPos(x, y + i, z)), BlockLoader.SOYMILK.getDefaultState(), 2);
// }
// }
// }
}
}
@Override
public boolean isEntityInsideOpaqueBlock() {
if (noClip) {
return false;
} else {
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
for (int i = 0; i < 8; ++i) {
int x = MathHelper.floor(posX + ((i >> 1) % 2 - 0.5F) * width * 0.8F);
int y = MathHelper.floor(posY + ((i >> 0) % 2 - 0.5F) * 0.1F + getEyeHeight());
// I added this check as it was sometimes clipping into the block above
if (y > getEntityBoundingBox().maxY) {
y = MathHelper.floor(getEntityBoundingBox().maxY);
}
int z = MathHelper.floor(posZ + ((i >> 2) % 2 - 0.5F) * width * 0.8F);
if (pos.getX() != x || pos.getY() != y || pos.getZ() != z) {
pos.setPos(x, y, z);
if (world.getBlockState(pos).isOpaqueCube()) {
return true;
}
}
}
return false;
}
}
protected void countBlocksInChunkRespectingLayerRange(ChunkPos pos, LayerRange range)
{
EnumFacing.Axis axis = range.getAxis();
BlockPos.MutableBlockPos posMutable = new BlockPos.MutableBlockPos();
for (IntBoundingBox bb : this.getBoxesInChunk(pos))
{
final int startX = axis == EnumFacing.Axis.X ? Math.max(bb.minX, range.getLayerMin()) : bb.minX;
final int startY = axis == EnumFacing.Axis.Y ? Math.max(bb.minY, range.getLayerMin()) : bb.minY;
final int startZ = axis == EnumFacing.Axis.Z ? Math.max(bb.minZ, range.getLayerMin()) : bb.minZ;
final int endX = axis == EnumFacing.Axis.X ? Math.min(bb.maxX, range.getLayerMax()) : bb.maxX;
final int endY = axis == EnumFacing.Axis.Y ? Math.min(bb.maxY, range.getLayerMax()) : bb.maxY;
final int endZ = axis == EnumFacing.Axis.Z ? Math.min(bb.maxZ, range.getLayerMax()) : bb.maxZ;
for (int y = startY; y <= endY; ++y)
{
for (int z = startZ; z <= endZ; ++z)
{
for (int x = startX; x <= endX; ++x)
{
posMutable.setPos(x, y, z);
this.countAtPosition(posMutable);
}
}
}
}
}
public static boolean isPlacementWithinWorld(World world, SchematicPlacement schematicPlacement, boolean respectRenderRange)
{
LayerRange range = DataManager.getRenderLayerRange();
BlockPos.MutableBlockPos posMutable1 = new BlockPos.MutableBlockPos();
BlockPos.MutableBlockPos posMutable2 = new BlockPos.MutableBlockPos();
for (Box box : schematicPlacement.getSubRegionBoxes(RequiredEnabled.PLACEMENT_ENABLED).values())
{
if (respectRenderRange)
{
if (range.intersectsBox(box.getPos1(), box.getPos2()))
{
IntBoundingBox bb = range.getClampedArea(box.getPos1(), box.getPos2());
if (bb != null)
{
posMutable1.setPos(bb.minX, bb.minY, bb.minZ);
posMutable2.setPos(bb.maxX, bb.maxY, bb.maxZ);
if (arePositionsWithinWorld(world, posMutable1, posMutable2) == false)
{
return false;
}
}
}
}
else if (isBoxWithinWorld(world, box) == false)
{
return false;
}
}
return true;
}
protected void buildTofu(BlockPos pos, int height, World worldIn, Random rand)
{
int ox = pos.getX();
int oy = pos.getY();
int oz = pos.getZ();
int radius = 1 + height / 2;
BlockPos.MutableBlockPos mutablepos = new BlockPos.MutableBlockPos();
for (int blockY = oy; blockY <= oy + height; ++blockY)
{
for (int blockX = ox - radius; blockX <= ox + radius; ++blockX)
{
for (int blockZ = oz - radius; blockZ <= oz + radius; ++blockZ)
{
if (blockY == oy)
{
for (int y = oy - 1; y > 0; y--)
{
mutablepos.setPos(blockX, y, blockZ);
Block blockId = worldIn.getBlockState(mutablepos).getBlock();
if (blockId == Blocks.AIR || blockId == BlockLoader.LEEK)
{
this.setBlockAndNotifyAdequately(worldIn, mutablepos, this.blockTofuState);
}
else
{
break;
}
}
}
mutablepos.setPos(blockX, blockY, blockZ);
this.setBlockAndNotifyAdequately(worldIn, mutablepos, this.blockTofuState);
}
}
}
mutablepos.setPos(ox, oy + height + 1, oz);
this.plantLeeks(mutablepos, radius, worldIn, rand);
}
public boolean generate(World worldIn, Random rand, BlockPos position)
{
int i = rand.nextInt(3) + 4;
boolean flag = true;
if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight())
{
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
{
int k = 1;
if (j == position.getY())
{
k = 0;
}
if (j >= position.getY() + 1 + i - 2)
{
k = 2;
}
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
{
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
{
if (j >= 0 && j < worldIn.getHeight())
{
if (!this.isReplaceable(worldIn,blockpos$mutableblockpos.setPos(l, j, i1)))
{
flag = false;
}
}
else
{
flag = false;
}
}
}
}
if (!flag)
{
return false;
}
else
{
IBlockState state = worldIn.getBlockState(position.down());
int j1;
if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, BlockLoader.TOFU_SAPLING) && position.getY() < worldIn.getHeight() - i - 1)
{
state.getBlock().onPlantGrow(state, worldIn, position.down(), position);
for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3)
{
j1 = i / 3;
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1)
{
for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2)
{
BlockPos blockpos = new BlockPos(k1, i3, i2);
state = worldIn.getBlockState(blockpos);
if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, BlockLoader.TOFU_LEAVE.getDefaultState());
}
}
}
}
for (int j3 = 0; j3 < i; ++j3)
{
BlockPos upN = position.up(j3);
state = worldIn.getBlockState(upN);
if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE)
{
this.setBlockAndNotifyAdequately(worldIn, position.up(j3), BlockLoader.ISHITOFU.getDefaultState());
}
}
return true;
}
else
{
return false;
}
}
}
else
{
return false;
}
}
public boolean generate(World worldIn, Random rand, BlockPos position) {
int i = rand.nextInt(3) + 4;
boolean flag = true;
if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
int k = 1;
if (j == position.getY()) {
k = 0;
}
if (j >= position.getY() + 1 + i - 2) {
k = 2;
}
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
if (j >= 0 && j < worldIn.getHeight()) {
if (!this.isReplaceable(worldIn, blockpos$mutableblockpos.setPos(l, j, i1))) {
flag = false;
}
} else {
flag = false;
}
}
}
}
if (!flag) {
return false;
} else {
IBlockState state = worldIn.getBlockState(position.down());
if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, BlockLoader.APRICOT_SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
state.getBlock().onPlantGrow(state, worldIn, position.down(), position);
for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) {
int i4 = i3 - (position.getY() + i);
int j1 = 1 - i4 / 2;
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) {
int l1 = k1 - position.getX();
for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) {
int j2 = i2 - position.getZ();
if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) {
BlockPos blockpos = new BlockPos(k1, i3, i2);
state = worldIn.getBlockState(blockpos);
if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
this.setBlockAndNotifyAdequately(worldIn, blockpos, BlockLoader.APRICOT_LEAVE.getDefaultState());
}
}
}
}
}
for (int j3 = 0; j3 < i; ++j3) {
BlockPos upN = position.up(j3);
state = worldIn.getBlockState(upN);
if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
this.setBlockAndNotifyAdequately(worldIn, position.up(j3), Blocks.LOG.getDefaultState());
}
}
return true;
} else {
return false;
}
}
} else {
return false;
}
}
private static Set<BlockPos> allLiquidInPool(World world, BlockPos pos, int needed, Fluid fluid) {
if (needed <= 0) return Sets.newHashSet();
Block block = fluid.getBlock();
if (block == null) return Sets.newHashSet();
IBlockState sourceBlock = block.getDefaultState();
BlockPos.MutableBlockPos topPos = new BlockPos.MutableBlockPos(pos);
IBlockState stateAt = world.getBlockState(topPos);
boolean lastWasFluid = false;
while (stateAt.getBlock() == block) {
lastWasFluid = stateAt == sourceBlock;
stateAt = world.getBlockState(topPos.setPos(topPos.getX(), topPos.getY() + 1, topPos.getZ()));
}
topPos.setPos(topPos.getX(), topPos.getY() - 1, topPos.getZ());
BlockPos.MutableBlockPos tool = new BlockPos.MutableBlockPos();
Set<BlockPos> positions = Sets.newHashSet(topPos.toImmutable());
Set<BlockPos> visited = Sets.newHashSet(positions);
Set<BlockPos> resultants = Sets.newHashSet();
if (lastWasFluid)
resultants.addAll(positions);
while (resultants.size() < needed && !positions.isEmpty() && visited.size() < 1000) {
BlockPos point = positions.iterator().next();
positions.remove(point);
for (int index = EnumFacing.VALUES.length - 1; index >= 0; index--) {
EnumFacing facing = EnumFacing.byIndex(index);
tool.setPos(point.getX() + facing.getXOffset(),
point.getY() + facing.getYOffset(),
point.getZ() + facing.getZOffset());
if (!visited.contains(tool)) {
BlockPos immutable = tool.toImmutable();
visited.add(immutable);
stateAt = world.getBlockState(tool);
if (stateAt.getBlock() == block) {
positions.add(immutable);
if (stateAt == sourceBlock) {
resultants.add(immutable);
if (resultants.size() >= needed)
return resultants;
}
}
}
}
}
return resultants;
}
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
EnumFacing faceHit = spell.getFaceHit();
Set<BlockPos> blockSet = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCK_SET, new BlockSet(new HashSet<>())).getBlockSet();
Map<BlockPos, IBlockState> blockStateCache = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCKSTATE_CACHE, new BlockStateCache(new HashMap<>())).getBlockStateCache();
HashMap<BlockPos, IBlockState> tmpCache = new HashMap<>(blockStateCache);
double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 20;
PhasedBlockRenderer.addPhase(world, blockSet, (int) duration);
if (faceHit != null) {
for (Map.Entry<BlockPos, IBlockState> entry : tmpCache.entrySet()) {
IBlockState thisState = entry.getValue();
if (thisState.getBlock() != ModBlocks.FAKE_AIR) continue;
ParticleBuilder glitter2 = new ParticleBuilder(10);
glitter2.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter2.disableRandom();
ParticleSpawner.spawn(glitter2, world, new StaticInterp<>(new Vec3d(entry.getKey()).add(0.5, 0.5, 0.5)), 5, (int) duration, (aFloat, build) -> {
build.setColor(Color.CYAN);
//build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f));
build.setAlpha(RandUtil.nextFloat(0.05f, 0.2f));
build.setPositionOffset(new Vec3d(
RandUtil.nextDouble(-0.5, 0.5),
RandUtil.nextDouble(-0.5, 0.5),
RandUtil.nextDouble(-0.5, 0.5)
));
build.setMotion(new Vec3d(
RandUtil.nextDouble(-0.001, 0.001),
RandUtil.nextDouble(-0.001, 0.001),
RandUtil.nextDouble(-0.001, 0.001)
));
build.setLifetime(RandUtil.nextInt(20, 40));
build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f));
build.setScale(RandUtil.nextFloat(0.1f, 0.3f));
});
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(entry.getKey());
for (EnumFacing facing : EnumFacing.VALUES) {
mutable.move(facing);
IBlockState adjState;
if (!blockStateCache.containsKey(mutable)) {
adjState = world.getBlockState(mutable);
blockStateCache.put(mutable.toImmutable(), adjState);
} else adjState = blockStateCache.get(mutable);
if (adjState.getBlock() != Blocks.AIR && adjState.getBlock() != ModBlocks.FAKE_AIR) {
Vec3d directionOffsetVec = new Vec3d(facing.getOpposite().getDirectionVec()).scale(0.5);
Vec3d adjPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec);
for (EnumFacing subFacing : getPerpendicularFacings(facing)) {
mutable.move(subFacing);
IBlockState subState;
if (!blockStateCache.containsKey(mutable)) {
subState = world.getBlockState(mutable);
blockStateCache.put(mutable.toImmutable(), subState);
} else subState = blockStateCache.get(mutable);
if (BlockUtils.isAnyAir(subState)) {
Vec3d subPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec);
Vec3d midPointVec = new Vec3d(
(adjPos.x + subPos.x) / 2.0,
(adjPos.y + subPos.y) / 2.0,
(adjPos.z + subPos.z) / 2.0);
Vec3d sub = subPos.subtract(adjPos);
EnumFacing adjSubFacing = EnumFacing.getFacingFromVector((float) sub.x, (float) sub.y, (float) sub.z);
Vec3d cross = new Vec3d(adjSubFacing.getDirectionVec()).crossProduct(new Vec3d(facing.getDirectionVec())).normalize().scale(0.5);
ParticleBuilder glitter = new ParticleBuilder(10);
glitter.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.disableRandom();
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(midPointVec), 50, (int) duration, (aFloat, build) -> {
build.setColor(Color.CYAN);
//build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f));
build.setAlpha(RandUtil.nextFloat(0.3f, 0.7f));
build.setPositionOffset(cross.scale(RandUtil.nextFloat(-1, 1)));
build.setLifetime(RandUtil.nextInt(20, 40));
build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f));
build.setScale(RandUtil.nextFloat(0.2f, 0.5f));
});
}
mutable.move(subFacing.getOpposite());
}
}
mutable.move(facing.getOpposite());
}
}
}
}
private void deleteArea(ItemStack stack, World world, EntityPlayer player, BlockPos posStart, BlockPos posEnd, boolean removeEntities)
{
if (posStart == null || posEnd == null)
{
return;
}
if (player.getDistanceSq(posStart) > 160 * 160)
{
player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoofar"), true);
return;
}
if (this.isAreaWithinSizeLimit(posStart.subtract(posEnd), stack, player) == false)
{
player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoolarge"), true);
return;
}
// Set all blocks to air
for (BlockPos.MutableBlockPos posMutable : BlockPos.getAllInBoxMutable(posStart, posEnd))
{
if (world.isAirBlock(posMutable) == false)
{
BlockUtils.setBlockToAirWithoutSpillingContents(world, posMutable, 2);
}
}
// Remove pending block updates from within the area
BlockPos posMin = PositionUtils.getMinCorner(posStart, posEnd);
BlockPos posMax = PositionUtils.getMaxCorner(posStart, posEnd).add(1, 1, 1);
StructureBoundingBox sbb = StructureBoundingBox.createProper(posMin.getX(), posMin.getY(), posMin.getZ(), posMax.getX(), posMax.getY(), posMax.getZ());
world.getPendingBlockUpdates(sbb, true); // The boolean parameter indicates whether the entries will be removed
// Remove all entities within the area
int count = 0;
if (removeEntities)
{
int x1 = Math.min(posStart.getX(), posEnd.getX());
int y1 = Math.min(posStart.getY(), posEnd.getY());
int z1 = Math.min(posStart.getZ(), posEnd.getZ());
int x2 = Math.max(posStart.getX(), posEnd.getX());
int y2 = Math.max(posStart.getY(), posEnd.getY());
int z2 = Math.max(posStart.getZ(), posEnd.getZ());
AxisAlignedBB bb = new AxisAlignedBB(x1, y1, z1, x2 + 1, y2 + 1, z2 + 1);
List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, bb);
for (Entity entity : entities)
{
if ((entity instanceof EntityPlayer) == false || entity instanceof FakePlayer)
{
entity.setDead();
count++;
}
}
if (count > 0)
{
player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.killedentitieswithcount", count), true);
}
}
}
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
int i = worldIn.getSeaLevel();
IBlockState iblockstate = this.topBlock;
IBlockState iblockstate1 = this.fillerBlock;
int j = -1;
int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
int l = x & 15;
int i1 = z & 15;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int j1 = 255; j1 >= 0; --j1) {
if (j1 <= rand.nextInt(5)) {
chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
} else {
IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);
if (iblockstate2.getMaterial() == Material.AIR) {
j = -1;
} else if (iblockstate2.getBlock() == Blocks.STONE) {
if (j == -1) {
if (k <= 0) {
iblockstate = AIR;
iblockstate1 = STONE;
} else if (j1 >= i - 4 && j1 <= i + 1) {
iblockstate = this.topBlock;
iblockstate1 = this.fillerBlock;
}
if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) {
if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) {
iblockstate = ICE;
} else {
iblockstate = WATER;
}
}
j = k;
if (j1 >= i - 1) {
chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
} else if (j1 < i - 7 - k) {
iblockstate = AIR;
iblockstate1 = STONE;
chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
} else {
chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
}
} else if (j > 0) {
--j;
chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) {
j = rand.nextInt(4) + Math.max(0, j1 - 63);
iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
}
if (j == 0 && iblockstate == redRock && k > 1) {
j = rand.nextInt(4) + Math.max(0, j1 - 63);
iblockstate = redRock;
}
if (j == 0 && iblockstate1 == redRock && k > 1) {
j = rand.nextInt(4) + Math.max(0, j1 - 63);
iblockstate1 = redRock;
}
}
}
}
}
}
public boolean generate(World worldIn, Random rand, BlockPos position) {
int num = rand.nextInt(5);
EnumFacing orientation;
if (num == 0) {
orientation = EnumFacing.EAST;
stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
} else if (num == 1) {
orientation = EnumFacing.WEST;
stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
} else if (num == 1) {
orientation = EnumFacing.SOUTH;
stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
} else {
orientation = EnumFacing.NORTH;
stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
}
int i = rand.nextInt(2) + this.minTreeLength;
boolean flag = true;
if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
int k = 1;
if (j == position.getY()) {
k = 0;
}
if (j >= position.getY() + 1 + i - 2) {
k = 2;
}
BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
if (j >= 0 && j < worldIn.getHeight()) {
if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) {
flag = false;
}
} else {
flag = false;
}
}
}
}
if (!flag) {
return false;
} else {
IBlockState state = worldIn.getBlockState(position.down());
if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
state.getBlock().onPlantGrow(state, worldIn, position.down(), position);
for (int j3 = 0; j3 < i; ++j3) {
BlockPos offsetPos = position.offset(orientation, j3);
state = worldIn.getBlockState(offsetPos);
if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) {
this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood);
}
}
return true;
} else {
return false;
}
}
} else {
return false;
}
}
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
int i = worldIn.getSeaLevel();
IBlockState iblockstate = this.topBlock;
IBlockState iblockstate1 = this.fillerBlock;
int j = -1;
int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
int l = x & 15;
int i1 = z & 15;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int j1 = 255; j1 >= 0; --j1) {
if (j1 <= rand.nextInt(5)) {
chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
} else {
IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);
if (iblockstate2.getMaterial() == Material.AIR) {
j = -1;
} else if (iblockstate2.getBlock() == Blocks.STONE) {
if (j == -1) {
if (k <= 0) {
iblockstate = AIR;
iblockstate1 = STONE;
} else if (j1 >= i - 4 && j1 <= i + 1) {
iblockstate = this.topBlock;
iblockstate1 = this.fillerBlock;
}
if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) {
if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) {
iblockstate = ICE;
} else {
iblockstate = WATER;
}
}
j = k;
if (j1 >= i - 1) {
chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
} else if (j1 < i - 7 - k) {
iblockstate = AIR;
iblockstate1 = STONE;
chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
} else {
chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
}
} else if (j > 0) {
--j;
chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) {
j = rand.nextInt(4) + Math.max(0, j1 - 63);
iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
}
if (j == 0 && iblockstate == redRock && k > 1) {
j = rand.nextInt(4) + Math.max(0, j1 - 63);
iblockstate = redRock;
}
if (j == 0 && iblockstate1 == redRock && k > 1) {
j = rand.nextInt(4) + Math.max(0, j1 - 63);
iblockstate1 = redRock;
}
}
}
}
}
}
protected void fillBoxDirect(IntBoundingBox box, boolean removeEntities)
{
if (removeEntities)
{
AxisAlignedBB aabb = new AxisAlignedBB(box.minX, box.minY, box.minZ, box.maxX + 1, box.maxY + 1, box.maxZ + 1);
List<Entity> entities = this.world.getEntitiesInAABBexcluding(this.mc.player, aabb, EntityUtils.NOT_PLAYER);
for (Entity entity : entities)
{
if ((entity instanceof EntityPlayer) == false)
{
entity.setDead();
}
}
}
try
{
WorldUtils.setShouldPreventBlockUpdates(this.world, true);
IBlockState barrier = Blocks.BARRIER.getDefaultState();
BlockPos.MutableBlockPos posMutable = new BlockPos.MutableBlockPos();
for (int z = box.minZ; z <= box.maxZ; ++z)
{
for (int x = box.minX; x <= box.maxX; ++x)
{
for (int y = box.maxY; y >= box.minY; --y)
{
posMutable.setPos(x, y, z);
IBlockState oldState = this.world.getBlockState(posMutable).getActualState(this.world, posMutable);
if ((this.replaceState == null && oldState != this.fillState) || oldState == this.replaceState)
{
TileEntity te = this.world.getTileEntity(posMutable);
if (te instanceof IInventory)
{
((IInventory) te).clear();
this.world.setBlockState(posMutable, barrier, 0x12);
}
this.world.setBlockState(posMutable, this.fillState, 0x12);
}
}
}
}
}
finally
{
WorldUtils.setShouldPreventBlockUpdates(this.world, false);
}
}
@Override
public void render(TileOrbHolder te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
if (te.containsCell()) {
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5);
GlStateManager.disableRescaleNormal();
float sin = (float) Math.sin((ClientTickHandler.getTicks() + partialTicks + te.getPos().hashCode()) / 10.0);
boolean gravitating = false;
// Hover towards block
if (te.containsCell()) {
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(te.getPos());
for (int i = -6; i < 6; i++)
for (int j = -6; j < 6; j++)
for (int k = -6; k < 6; k++) {
pos.setPos(te.getPos().getX() + i, te.getPos().getY() + j, te.getPos().getZ() + k);
Block block = te.getWorld().getBlockState(pos).getBlock();
if (te.containsCell() && block == ModBlocks.MANA_BATTERY) {
gravitating = true;
Vec3d direction = new Vec3d(te.getPos()).subtract(new Vec3d(pos)).normalize();
GlStateManager.translate(sin * direction.x / 5.0, sin * direction.y / 5.0, sin * direction.z / 5.0);
break;
}
}
}
if (!gravitating) GlStateManager.translate(0, sin / 10.0, 0);
GlStateManager.rotate((ClientTickHandler.getTicks() + partialTicks) * 4.0f, 0, 1, 0);
GlStateManager.translate(0, 0.6, 0);
GlStateManager.rotate(45f, 1, 0, 1);
{
GlStateManager.disableCull();
GlStateManager.enableLighting();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
RenderHelper.disableStandardItemLighting();
if (te.containsCell()) {
Color c = new Color(1f, 1f, 1f, (float) (ManaManager.getMana(te.getWizardryCap()) / ManaManager.getMaxMana(te.getWizardryCap())));
Minecraft.getMinecraft().getTextureManager().bindTexture(manaOrb);
renderCube(0.13, c);
Minecraft.getMinecraft().getTextureManager().bindTexture(glassOrb);
renderCube(0.135, new Color(1, 1, 1, 0.8f));
}
GlStateManager.disableRescaleNormal();
}
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}