本文整理汇总了Java中net.minecraft.util.math.BlockPos.MutableBlockPos类的典型用法代码示例。如果您正苦于以下问题:Java MutableBlockPos类的具体用法?Java MutableBlockPos怎么用?Java MutableBlockPos使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutableBlockPos类属于net.minecraft.util.math.BlockPos包,在下文中一共展示了MutableBlockPos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assignConstructionBlocks
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
* builds the block array using the representation map and the layout(String[]...)
* String = x-line
* String[] = z-line
* String[]... = y-line
* @param layer the layout of the blocks.
* @exception NullPointerException the layout is missing a map
*/
public void assignConstructionBlocks(String[]... layer)
{
final int xsz = layer[0][0].length();
final int ysz = layer.length;
final int zsz = layer[0].length;
conBlocks = new IBlockState[xsz][ysz][zsz];
for (final MutableBlockPos local : BlockPos.getAllInBoxMutable(BlockPos.ORIGIN, new BlockPos(xsz-1, ysz-1, zsz-1)))
{
final char c = layer[local.getY()][local.getZ()].charAt(local.getX());
if (!conDef.containsKey(c) && c != '-')
{
throw new StructureDefinitionError("Map missing '" + c + "' @" + local);
}
conBlocks[local.getX()][local.getY()][local.getZ()] = c == '-' ? null : conDef.get(c);
}
}
示例2: assignConstructionStateBlocks
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
* builds the state array using the representation map and the layout(String[]...)
* String = x-line
* String[] = z-line
* String[]... = y-line
* @param layer the layout of the states.
* @exception NullPointerException the layout is missing a map
*/
public void assignConstructionStateBlocks(String[]... layer)
{
final int xsz = layer[0][0].length();
final int ysz = layer.length;
final int zsz = layer[0].length;
state = new String[xsz][ysz][zsz];
for (final MutableBlockPos local : BlockPos.getAllInBoxMutable(BlockPos.ORIGIN, new BlockPos(xsz-1, ysz-1, zsz-1)))
{
final char c = layer[local.getY()][local.getZ()].charAt(local.getX());
if (!repState.containsKey(c) && c != ' ')
{
throw new StructureDefinitionError("Map missing '" + c + "' @" + local);
}
state[local.getX()][local.getY()][local.getZ()] = repState.get(c);
}
}
示例3: mutLocalToGlobal
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public static void mutLocalToGlobal(MutableBlockPos local,
BlockPos global,
EnumFacing orientation, boolean ismirrored,
BlockPos strucSize)
{
final int rotIndex = orientation.ordinal()-2;
if (rotIndex < 0 || rotIndex > 3) return; //should not happen. who screwed up
if (ismirrored)
{
mutSetX(local, local.getX() * -1);
if (strucSize.getX() % 2 == 0) mutSetX(local, 1 + local.getX());
}
final int rx = rotationMatrix[rotIndex][0][0] * local.getX() + rotationMatrix[rotIndex][0][1] * local.getZ();
final int rz = rotationMatrix[rotIndex][1][0] * local.getX() + rotationMatrix[rotIndex][1][1] * local.getZ();
local.setPos(
global.getX() + rx,
global.getY() + local.getY(),
global.getZ() + rz
);
}
示例4: breakStructure
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public void breakStructure(World world, BlockPos origin, EnumFacing orientation, boolean mirror, boolean isCreative, boolean isSneaking)
{
for (final MutableBlockPos local : getPattern().getStructureItr())
{
if (getPattern().hasBlockAt(local))
{
final IBlockState block = getPattern().getBlock(local).getBlockState();
mutLocalToGlobal(local, origin, orientation, mirror, getPattern().getBlockBounds());
final IBlockState worldBlock = world.getBlockState(local);
if (worldBlock.getBlock() instanceof StructureBlock || worldBlock.getBlock() instanceof StructureShapeBlock)
{
world.removeTileEntity(local);
world.setBlockState(new BlockPos(local), (isCreative && !isSneaking) ?
Blocks.AIR.getDefaultState() :
localToGlobal(block, orientation, mirror)
, 0x2);
}
}
}
}
示例5: includedPositions
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
* All positions included in the region. Excludes interior positions if hollow, and excludes any excluded positions.
*/
public Iterable<MutableBlockPos> includedPositions()
{
return new Iterable<BlockPos.MutableBlockPos>()
{
public Iterator<BlockPos.MutableBlockPos> iterator()
{
return new AbstractIterator<BlockPos.MutableBlockPos>()
{
Iterator<BlockPos.MutableBlockPos> wrapped = positions().iterator();
protected BlockPos.MutableBlockPos computeNext()
{
while(wrapped.hasNext())
{
BlockPos.MutableBlockPos result = wrapped.next();
if(exclusions == null || !exclusions.contains(result)) return result;
}
return (BlockPos.MutableBlockPos)this.endOfData();
}
};
}
};
}
示例6: getOffsetPosition
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
* Returns the MutableBlockPos <b>pos</b> with a position set to <b>posReference</b> offset by <b>amount</b> in the direction <b>side</b>.
*/
public static MutableBlockPos getOffsetPosition(MutableBlockPos pos, BlockPos posReference, EnumFacing side, int amount)
{
switch (side)
{
case NORTH:
pos.setPos(posReference.getX(), posReference.getY(), posReference.getZ() - amount);
case SOUTH:
pos.setPos(posReference.getX(), posReference.getY(), posReference.getZ() + amount);
case EAST:
pos.setPos(posReference.getX() + amount, posReference.getY(), posReference.getZ());
case WEST:
pos.setPos(posReference.getX() - amount, posReference.getY(), posReference.getZ());
case UP:
pos.setPos(posReference.getX(), posReference.getY() + amount, posReference.getZ());
case DOWN:
pos.setPos(posReference.getX(), posReference.getY() - amount, posReference.getZ());
}
return pos;
}
示例7: handleHarvest
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
public boolean handleHarvest(IBetterChest chest, IBlockState state, World world, BlockPos pos) {
MutableBlockPos start = new MutableBlockPos(pos);
while (canBreak(world, start)) {
start.move(EnumFacing.UP);
}
start.move(EnumFacing.DOWN);
if (start.getY() >= pos.getY()) {
BlockPos target = search(world, pos);
IBlockState targetState = world.getBlockState(target);
targetState.getBlock().breakBlock(world, pos, state);
PlantHarvestHelper.breakBlockHandleDrop(world, target, targetState, chest);
return true;
}
return false;
}
示例8: spawnFlowers
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@SubscribeEvent
public void spawnFlowers(PlayerTickEvent evt) {
if (evt.side == Side.SERVER && evt.phase == Phase.START) {
World w = evt.player.world;
if (w.getTotalWorldTime() % 20 == 0 && validBiomesMoonBell.contains(w.getBiome(evt.player.getPosition()))) {
Random r = evt.player.getRNG();
if (w.provider.getDimension() == 0 && w.provider.getMoonPhase(w.getWorldTime()) == 4 && !w.isDaytime() && evt.player.getRNG().nextDouble() < 0.2) {
int dx = (r.nextInt(7) - 3) * 10;
int dz = (r.nextInt(7) - 3) * 10;
MutableBlockPos pos = new MutableBlockPos(evt.player.getPosition().add(dx, 0, dz));
tryAndSpawn(w, pos);
}
}
}
}
示例9: tryAndSpawn
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
private void tryAndSpawn(World w, MutableBlockPos p) {
int oy = p.getY();
for (int dy = -5; dy <= 5; dy++) {
p.setY(oy + dy);
if ((w.isAirBlock(p) || w.getBlockState(p).getBlock().isReplaceable(w, p)) && w.getBlockState(p.down()).getBlock() == Blocks.DIRT) {
w.setBlockState(p, this.getDefaultState().withProperty(placed, false), 3);
return;
}
}
}
示例10: readFromNBT
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
if (nbt.hasKey("current"))
this.current = new MutableBlockPos(BlockPos.fromLong(nbt.getLong("current")));
}
示例11: getBlockState
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
* Gets the clean error checked block state
* @param local local coords of the block within the map
* @return block state
*/
private IPartBlockState getBlockState(MutableBlockPos local)
{
final IBlockState block = conBlocks[local.getX()][local.getY()][local.getZ()];
if (block == null) return PartBlockState.of();
if (state == null) return PartBlockState.of(block);
final String blockState = state[local.getX()][local.getY()][local.getZ()];
if (blockState == null) return PartBlockState.of(block);
return PartBlockState.of(block, blockState);
}
示例12: next
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
public MutableBlockPos next()
{
if (!hasNext())
{
throw new NoSuchElementException();
}
pos.setPos(rowNo, layerNo, depthNo);
shiftReadHead();
return pos;
}
示例13: mutOffset
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public static MutableBlockPos mutOffset(MutableBlockPos pos, EnumFacing facing)
{
return pos.setPos(
facing.getFrontOffsetX() + pos.getX(),
facing.getFrontOffsetY() + pos.getY(),
facing.getFrontOffsetZ() + pos.getZ()
);
}
示例14: addDestroyEffects
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager)
{
final float scaleVec = 0.05f;
final TileEntity ute = world.getTileEntity(pos);
if (ute instanceof StructureTE)
{
final StructureTE te = (StructureTE) ute;
for (MutableBlockPos local : getPattern().getStructureItr())
{
//outward Vector
float xSpeed = 0.0f;
float ySpeed = 0.0f;
float zSpeed = 0.0f;
for (EnumFacing d : EnumFacing.VALUES)
{
if (!getPattern().hasBlockAt(local, d))
{
d = localToGlobal(d, te.getOrientation(), te.getMirror());
xSpeed += d.getFrontOffsetX();
ySpeed += d.getFrontOffsetY();
zSpeed += d.getFrontOffsetZ();
}
}
mutLocalToGlobal(local, pos, te.getOrientation(), te.getMirror(), getPattern().getBlockBounds());
spawnBreakParticle(world, te, local, xSpeed * scaleVec, ySpeed * scaleVec, zSpeed * scaleVec);
}
}
return true; //No Destroy Effects
}
示例15: updateExternalNeighbours
import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public static void updateExternalNeighbours(World world, BlockPos origin, StructureDefinition sd, EnumFacing orientation, boolean mirror, boolean notifyBlocks)
{
for (final MutableBlockPos local : sd.getStructureItr())
{
for (EnumFacing d : EnumFacing.VALUES)
{
if (!sd.hasBlockAt(local, d))
{
final IBlockState updatedBlock = sd.getBlock(local).getBlockState();
if (updatedBlock == null)
{
continue;
}
final MutableBlockPos mutLocal = BlockPosUtil.newMutBlockPos(local);
BlockPosUtil.mutOffset(mutLocal, d);
mutLocalToGlobal(
mutLocal,
origin,
orientation, mirror,
sd.getBlockBounds()
);
world.notifyNeighborsOfStateChange(mutLocal, updatedBlock.getBlock());
}
}
}
}