public static Property<?> adaptProperty(IProperty<?> property) { if (property instanceof PropertyBool) { return new BooleanProperty(property.getName(), ImmutableList.copyOf(((PropertyBool) property).getAllowedValues())); } if (property instanceof PropertyInteger) { return new IntegerProperty(property.getName(), ImmutableList.copyOf(((PropertyInteger) property).getAllowedValues())); } if (property instanceof PropertyDirection) { return new DirectionalProperty(property.getName(), ((PropertyDirection) property).getAllowedValues().stream() .map(ForgeAdapter::adaptEnumFacing) .collect(Collectors.toList())); } if (property instanceof PropertyEnum) { return new EnumProperty(property.getName(), ((PropertyEnum<?>) property).getAllowedValues().stream() .map(e -> e.getName()) .collect(Collectors.toList())); } return new IPropertyAdapter<>(property); }
@Override @SideOnly(Side.CLIENT) public void registerRenderers(@Nonnull IModObject modObject) { for (Integer dmg : DAMAGE.getAllowedValues()) { ClientUtil.regRenderer(this, dmg, DAMAGE.getName() + "=" + DAMAGE.getName(NullHelper.notnullM(dmg, "invalid property")) + "," + FACING.getName() + "=" + FACING.getName(EnumFacing.NORTH)); } }
public StateHandlerDefault(int maximum) { this.maximum = maximum; this.stages = PropertyInteger.create("stage", 1, maximum); this.stateContainer = HFApi.crops.getStateContainer(stages); this.defaultState = stateContainer.getBaseState().withProperty(stages, 1); }
@Override public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { int use = 250; if (farmer.getEnergy() >= use) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (block instanceof BlockCrops) { if (((BlockCrops) block).isMaxAge(state)) { return doFarmerStuff(state, world, pos, farmer); } } else if ((BlockCrops.AGE).equals(block.getBlockState().getProperty("age"))) { if (state.getValue(BlockCrops.AGE) >= 7 && !(block instanceof BlockStem)) return doFarmerStuff(state, world, pos, farmer); } } return FarmerResult.FAIL; }
public BlockInteger(Material material, int maxMeta, String propName) { super(material); this.maxMeta = maxMeta; this.property = PropertyInteger.create(propName, 0, maxMeta); this.realStateContainer = createStateContainer(); setDefaultState(getBlockState().getBaseState()); }
@Nonnull @Override public Map<IBlockState, ModelResourceLocation> getStateModelLocations() { Map<IBlockState, ModelResourceLocation> map = new HashMap<>(); for (int bite : BlockCake.BITES.getAllowedValues()) map.put(getDefaultState().withProperty(BlockCake.BITES, bite), new ModelResourceLocation(new ResourceLocation(FoodCraftReloadedMod.MODID, "fruit_cake"), "bites=" + bite)); return map; }
"chili" ); PropertyInteger cropAge = PropertyInteger.create("age", 0, 3); int seedAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed"); int juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple");
@Nonnull @Override public Map<IBlockState, ModelResourceLocation> getStateModelLocations() { Map<IBlockState, ModelResourceLocation> locationMap = new HashMap<>(); for (int i : BlockSapling.STAGE.getAllowedValues()) locationMap.put(getDefaultState().withProperty(BlockSapling.STAGE, i), new ModelResourceLocation(new ResourceLocation(FoodCraftReloadedMod.MODID, "fruit_sapling"), "normal")); return locationMap; }
int seedamount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed"); int wheatamount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.compost.wheat"); PropertyInteger plantAGE = PropertyInteger.create("age", 0, 3); PropertyInteger fruitAGE = PropertyInteger.create("age", 0, 2);
private static void setMoreSnow(World world, BlockPos pos) { IBlockState hitState = world.getBlockState(pos); int m = hitState.getBlock().getMetaFromState(hitState) + 1; if (BlockSnow.LAYERS.getAllowedValues().contains(m + 1)) { world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, m + 1)); UtilSound.playSound(world, pos, SoundEvents.BLOCK_SNOW_PLACE, SoundCategory.BLOCKS); } else { setNewSnow(world, pos.up()); } }
private void setDynamicBlocks(Map<BlockPos, String> dataBlocks, Map<BlockPos, String> dataBlocksClone, World world, Random random, HashMap<BlockPos, IBlockState> defaultBlocks) { int dinoType = random.nextInt(FossilBlock.VARIANT.getAllowedValues().size()); dataBlocks.forEach((pos, type) -> {
ModCyclic.logger.log("[harvest] age Property " + blockId); int currentAge = blockState.getValue(propInt); int minAge = Collections.min(propInt.getAllowedValues()); int maxAge = Collections.max(propInt.getAllowedValues()); if (harvestCustomMaxAge.containsKey(blockId.toString())) { maxAge = harvestCustomMaxAge.get(blockId.toString());
int garlic_age_count = BlockGarlic.AGE.getAllowedValues().size(); this.setBlockState(worldIn, Blocks.WATER.getDefaultState(), 1, -1, 6, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.FARMLAND.getDefaultState(), 1, -1, 7, structureBoundingBoxIn);