use of net.minecraft.block.state.BlockWorldState in project Cavern2 by kegare.
the class BlockPortalCavern method createPatternHelper.
@Override
public PatternHelper createPatternHelper(World world, BlockPos pos) {
EnumFacing.Axis axis = EnumFacing.Axis.Z;
Size size = new Size(world, pos, EnumFacing.Axis.X);
LoadingCache<BlockPos, BlockWorldState> cache = BlockPattern.createLoadingCache(world, true);
if (!size.isValid()) {
axis = EnumFacing.Axis.X;
size = new Size(world, pos, EnumFacing.Axis.Z);
}
if (!size.isValid()) {
return new PatternHelper(pos, EnumFacing.NORTH, EnumFacing.UP, cache, 1, 1, 1);
} else {
int[] values = new int[EnumFacing.AxisDirection.values().length];
EnumFacing facing = size.rightDir.rotateYCCW();
BlockPos blockpos = size.bottomLeft.up(size.getHeight() - 1);
for (EnumFacing.AxisDirection direction : EnumFacing.AxisDirection.values()) {
PatternHelper pattern = new PatternHelper(facing.getAxisDirection() == direction ? blockpos : blockpos.offset(size.rightDir, size.getWidth() - 1), EnumFacing.getFacingFromAxis(direction, axis), EnumFacing.UP, cache, size.getWidth(), size.getHeight(), 1);
for (int i = 0; i < size.getWidth(); ++i) {
for (int j = 0; j < size.getHeight(); ++j) {
BlockWorldState state = pattern.translateOffset(i, j, 1);
if (state.getBlockState() != null && state.getBlockState().getMaterial() != Material.AIR) {
++values[direction.ordinal()];
}
}
}
}
EnumFacing.AxisDirection axis1 = EnumFacing.AxisDirection.POSITIVE;
for (EnumFacing.AxisDirection direction : EnumFacing.AxisDirection.values()) {
if (values[direction.ordinal()] < values[axis1.ordinal()]) {
axis1 = direction;
}
}
return new PatternHelper(facing.getAxisDirection() == axis1 ? blockpos : blockpos.offset(size.rightDir, size.getWidth() - 1), EnumFacing.getFacingFromAxis(axis1, axis), EnumFacing.UP, cache, size.getWidth(), size.getHeight(), 1);
}
}
use of net.minecraft.block.state.BlockWorldState in project Gaia-Dimension by Andromander.
the class GDGaiaPortal method createPatternHelper.
public BlockPattern.PatternHelper createPatternHelper(World worldIn, BlockPos pos) {
EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Z;
GDGaiaPortal.Size blockportal$size = new GDGaiaPortal.Size(worldIn, pos, EnumFacing.Axis.X);
LoadingCache<BlockPos, BlockWorldState> loadingcache = BlockPattern.createLoadingCache(worldIn, true);
if (!blockportal$size.isValid()) {
enumfacing$axis = EnumFacing.Axis.X;
blockportal$size = new GDGaiaPortal.Size(worldIn, pos, EnumFacing.Axis.Z);
}
if (!blockportal$size.isValid()) {
return new BlockPattern.PatternHelper(pos, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1);
} else {
int[] aint = new int[EnumFacing.AxisDirection.values().length];
EnumFacing enumfacing = blockportal$size.rightDir.rotateYCCW();
BlockPos blockpos = blockportal$size.bottomLeft.up(blockportal$size.getHeight() - 1);
for (EnumFacing.AxisDirection enumfacing$axisdirection : EnumFacing.AxisDirection.values()) {
BlockPattern.PatternHelper blockpattern$patternhelper = new BlockPattern.PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1);
for (int i = 0; i < blockportal$size.getWidth(); ++i) {
for (int j = 0; j < blockportal$size.getHeight(); ++j) {
BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1);
if (blockworldstate.getBlockState() != null && blockworldstate.getBlockState().getMaterial() != Material.AIR) {
++aint[enumfacing$axisdirection.ordinal()];
}
}
}
}
EnumFacing.AxisDirection enumfacing$axisdirection1 = EnumFacing.AxisDirection.POSITIVE;
for (EnumFacing.AxisDirection enumfacing$axisdirection2 : EnumFacing.AxisDirection.values()) {
if (aint[enumfacing$axisdirection2.ordinal()] < aint[enumfacing$axisdirection1.ordinal()]) {
enumfacing$axisdirection1 = enumfacing$axisdirection2;
}
}
return new BlockPattern.PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection1 ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1);
}
}
use of net.minecraft.block.state.BlockWorldState in project takumicraft by TNTModders.
the class BlockTakumiPortal method createPatternHelper.
public PatternHelper createPatternHelper(World worldIn, BlockPos p_181089_2_) {
Axis enumfacing$axis = Axis.Z;
Size blockportal$size = new Size(worldIn, p_181089_2_, Axis.X);
LoadingCache<BlockPos, BlockWorldState> loadingcache = BlockPattern.createLoadingCache(worldIn, true);
if (!blockportal$size.isValid()) {
enumfacing$axis = Axis.X;
blockportal$size = new Size(worldIn, p_181089_2_, Axis.Z);
}
if (!blockportal$size.isValid()) {
return new PatternHelper(p_181089_2_, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1);
}
int[] aint = new int[AxisDirection.values().length];
EnumFacing enumfacing = blockportal$size.rightDir.rotateYCCW();
BlockPos blockpos = blockportal$size.bottomLeft.up(blockportal$size.getHeight() - 1);
for (AxisDirection enumfacing$axisdirection : AxisDirection.values()) {
PatternHelper blockpattern$patternhelper = new PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1);
for (int i = 0; i < blockportal$size.getWidth(); ++i) {
for (int j = 0; j < blockportal$size.getHeight(); ++j) {
BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1);
if (blockworldstate.getBlockState() != null && blockworldstate.getBlockState().getMaterial() != Material.AIR) {
++aint[enumfacing$axisdirection.ordinal()];
}
}
}
}
AxisDirection enumfacing$axisdirection1 = AxisDirection.POSITIVE;
for (AxisDirection enumfacing$axisdirection2 : AxisDirection.values()) {
if (aint[enumfacing$axisdirection2.ordinal()] < aint[enumfacing$axisdirection1.ordinal()]) {
enumfacing$axisdirection1 = enumfacing$axisdirection2;
}
}
return new PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection1 ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1);
}
Aggregations