下面列出了net.minecraft.util.EnumFacing#rotateYCCW ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
return super.doesSideBlockRendering(state, world, pos, face);
if (state.isOpaqueCube())
return true;
state = this.getActualState(state, world, pos);
EnumHalf half = state.getValue(HALF);
EnumFacing side = state.getValue(FACING);
EnumShape shape = state.getValue(SHAPE);
if (face == EnumFacing.UP) return half == EnumHalf.TOP;
if (face == EnumFacing.DOWN) return half == EnumHalf.BOTTOM;
if (shape == EnumShape.OUTER_LEFT || shape == EnumShape.OUTER_RIGHT) return false;
if (face == side) return true;
if (shape == EnumShape.INNER_LEFT && face.rotateY() == side) return true;
return shape == EnumShape.INNER_RIGHT && face.rotateYCCW() == side;
}
@Override
public boolean isSideSolid(IBlockState state,IBlockAccess world, BlockPos pos, EnumFacing side)
{
boolean flipped = state.getValue(BlockStairs.HALF) == EnumHalf.TOP;
EnumShape shape = (EnumShape)state.getValue(BlockStairs.SHAPE);
EnumFacing facing = (EnumFacing)state.getValue(BlockStairs.FACING);
if (side == EnumFacing.UP) return flipped;
if (side == EnumFacing.DOWN) return !flipped;
if (facing == side) return true;
if (flipped)
{
if (shape == EnumShape.INNER_LEFT) return side == facing.rotateYCCW();
if (shape == EnumShape.INNER_RIGHT) return side == facing.rotateY();
}
else
{
if (shape == EnumShape.INNER_LEFT) return side == facing.rotateY();
if (shape == EnumShape.INNER_RIGHT) return side == facing.rotateYCCW();
}
return false;
}
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
{
if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
return super.doesSideBlockRendering(state, world, pos, face);
if ( state.isOpaqueCube() )
return true;
state = this.getActualState(state, world, pos);
EnumHalf half = state.getValue(BlockStairs.HALF);
EnumFacing side = state.getValue(BlockStairs.FACING);
EnumShape shape = state.getValue(BlockStairs.SHAPE);
if (face == EnumFacing.UP) return half == EnumHalf.TOP;
if (face == EnumFacing.DOWN) return half == EnumHalf.BOTTOM;
if (shape == EnumShape.OUTER_LEFT || shape == EnumShape.OUTER_RIGHT) return false;
if (face == side) return true;
if (shape == EnumShape.INNER_LEFT && face.rotateY() == side) return true;
if (shape == EnumShape.INNER_RIGHT && face.rotateYCCW() == side) return true;
return false;
}
private static EnumShape getStairsShape(IBlockState p_185706_0_, IBlockAccess p_185706_1_, BlockPos p_185706_2_)
{
EnumFacing enumfacing = p_185706_0_.getValue(FACING);
IBlockState iblockstate = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing.getOpposite()));
if (isBlockStairs(iblockstate))
{
EnumFacing enumfacing1 = iblockstate.getValue(FACING);
if (enumfacing1.getAxis() != p_185706_0_.getValue(FACING).getAxis())
{
if (enumfacing1 == enumfacing.rotateYCCW()) {
return EnumShape.OUTER_LEFT;
}
return EnumShape.OUTER_RIGHT;
}
}
IBlockState iblockstate1 = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing));
if (isBlockStairs(iblockstate1))
{
EnumFacing enumfacing2 = iblockstate1.getValue(FACING);
if (enumfacing2.getAxis() != p_185706_0_.getValue(FACING).getAxis())
{
if (enumfacing2 == enumfacing.rotateYCCW()) {
return EnumShape.INNER_LEFT;
}
return EnumShape.INNER_RIGHT;
}
}
return EnumShape.STRAIGHT;
}
private static EnumFacing rotateFacing(EnumFacing facing, int rotation) {
if (rotation >= 0) {
for (int i = 0; i < rotation; i++) {
facing = facing.rotateY();
}
} else {
rotation = -rotation;
for (int i = 0; i < rotation; i++) {
facing = facing.rotateYCCW();
}
}
return facing;
}
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing,
float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
EnumFacing playerFacing = placer.getHorizontalFacing();
if (!placer.isSneaking()) {
playerFacing = playerFacing.getOpposite();
}
// Find the facing that's closest to what the player wanted.
EnumFacing facingHorizontal;
if (canPlaceBlockAtWithFacing(worldIn, pos, playerFacing)) {
facingHorizontal = playerFacing;
} else if (canPlaceBlockAtWithFacing(worldIn, pos, playerFacing.rotateY())) {
facingHorizontal = playerFacing.rotateY();
} else if (canPlaceBlockAtWithFacing(worldIn, pos, playerFacing.rotateYCCW())) {
facingHorizontal = playerFacing.rotateYCCW();
} else if (canPlaceBlockAtWithFacing(worldIn, pos, playerFacing.getOpposite())) {
facingHorizontal = playerFacing.getOpposite();
} else {
// There was no valid facing! How the did this method even get called!
throw new IllegalStateException(
"Cannot find valid state for placement for Physics Infuser!");
}
return this.getDefaultState()
.withProperty(FACING, facingHorizontal)
.withProperty(INFUSER_LIGHT_ON, false);
}
/**
* @return Can this block attach to other blocks for support checks in this direction
*/
@Override
public boolean canSupportFacing(IBlockState myState, IBlockAccess world, BlockPos pos, EnumFacing facing)
{
EnumFacing f = (EnumFacing)myState.getValue(BlockStairs.FACING);
if(facing == f.rotateY() || facing == f.rotateYCCW())
return true;
return myState.getBlock().isSideSolid(myState, world, pos, facing);
}
/**
* Returns a bounding box representing an eighth of a block (a block whose three dimensions are halved).
* Used in all stair shapes except STRAIGHT (gets added alone in the case of OUTER; alone with a quarter block in
* case of INSIDE).
*/
private static AxisAlignedBB getCollEighthBlock(IBlockState bstate)
{
EnumFacing enumfacing = (EnumFacing)bstate.getValue(BlockStairs.FACING);
EnumFacing enumfacing1;
switch ((BlockStairs.EnumShape)bstate.getValue(BlockStairs.SHAPE))
{
case OUTER_LEFT:
default:
enumfacing1 = enumfacing;
break;
case OUTER_RIGHT:
enumfacing1 = enumfacing.rotateY();
break;
case INNER_RIGHT:
enumfacing1 = enumfacing.getOpposite();
break;
case INNER_LEFT:
enumfacing1 = enumfacing.rotateYCCW();
}
boolean flag = bstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP;
switch (enumfacing1)
{
case NORTH:
default:
return flag ? AABB_OCT_BOT_NW : AABB_OCT_TOP_NW;
case SOUTH:
return flag ? AABB_OCT_BOT_SE : AABB_OCT_TOP_SE;
case WEST:
return flag ? AABB_OCT_BOT_SW : AABB_OCT_TOP_SW;
case EAST:
return flag ? AABB_OCT_BOT_NE : AABB_OCT_TOP_NE;
}
}
private static BlockStairs.EnumShape func_185706_d(IBlockState p_185706_0_, IBlockAccess p_185706_1_, BlockPos p_185706_2_)
{
EnumFacing enumfacing = (EnumFacing)p_185706_0_.getValue(BlockStairs.FACING);
IBlockState iblockstate = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing));
if (isBlockStairs(iblockstate) && p_185706_0_.getValue(BlockStairs.HALF) == iblockstate.getValue(BlockStairs.HALF))
{
EnumFacing enumfacing1 = (EnumFacing)iblockstate.getValue(BlockStairs.FACING);
if (enumfacing1.getAxis() != ((EnumFacing)p_185706_0_.getValue(BlockStairs.FACING)).getAxis() && isDifferentStairs(p_185706_0_, p_185706_1_, p_185706_2_, enumfacing1.getOpposite()))
{
if (enumfacing1 == enumfacing.rotateYCCW())
{
return BlockStairs.EnumShape.OUTER_LEFT;
}
return BlockStairs.EnumShape.OUTER_RIGHT;
}
}
IBlockState iblockstate1 = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing.getOpposite()));
if (isBlockStairs(iblockstate1) && p_185706_0_.getValue(BlockStairs.HALF) == iblockstate1.getValue(BlockStairs.HALF))
{
EnumFacing enumfacing2 = (EnumFacing)iblockstate1.getValue(BlockStairs.FACING);
if (enumfacing2.getAxis() != ((EnumFacing)p_185706_0_.getValue(BlockStairs.FACING)).getAxis() && isDifferentStairs(p_185706_0_, p_185706_1_, p_185706_2_, enumfacing2))
{
if (enumfacing2 == enumfacing.rotateYCCW())
{
return BlockStairs.EnumShape.INNER_LEFT;
}
return BlockStairs.EnumShape.INNER_RIGHT;
}
}
return BlockStairs.EnumShape.STRAIGHT;
}
private void build(TIntObjectHashMap<BakedRenderer> bakedRenderers, ImmutableList<NetworkRail<MCPos>> edge){
for(int edgeIndex = 1; edgeIndex < edge.size() - 1; edgeIndex++) {
NetworkRail<MCPos> prevRail = edge.get(edgeIndex - 1);
MCNetworkRail curRail = (MCNetworkRail)edge.get(edgeIndex);
NetworkRail<MCPos> nextRail = edge.get(edgeIndex + 1);
EnumHeading prevHeading = curRail.getPos().getRelativeHeading(prevRail.getPos());
EnumHeading nextHeading = nextRail.getPos().getRelativeHeading(curRail.getPos());
if(prevHeading == null || nextHeading == null || prevHeading != nextHeading || curRail.getPos().getDimID() != nextRail.getPos().getDimID() || curRail.getPos().getDimID() != prevRail.getPos().getDimID()) continue;
BakedRenderer bakedRenderer = bakedRenderers.get(curRail.getPos().getDimID());
if(bakedRenderer == null) {
bakedRenderer = new BakedRenderer();
bakedRenderers.put(curRail.getPos().getDimID(), bakedRenderer);
}
MCPos pos = curRail.getPos();
EnumFacing facing = HeadingUtils.toFacing(nextHeading).getOpposite();
EnumFacing rotatedFacing = facing.rotateY();
EnumFacing rotatedFacing2 = facing.rotateYCCW();
int yOffset = AbstractRailRenderer.getRailHeightOffset(curRail, facing);
Vec3d posVec = new Vec3d(pos.getX() + 0.5, pos.getY() + (yOffset != 0 ? 0.6001 : 0.1001), pos.getZ() + 0.5);
double arrowSize = 0.1;
double spacing = 0.1;
for(int i = -2; i < -1; i++) {
Vec3d shiftedPosVec = posVec.addVector(facing.getFrontOffsetX() * spacing * i, spacing * i * yOffset + 0.001, facing.getFrontOffsetZ() * spacing * i);
Vec3d vecBack = shiftedPosVec.addVector(facing.getFrontOffsetX() * arrowSize, arrowSize * yOffset, facing.getFrontOffsetZ() * arrowSize);
Vec3d c1 = vecBack.addVector(rotatedFacing.getFrontOffsetX() * arrowSize, 0, rotatedFacing.getFrontOffsetZ() * arrowSize);
Vec3d c2 = vecBack.addVector(rotatedFacing2.getFrontOffsetX() * arrowSize, 0, rotatedFacing2.getFrontOffsetZ() * arrowSize);
bakedRenderer.add(shiftedPosVec.x, shiftedPosVec.y, shiftedPosVec.z);
bakedRenderer.add(c1.x, c1.y, c1.z);
//buffer.pos(shiftedPosVec.x, shiftedPosVec.y, shiftedPosVec.z).color(r, g, b, 1).endVertex();
bakedRenderer.add(c2.x, c2.y, c2.z);
}
}
}