private Predicate<BlockWorldState>[][][] makePredicateArray() { this.checkMissingPredicates(); Predicate<BlockWorldState>[][][] predicate = (Predicate[][][])((Predicate[][][])Array.newInstance(Predicate.class, new int[] {this.depth.size(), this.aisleHeight, this.rowWidth})); for (int i = 0; i < this.depth.size(); ++i) { for (int j = 0; j < this.aisleHeight; ++j) { for (int k = 0; k < this.rowWidth; ++k) { predicate[i][j][k] = (Predicate)this.symbolMap.get(Character.valueOf(((String[])this.depth.get(i))[j].charAt(k))); } } } return predicate; }
private void checkMissingPredicates() { List<Character> list = Lists.<Character>newArrayList(); for (Entry<Character, Predicate<BlockWorldState>> entry : this.symbolMap.entrySet()) { if (entry.getValue() == null) { list.add(entry.getKey()); } } if (!list.isEmpty()) { throw new IllegalStateException("Predicates for character(s) " + COMMA_JOIN.join(list) + " are missing"); } }
public BlockPattern(Predicate<BlockWorldState>[][][] predicatesIn) { this.blockMatches = predicatesIn; this.fingerLength = predicatesIn.length; if (this.fingerLength > 0) { this.thumbLength = predicatesIn[0].length; if (this.thumbLength > 0) { this.palmLength = predicatesIn[0][0].length; } else { this.palmLength = 0; } } else { this.thumbLength = 0; this.palmLength = 0; } }
/** * checks that the given pattern & rotation is at the block co-ordinates. */ private BlockPattern.PatternHelper checkPatternAt(BlockPos pos, EnumFacing finger, EnumFacing thumb, LoadingCache<BlockPos, BlockWorldState> lcache) { for (int i = 0; i < this.palmLength; ++i) { for (int j = 0; j < this.thumbLength; ++j) { for (int k = 0; k < this.fingerLength; ++k) { if (!this.blockMatches[k][j][i].apply(lcache.getUnchecked(translateOffset(pos, finger, thumb, i, j, k)))) { return null; } } } } return new BlockPattern.PatternHelper(pos, finger, thumb, lcache, this.palmLength, this.thumbLength, this.fingerLength); }
/** * checks that the given pattern & rotation is at the block co-ordinates. */ @Nullable private BlockPattern.PatternHelper checkPatternAt(BlockPos pos, EnumFacing finger, EnumFacing thumb, LoadingCache<BlockPos, BlockWorldState> lcache) { for (int i = 0; i < this.palmLength; ++i) { for (int j = 0; j < this.thumbLength; ++j) { for (int k = 0; k < this.fingerLength; ++k) { if (!this.blockMatches[k][j][i].apply(lcache.getUnchecked(translateOffset(pos, finger, thumb, i, j, k)))) { return null; } } } } return new BlockPattern.PatternHelper(pos, finger, thumb, lcache, this.palmLength, this.thumbLength, this.fingerLength); }
@Nullable /** * checks that the given pattern & rotation is at the block co-ordinates. */ private BlockPattern.PatternHelper checkPatternAt(BlockPos pos, EnumFacing finger, EnumFacing thumb, LoadingCache<BlockPos, BlockWorldState> lcache) { for (int i = 0; i < this.palmLength; ++i) { for (int j = 0; j < this.thumbLength; ++j) { for (int k = 0; k < this.fingerLength; ++k) { if (!this.blockMatches[k][j][i].apply(lcache.getUnchecked(translateOffset(pos, finger, thumb, i, j, k)))) { return null; } } } } return new BlockPattern.PatternHelper(pos, finger, thumb, lcache, this.palmLength, this.thumbLength, this.fingerLength); }
protected BlockPattern getGolemBasePattern() { if (this.golemBasePattern == null) { this.golemBasePattern = FactoryBlockPattern.start().aisle(new String[] {"~ ~", "###", "~#~"}).where('#', BlockWorldState.hasState(BlockStateMatcher.forBlock(Blocks.IRON_BLOCK))).where('~', BlockWorldState.hasState(BlockMaterialMatcher.forMaterial(Material.AIR))).build(); } return this.golemBasePattern; }
protected BlockPattern getWitherPattern() { if (this.witherPattern == null) { this.witherPattern = FactoryBlockPattern.start().aisle(new String[] {"^^^", "###", "~#~"}).where('#', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.soul_sand))).where('^', IS_WITHER_SKELETON).where('~', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.air))).build(); } return this.witherPattern; }
protected BlockPattern getSnowmanBasePattern() { if (this.snowmanBasePattern == null) { this.snowmanBasePattern = FactoryBlockPattern.start().aisle(new String[] {" ", "#", "#"}).where('#', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.snow))).build(); } return this.snowmanBasePattern; }
protected BlockPattern getSnowmanPattern() { if (this.snowmanPattern == null) { this.snowmanPattern = FactoryBlockPattern.start().aisle(new String[] {"^", "#", "#"}).where('^', BlockWorldState.hasState(field_181085_Q)).where('#', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.snow))).build(); } return this.snowmanPattern; }
protected BlockPattern getGolemBasePattern() { if (this.golemBasePattern == null) { this.golemBasePattern = FactoryBlockPattern.start().aisle(new String[] {"~ ~", "###", "~#~"}).where('#', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.iron_block))).where('~', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.air))).build(); } return this.golemBasePattern; }
protected BlockPattern getGolemPattern() { if (this.golemPattern == null) { this.golemPattern = FactoryBlockPattern.start().aisle(new String[] {"~^~", "###", "~#~"}).where('^', BlockWorldState.hasState(field_181085_Q)).where('#', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.iron_block))).where('~', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.air))).build(); } return this.golemPattern; }
public static BlockPattern getOrCreatePortalShape() { if (portalShape == null) { portalShape = FactoryBlockPattern.start().aisle(new String[] {"?vvv?", ">???<", ">???<", ">???<", "?^^^?"}).where('?', BlockWorldState.hasState(BlockStateMatcher.ANY)).where('^', BlockWorldState.hasState(BlockStateMatcher.forBlock(Blocks.END_PORTAL_FRAME).where(EYE, Predicates.equalTo(Boolean.valueOf(true))).where(FACING, Predicates.equalTo(EnumFacing.SOUTH)))).where('>', BlockWorldState.hasState(BlockStateMatcher.forBlock(Blocks.END_PORTAL_FRAME).where(EYE, Predicates.equalTo(Boolean.valueOf(true))).where(FACING, Predicates.equalTo(EnumFacing.WEST)))).where('v', BlockWorldState.hasState(BlockStateMatcher.forBlock(Blocks.END_PORTAL_FRAME).where(EYE, Predicates.equalTo(Boolean.valueOf(true))).where(FACING, Predicates.equalTo(EnumFacing.NORTH)))).where('<', BlockWorldState.hasState(BlockStateMatcher.forBlock(Blocks.END_PORTAL_FRAME).where(EYE, Predicates.equalTo(Boolean.valueOf(true))).where(FACING, Predicates.equalTo(EnumFacing.EAST)))).build(); } return portalShape; }
/** * Calculates whether the given world position matches the pattern. Warning, fairly heavy function. @return a * BlockPattern.PatternHelper if found, null otherwise. */ public BlockPattern.PatternHelper match(World worldIn, BlockPos pos) { LoadingCache<BlockPos, BlockWorldState> loadingcache = func_181627_a(worldIn, false); int i = Math.max(Math.max(this.palmLength, this.thumbLength), this.fingerLength); for (BlockPos blockpos : BlockPos.getAllInBox(pos, pos.add(i - 1, i - 1, i - 1))) { for (EnumFacing enumfacing : EnumFacing.values()) { for (EnumFacing enumfacing1 : EnumFacing.values()) { if (enumfacing1 != enumfacing && enumfacing1 != enumfacing.getOpposite()) { BlockPattern.PatternHelper blockpattern$patternhelper = this.checkPatternAt(blockpos, enumfacing, enumfacing1, loadingcache); if (blockpattern$patternhelper != null) { return blockpattern$patternhelper; } } } } } return null; }
protected BlockPattern getWitherPattern() { if (this.witherPattern == null) { this.witherPattern = FactoryBlockPattern.start().aisle(new String[] {"^^^", "###", "~#~"}).where('#', BlockWorldState.hasState(BlockStateMatcher.forBlock(Blocks.SOUL_SAND))).where('^', IS_WITHER_SKELETON).where('~', BlockWorldState.hasState(BlockMaterialMatcher.forMaterial(Material.AIR))).build(); } return this.witherPattern; }
protected BlockPattern getWitherBasePattern() { if (this.witherBasePattern == null) { this.witherBasePattern = FactoryBlockPattern.start().aisle(new String[] {" ", "###", "~#~"}).where('#', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.soul_sand))).where('~', BlockWorldState.hasState(BlockStateHelper.forBlock(Blocks.air))).build(); } return this.witherBasePattern; }
public PatternHelper(BlockPos p_i46378_1_, EnumFacing p_i46378_2_, EnumFacing p_i46378_3_, LoadingCache<BlockPos, BlockWorldState> p_i46378_4_, int p_i46378_5_, int p_i46378_6_, int p_i46378_7_) { this.pos = p_i46378_1_; this.finger = p_i46378_2_; this.thumb = p_i46378_3_; this.lcache = p_i46378_4_; this.field_181120_e = p_i46378_5_; this.field_181121_f = p_i46378_6_; this.field_181122_g = p_i46378_7_; }