本文整理汇总了Java中openmods.geometry.Orientation类的典型用法代码示例。如果您正苦于以下问题:Java Orientation类的具体用法?Java Orientation怎么用?Java Orientation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Orientation类属于openmods.geometry包,在下文中一共展示了Orientation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (hand != EnumHand.MAIN_HAND) return false;
if (world.isRemote) {
if (areButtonsActive(player)) {
final Orientation orientation = getOrientation(world, pos);
final Vec3d localHit = BlockSpaceTransform.instance.mapWorldToBlock(orientation, hitX, hitY, hitZ);
final Hitbox clickBox = findClickBox(localHit);
if (clickBox != null) {
new GuideActionEvent(world.provider.getDimension(), pos, clickBox.name).sendToServer();
}
}
return true;
} else if (player instanceof EntityPlayerMP) {
final ItemStack heldStack = player.getHeldItemMainhand();
if (!heldStack.isEmpty()) {
TileEntityGuide guide = getTileEntity(world, pos, TileEntityGuide.class);
if (guide.onItemUse((EntityPlayerMP)player, heldStack, side, hitX, hitY, hitZ)) return true;
}
}
return false;
}
示例2: getRotation
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public PlayerRotation getRotation(World world, BlockPos pos, IBlockState state) {
final Orientation orientation = getOrientation(world, pos);
final EnumFacing rot = orientation.north();
switch (rot) {
case NORTH:
return PlayerRotation.NORTH;
case SOUTH:
return PlayerRotation.SOUTH;
case WEST:
return PlayerRotation.WEST;
case EAST:
return PlayerRotation.EAST;
default:
return PlayerRotation.NONE;
}
}
示例3: onBlockPlacedBy
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
if (placer instanceof EntityPlayer) {
final EntityPlayer player = (EntityPlayer)placer;
final Orientation orientation = getOrientation(state);
BlockPos placePos = pos.down();
while (placePos.getY() > 0 && (Config.infiniteLadder || stack.getCount() > 1)) {
final BlockManipulator manipulator = new BlockManipulator(world, player, placePos);
if (world.isAirBlock(placePos) && manipulator.place(state, orientation.north(), EnumHand.MAIN_HAND)) {
if (!Config.infiniteLadder) stack.shrink(1);
} else return;
placePos = placePos.down();
}
}
}
示例4: createRotationManipulator
import openmods.geometry.Orientation; //导入依赖的package包/类
private static IShapeManipulator createRotationManipulator(final HalfAxis ha) {
return (te, player) -> {
final World world = te.getWorld();
final BlockPos pos = te.getPos();
final IBlockState state = world.getBlockState(pos);
final Block block = state.getBlock();
if (block instanceof OpenBlock) {
final IProperty<Orientation> orientationProperty = ((OpenBlock)block).propertyOrientation;
final Orientation orientation = state.getValue(orientationProperty);
final Orientation newOrientation = orientation.rotateAround(ha);
world.setBlockState(pos, state.withProperty(orientationProperty, newOrientation));
return true;
}
return false;
};
}
示例5: generateShape
import openmods.geometry.Orientation; //导入依赖的package包/类
private List<BlockPos> generateShape() {
final IShapeGenerator generator = getCurrentMode().generator;
final Set<BlockPos> uniqueResults = Sets.newHashSet();
final IShapeable collector = (x, y, z) -> {
if (canAddCoord(x, y, z)) uniqueResults.add(new BlockPos(x, y, z));
};
generator.generateShape(-negX.get(), -negY.get(), -negZ.get(), posX.get(), posY.get(), posZ.get(), collector);
final List<BlockPos> sortedResults = Lists.newArrayList(uniqueResults);
Collections.sort(sortedResults, COMPARATOR);
final List<BlockPos> rotatedResult = Lists.newArrayList();
final Orientation orientation = getOrientation();
for (BlockPos c : sortedResults) {
final int tx = orientation.transformX(c.getX(), c.getY(), c.getZ());
final int ty = orientation.transformY(c.getX(), c.getY(), c.getZ());
final int tz = orientation.transformZ(c.getX(), c.getY(), c.getZ());
rotatedResult.add(new BlockPos(tx, ty, tz));
}
return ImmutableList.copyOf(rotatedResult);
}
示例6: Transformation
import openmods.geometry.Orientation; //导入依赖的package包/类
public Transformation(Orientation orientation) {
final javax.vecmath.Matrix4f originalMatrix = new javax.vecmath.Matrix4f();
originalMatrix.set(orientation.getLocalToWorldMatrix());
asMatrix = TRSRTransformation.toLwjgl(originalMatrix);
asBuffer = BufferUtils.createFloatBuffer(16);
asMatrix.store(asBuffer);
asBuffer.rewind();
asInverseMatrix = new Matrix4f();
Matrix4f.invert(asMatrix, asInverseMatrix);
asInverseBuffer = BufferUtils.createFloatBuffer(16);
asInverseMatrix.store(asInverseBuffer);
asInverseBuffer.rewind();
}
示例7: onSelected
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public boolean onSelected(World world, BlockPos pos, DrawBlockHighlightEvent evt) {
if (areButtonsActive(evt.getPlayer())) {
final Vec3d hitVec = evt.getTarget().hitVec;
final Orientation orientation = getOrientation(world, pos);
final Vec3d localHit = BlockSpaceTransform.instance.mapWorldToBlock(orientation, hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
final Hitbox clickBox = findClickBox(localHit);
selection = clickBox != null? BlockSpaceTransform.instance.mapBlockToWorld(orientation, clickBox.aabb()).offset(pos.getX(), pos.getY(), pos.getZ()) : null;
} else selection = null;
return false;
}
示例8: hasStuckArrows
import openmods.geometry.Orientation; //导入依赖的package包/类
private boolean hasStuckArrows(IBlockState state, World world, BlockPos pos) {
final Orientation orientation = getOrientation(state);
final AxisAlignedBB checkAabb = BlockSpaceTransform.instance.mapBlockToWorld(orientation, COLLISION_AABB).offset(pos);
final List<? extends Entity> collidingArrows = world.getEntitiesWithinAABB(EntityArrow.class, checkAabb);
return !collidingArrows.isEmpty();
}
示例9: getBoundingBox
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
if (state.getValue(POWERED)) {
final Orientation orientation = state.getValue(propertyOrientation);
return BlockSpaceTransform.instance.mapBlockToWorld(orientation, DEPLOYED_AABB);
} else {
return FOLDED_AABB;
}
}
示例10: neighborChanged
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos neigbour) {
super.neighborChanged(state, world, pos, block, neigbour);
final Orientation orientation = getOrientation(state);
final EnumFacing down = orientation.down();
if (isNeighborBlockSolid(world, pos, down)) return;
if (isFlagOnGround(state) && isBaseSolidForFlag(world, pos)) return;
world.destroyBlock(pos, true);
}
示例11: getBoundingBox
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
final boolean pressed = state.getValue(POWERED);
final Orientation orientation = getOrientation(state);
return BlockSpaceTransform.instance.mapBlockToWorld(orientation, pressed? ACTIVE_AABB : INACTIVE_AABB);
}
示例12: canBlockBePlaced
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public boolean canBlockBePlaced(World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ, int itemMetadata, EntityPlayer player) {
if (side == EnumFacing.DOWN) {
final IBlockState maybeLadder = world.getBlockState(pos.up());
return maybeLadder.getBlock() == this;
}
for (Orientation o : getRotationMode().getValidDirections()) {
final EnumFacing placeDir = getRotationMode().getFront(o).getOpposite();
if (!world.isAirBlock(pos.offset(placeDir))) return true;
}
return false;
}
示例13: getStateForPlacement
import openmods.geometry.Orientation; //导入依赖的package包/类
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
Orientation orientation = calculateOrientationAfterPlace(pos, facing, placer);
if (orientation == null) orientation = findValidBlock(world, pos);
if (orientation == null) orientation = tryCloneState(world, pos, facing);
if (orientation == null) return getDefaultState();
return getStateFromMeta(meta).withProperty(propertyOrientation, orientation);
}
示例14: tryCloneState
import openmods.geometry.Orientation; //导入依赖的package包/类
private Orientation tryCloneState(World world, BlockPos pos, EnumFacing facing) {
if (facing == EnumFacing.DOWN) {
final IBlockState maybeLadder = world.getBlockState(pos.up());
if (maybeLadder.getBlock() == this)
return maybeLadder.getValue(getPropertyOrientation());
}
return null;
}
示例15: findValidBlock
import openmods.geometry.Orientation; //导入依赖的package包/类
private Orientation findValidBlock(World world, BlockPos pos) {
for (Orientation o : getRotationMode().getValidDirections()) {
final EnumFacing placeDir = getRotationMode().getFront(o).getOpposite();
if (!world.isAirBlock(pos.offset(placeDir))) return o;
}
return null;
}