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); }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onModelBakeEvent(ModelBakeEvent event) { for (EnumFacing facing : DisplayStand.FACING.getAllowedValues()) { for (Boolean axisX : DisplayStand.AXIS_X.getAllowedValues()) { String blockVariant = String.format("%s=%s,%s=%s", DisplayStand.AXIS_X.getName(), DisplayStand.AXIS_X.getName(axisX), DisplayStand.FACING.getName(), DisplayStand.FACING.getName(facing)); bakeVariantModel(event, blockVariant, !axisX); } } bakeVariantModel(event, "inventory", false); }
public static boolean hasRubberToHarvest(IBlockState blockState) { Block block = blockState.getBlock(); if (PluginIC2.rubberWood != null && ItemStackUtil.equals(block, PluginIC2.rubberWood)) { ImmutableCollection<Comparable<?>> propertyValues = blockState.getProperties().values(); for (Comparable<?> propertyValue : propertyValues) { if (propertyValue.toString().contains("wet")) { return true; } } } else if (PluginTechReborn.RUBBER_WOOD != null && ItemStackUtil.equals(block, PluginTechReborn.RUBBER_WOOD)) { return blockState.getValue(PropertyBool.create("hassap")); } return false; }
/** * Convert a "wet" rubber log blockstate into the dry version. * Total hack since we don't have access to the blockstates. */ private static <T extends Comparable<T>> IBlockState getReplantState(IBlockState sappyState) { if (hasRubberToHarvest(sappyState)) { for (Map.Entry<IProperty<?>, Comparable<?>> wetPropertyEntry : sappyState.getProperties().entrySet()) { String valueWetString = wetPropertyEntry.getValue().toString(); String valueDryString = valueWetString.replace("wet", "dry"); IProperty<?> property = wetPropertyEntry.getKey(); if (property instanceof PropertyBool && property.getName().equals("hassap")) { return sappyState.withProperty(PropertyBool.create("hassap"), false); } IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState(); IBlockState dryState = getStateWithValue(baseState, property, valueDryString); if (dryState != null) { return dryState; } } } return sappyState.getBlock().getDefaultState(); }
public void addLeafMapping(Block logBlock, int logMetadata, Block leafBlock, int leafMetadata) { IBlockState logState = logBlock.getStateFromMeta(logMetadata); for (Boolean check_decay : BlockLeaves.CHECK_DECAY.getAllowedValues()) { IBlockState leafState = leafBlock.getStateFromMeta(leafMetadata).withProperty(BlockLeaves.DECAYABLE, Boolean.TRUE).withProperty(BlockLeaves.CHECK_DECAY, check_decay); TapperManager.addLeafMapping(logState, leafState); } }
@Override public void registerRecipes() { IFarmRegistry farmRegistry = ForestryAPI.farmRegistry; int seedAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed"); PropertyBool TOP = PropertyBool.create("top"); PropertyInteger AGE = BlockCrops.AGE; ItemStack hempSeed = getItemStack("hemp"); Block hempCrop = getBlock("hemp"); if (hempSeed != null && hempCrop != null) { IBlockState defaultState = hempCrop.getDefaultState(); IBlockState planted = defaultState.withProperty(AGE, 0).withProperty(TOP, false); IBlockState mature = defaultState.withProperty(AGE, 7).withProperty(TOP, false); IBlockState topMature = defaultState.withProperty(AGE, 7).withProperty(TOP, true); farmRegistry.registerFarmables(ForestryFarmIdentifier.CROPS, new FarmableDoubleCrop(hempSeed, planted, mature, topMature, true)); RecipeManagers.squeezerManager.addRecipe(10, hempSeed, Fluids.SEED_OIL.getFluid(seedAmount)); } } }
private static void addVanillaLeafMappings(Block logBlock, PropertyEnum<BlockPlanks.EnumType> logVariantProperty, Block leavesBlock, PropertyEnum<BlockPlanks.EnumType> leafVariantProperty) { for (BlockPlanks.EnumType variant : logVariantProperty.getAllowedValues()) { IBlockState logState = logBlock.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(logVariantProperty, variant); for (Boolean check_decay : BlockLeaves.CHECK_DECAY.getAllowedValues()) { IBlockState leafState = leavesBlock.getDefaultState().withProperty(leafVariantProperty, variant).withProperty(BlockLeaves.DECAYABLE, Boolean.TRUE).withProperty(BlockLeaves.CHECK_DECAY, check_decay); leafMap.put(new BlockWrapper(logState), new BlockWrapper(leafState)); } } }
public static final IUnlistedProperty<VoxelBlobStateReference> UProperty_VoxelBlob = new UnlistedVoxelBlob(); public static final IUnlistedProperty<Integer> UProperty_Primary_BlockState = new UnlistedBlockStateID(); public static final PropertyBool LProperty_FullBlock = PropertyBool.create( "full_block" );