本文整理了Java中net.minecraft.util.math.BlockPos.subtract()
方法的一些代码示例,展示了BlockPos.subtract()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockPos.subtract()
方法的具体详情如下:
包路径:net.minecraft.util.math.BlockPos
类名称:BlockPos
方法名:subtract
暂无
代码示例来源:origin: ldtteam/minecolonies
/**
* Get the neighbor of the entity.
*
* @return the position, a blockPos.
*/
public BlockPos getNeighbor()
{
return pos.subtract(relativeNeighbor);
}
代码示例来源:origin: PrinceOfAmber/Cyclic
public static List<BlockPos> rotateShape(BlockPos posCenter, List<BlockPos> shapeInput, Rotation rot) {
if (rot == Rotation.NONE) {
return shapeInput;
}
List<BlockPos> shape = new ArrayList<BlockPos>();
BlockPos pRotated;
for (BlockPos p : shapeInput) {
pRotated = new BlockPos(p).subtract(posCenter).rotate(rot).add(posCenter);
shape.add(pRotated);
}
return shape;
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
public StructureBB expand(int x, int y, int z) {
min = min.subtract(new Vec3i(x, y, z));
max = max.add(x, y, z);
return this;
}
代码示例来源:origin: ldtteam/minecolonies
/**
* Define the neighbor for a block.
*
* @param neighbor the neighbor to define.
*/
public void setNeighbor(final BlockPos neighbor)
{
if ((single && neighbor != null) || (!single && neighbor == null))
{
single = neighbor == null;
markDirty();
}
if ((this.relativeNeighbor == null && neighbor != null) || (this.relativeNeighbor != null && neighbor != null
&& !this.relativeNeighbor.equals(this.pos.subtract(neighbor))))
{
this.relativeNeighbor = this.pos.subtract(neighbor);
markDirty();
}
}
}
代码示例来源:origin: RS485/LogisticsPipes
private InternalRayTraceResult doRayTraceMultiblock(LogisticsTileGenericPipe tileG, CoreMultiBlockPipe pipe, Vec3d start, Vec3d direction) {
if (tileG == null) return null;
if (!LogisticsBlockGenericPipe.isValid(pipe)) return null;
List<RayTraceResult> hits = new ArrayList<>();
List<AxisAlignedBB> boxes = new ArrayList<>();
pipe.addCollisionBoxesToList(boxes, null);
while (hits.size() < boxes.size()) {
hits.add(null);
}
for (int i = 0; i < boxes.size(); i++) {
AxisAlignedBB bb = boxes.get(i);
hits.set(i, super.rayTrace(tileG.getPos(), start, direction, bb.offset(BlockPos.ORIGIN.subtract(tileG.getPos()))));
}
return hits.stream()
.filter(Objects::nonNull)
.min(Comparator.comparing(r -> r.hitVec.squareDistanceTo(start)))
.map(r -> new InternalRayTraceResult(Part.PIPE, r, pipe.getCompleteBox(), null))
.orElse(null);
}
代码示例来源:origin: ldtteam/minecolonies
/**
* Load a structure into this world
* and place it in the right position and rotation.
*
* @param worldObj the world to load it in
* @param name the structures name
* @param pos coordinates
* @param rotations number of times rotated
* @param mirror the mirror used.
* @param complete paste it complete (with structure blocks) or without
*/
public static void loadAndPlaceStructureWithRotation(
final World worldObj, @NotNull final String name,
@NotNull final BlockPos pos, final int rotations, @NotNull final Mirror mirror,
final boolean complete)
{
try
{
@NotNull final StructureWrapper structureWrapper = new StructureWrapper(worldObj, name);
structureWrapper.position = pos;
structureWrapper.rotate(rotations, worldObj, pos, mirror);
structureWrapper.placeStructure(pos.subtract(structureWrapper.getOffset()), complete);
}
catch (final IllegalStateException e)
{
Log.getLogger().warn("Could not load structure!", e);
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
private @Nonnull FarmSlots mapBlockPosToSeedSlot(@Nonnull BlockPos pos) {
BlockPos offset = pos.subtract(getLocation());
if (offset.getX() <= 0 && offset.getZ() > 0) {
return FarmSlots.SEED1;
} else if (offset.getX() > 0 && offset.getZ() >= 0) {
return FarmSlots.SEED2;
} else if (offset.getX() < 0 && offset.getZ() <= 0) {
return FarmSlots.SEED3;
}
return FarmSlots.SEED4;
}
代码示例来源:origin: ldtteam/minecolonies
/**
* Get the other double chest or null.
*
* @return the tileEntity of the other half or null.
*/
public TileEntityRack getOtherChest()
{
if (relativeNeighbor == null || world == null)
{
return null;
}
final TileEntity tileEntity = world.getTileEntity(pos.subtract(relativeNeighbor));
if (tileEntity instanceof TileEntityRack)
{
((TileEntityRack) tileEntity).setNeighbor(this.getPos());
return (TileEntityRack) tileEntity;
}
return null;
}
代码示例来源:origin: ldtteam/minecolonies
/**
* Checks if the destination has been reached.
* Meaning that the avoid distance has been reached.
*
* @param n Node to test.
* @return true if so.
*/
@Override
protected boolean isAtDestination(@NotNull final Node n)
{
final BlockPos vector = n.pos.subtract(avoid);
final double nodeResult = getNodeResultScore(n);
final int avoidSq = (avoidDistance * avoidDistance);
return nodeResult >= avoidSq && (EnumFacing.getFacingFromVector(vector.getX(), 0, vector.getZ()).equals(direction) || nodeResult > avoidSq * avoidDistance);
}
代码示例来源:origin: Chisel-Team/Chisel
@Override
public Iterable<BlockPos> getCandidates(EntityPlayer player, BlockPos pos, EnumFacing side) {
if (side.getAxisDirection() == AxisDirection.NEGATIVE) {
side = side.getOpposite();
}
Vec3i offset = side.getDirectionVec();
return filteredIterable(Sets.newHashSet(BlockPos.getAllInBox(NEG_ONE.add(offset).add(pos), ONE.subtract(offset).add(pos))), player.world, player.world.getBlockState(pos));
}
代码示例来源:origin: ValkyrienWarfare/Valkyrien-Warfare-Revamped
public static void runFinishingTouches(PhysicsWrapperEntity wrapperEntity, Schematic lootGet) {
BlockPos centerInSchematic = new BlockPos(-(lootGet.width / 2), 128 - (lootGet.height / 2), -(lootGet.length / 2));
BlockPos centerDifference = wrapperEntity.wrapping.refrenceBlockPos.subtract(centerInSchematic);
BlockPos realSkyControllerPos = skyControllerPos.add(centerDifference);
BlockPos realSkulkerBoxPos = skulkerBoxPos.add(centerDifference);
wrapperEntity.world.setBlockState(realSkyControllerPos, ValkyrienWarfareWorld.INSTANCE.skydungeon_controller.getDefaultState());
wrapperEntity.yaw = Math.random() * 360D;
TileEntityShulkerBox skulkerTile = (TileEntityShulkerBox) wrapperEntity.world.getTileEntity(realSkulkerBoxPos);
ItemStack stack = ValkyrienWarfareWorld.INSTANCE.etheriumCrystal.getDefaultInstance().copy();
stack.stackSize = 5;
skulkerTile.setInventorySlotContents(new Random().nextInt(26), stack);
TileEntitySkyTempleController skyTile = (TileEntitySkyTempleController) wrapperEntity.world.getTileEntity(realSkyControllerPos);
skyTile.setOriginPos(new Vector(wrapperEntity.posX, wrapperEntity.posY, wrapperEntity.posZ));
}
}
代码示例来源:origin: CyclopsMC/EvilCraft
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return new AxisAlignedBB(getPos().subtract(new Vec3i(3, 3, 3)), getPos().add(3, 6, 3));
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
@Override
public boolean generate(World world, Random random, BlockPos position) {
BlockPos levelPos = getLevelPosition();
position = levelPos == null ? this.placeOnGround(world, position, this.getOffsetY()) : this.getGround(world, position).subtract(this.transformPos(levelPos, this.mirror, this.rotation));
if (position != null) {
this.generateStructure(world, random, position);
this.generateFiller(world, position);
return true;
}
return false;
}
代码示例来源:origin: TeamWizardry/Wizardry
default boolean buildStructure(World world, BlockPos pos) {
if (world.isRemote) return true;
for (Template.BlockInfo info : getStructure().getBlockInfos()) {
if (info.blockState == null) 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;
}
world.setBlockState(realPos, info.blockState);
}
}
return true;
}
}
代码示例来源:origin: ForestryMC/ForestryMC
private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorldObj();
BlockPos housingCoordinates = housing.getCoordinates();
Vec3i area = getModifiedArea(genome, housing);
Vec3i halfArea = new Vec3i(area.getX() / 2, area.getY() / 2, area.getZ() / 2);
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
BlockPos pos = VectUtil.getRandomPositionInArea(world.rand, area).subtract(halfArea).add(housingCoordinates);
if (world.isBlockLoaded(pos)) {
IBlockState blockState = world.getBlockState(pos);
if (convertToMycelium(world, blockState, pos)) {
return;
} else if (growGiantMushroom(world, blockState, pos)) {
return;
}
}
}
}
代码示例来源:origin: TeamWizardry/Wizardry
/**
* Will return a list of blocks that are incorrect. If this list is empty, the structure is complete.
*/
default Set<BlockPos> testStructure(World world, BlockPos pos) {
Set<BlockPos> errors = new HashSet<>();
for (Template.BlockInfo info : getStructure().getBlockInfos()) {
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;
}
errors.add(realPos);
}
}
return errors;
}
代码示例来源:origin: CyclopsMC/EvilCraft
public void setCenter(BlockPos center) {
EnumFacing rotation = EnumFacing.NORTH;
if(center.getX() != getPos().getX()) {
rotation = DirectionHelpers.getEnumFacingFromXSign(center.getX() - getPos().getX());
} else if(center.getZ() != getPos().getZ()) {
rotation = DirectionHelpers.getEnumFacingFromZSing(center.getZ() - getPos().getZ());
}
this.setRotation(rotation);
this.renderOffset = getPos().subtract(center);
}
代码示例来源:origin: TeamWizardry/Wizardry
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder helix = new ParticleBuilder(200);
helix.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
helix.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f));
ParticleSpawner.spawn(helix, world, new StaticInterp<>(new Vec3d(interacterFrom.getPos()).add(0.5, 1, 0.5)), 1, 0, (someFloat, particleBuilder) -> {
particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(50, 200)));
particleBuilder.setScale(RandUtil.nextFloat(0.3f, 0.8f));
particleBuilder.setPositionFunction(new InterpBezier3D(Vec3d.ZERO, new Vec3d(getPos().subtract(interacterFrom.getPos())), new Vec3d(0, 5, 0), new Vec3d(0, -5, 0)));
particleBuilder.setLifetime(RandUtil.nextInt(50, 60));
});
}
});
代码示例来源:origin: ExtraCells/ExtraCells2
IWirelessAccessPoint accessPoint = (IWirelessAccessPoint) node
.getMachine();
BlockPos distance = accessPoint.getLocation().getPos().subtract(pos);
int squaredDistance = distance.getX() * distance.getX() + distance.getY() * distance.getY() + distance.getZ() * distance.getZ();
if (squaredDistance <= accessPoint.getRange() * accessPoint.getRange()) {
代码示例来源:origin: TeamWizardry/Wizardry
public static void COLORFUL_BATTERY_BEZIER(World world, BlockPos pedestal, BlockPos center) {
ParticleBuilder glitter = new ParticleBuilder(200);
glitter.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFloatInOut(0.5f, 0.3f));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(new Vec3d(pedestal).add(0.5, 1, 0.5)), 1, 0, (aFloat, particleBuilder) -> {
glitter.setColorFunction(new InterpColorHSV(ColorUtils.changeColorAlpha(Color.BLUE, RandUtil.nextInt(100, 150)), ColorUtils.changeColorAlpha(Color.CYAN, RandUtil.nextInt(100, 150))));
glitter.setScale(RandUtil.nextFloat());
glitter.setPositionFunction(new InterpBezier3D(Vec3d.ZERO, new Vec3d(center.subtract(pedestal)), new Vec3d(0, 3, 0), new Vec3d(0, 5, 0)));
glitter.setScaleFunction(new InterpScale(1, 0.4f));
glitter.setLifetime(RandUtil.nextInt(10, 30));
});
}
内容来源于网络,如有侵权,请联系作者删除!