IBlockState newState = mcBlock.getDefaultState(); Map<Property<?>, Object> states = block.getStates(); newState = applyProperties(mcBlock.getBlockState(), newState, states); IBlockState successState = chunk.setBlockState(pos, newState); boolean successful = successState != null;
private Map<IBlockState, ModelResourceLocation> mapState( Block block, ModelResourceLocation defaultModel, ModelResourceLocation formedModel ) { Map<IBlockState, ModelResourceLocation> result = new HashMap<>(); for( IBlockState state : block.getBlockState().getValidStates() ) { if( state.getValue( BlockCraftingUnit.FORMED ) ) { // Always use the builtin model if the multiblock is formed result.put( state, formedModel ); } else { // Use the default model result.put( state, defaultModel ); } } return result; } }
@Override protected BlockStateContainer createBlockState() { return Blocks.AIR.getBlockState(); }
@Override public Map<IBlockState, ModelResourceLocation> putStateModelLocations( Block blockIn ) { Map<IBlockState, ModelResourceLocation> map = new HashMap<IBlockState, ModelResourceLocation>(); for ( IBlockState o : blk.getBlockState().getValidStates() ) map.put( o, loctaion ); return map; } } );
@Override public BlockStateContainer getBaseBlockState() { return getBlock().getBlockState(); }
@Override public ImmutableList<IBlockState> getValidStates() { return block.getBlockState().getValidStates(); }
@Override public <V> V getValue(IUnlistedProperty<V> property) { Optional<?> value = unlistedProperties.get(property); if (value == null) { throw new IllegalArgumentException("Cannot get unlisted property " + property + " as it does not exist in " + getBlock().getBlockState()); } return property.getType().cast(value.orElse(null)); }
public static PropertyState getPropertyState(IBlockState state, JsonObject parent, String elementName) { JsonObject jsonProperty = JsonUtils.getJsonObject(parent, elementName); if (jsonProperty.entrySet().isEmpty()) { throw new JsonParseException("Expected at least one property defined for " + elementName + " in " + parent.toString()); } Entry<String, JsonElement> propJson = jsonProperty.entrySet().iterator().next(); String propName = propJson.getKey(); String propValue = propJson.getValue().getAsString(); return BlockTools.getPropertyState(state.getBlock(), state.getBlock().getBlockState(), propName, propValue); }
public void setTranquility(Block block, TranquilityStack tranquilityStack) { for (IBlockState state : block.getBlockState().getValidStates()) { BMLog.API_VERBOSE.info("Value Manager: Set tranquility value of {} to {} @ {}", state, tranquilityStack.type, tranquilityStack.value); tranquility.put(state, tranquilityStack); } }
public void addTeleposer(@Nonnull Block block) { for (IBlockState state : block.getBlockState().getValidStates()) addTeleposer(state); }
public void addTransposition(@Nonnull Block block) { for (IBlockState state : block.getBlockState().getValidStates()) addTransposition(state); }
public void addGreenGrove(@Nonnull Block block) { for (IBlockState state : block.getBlockState().getValidStates()) addGreenGrove(state); }
ModelResourceLocation getModelResourceLocation(VariationData data, String variant) { String name = block.getRegistryName().getResourcePath(); while (Character.isDigit(name.charAt(name.length() - 1))) { name = name.substring(0, name.length() - 1); } // This block has additional properties, so don't use a single blockstate file, instead use the provided variant path if (block.getBlockState().getProperties().size() > 1) { return new ModelResourceLocation(new ResourceLocation("chisel", data.path), variant); } else { // Otherwise, break the variant name off of the path to use as the variant path int lastslash = data.path.lastIndexOf('/'); return new ModelResourceLocation(new ResourceLocation("chisel", data.path.substring(0, lastslash)), data.path.substring(lastslash + 1)); } }
public static ImmutableSet<IBlockState> getBlockPresets(Block block) { if (!(block instanceof ITANBlock)) {return ImmutableSet.<IBlockState>of();} IBlockState defaultState = block.getDefaultState(); if (defaultState == null) {defaultState = block.getBlockState().getBaseState();} return getStatesSet(defaultState, ((ITANBlock)block).getPresetProperties()); }
public static ImmutableSet<IBlockState> getBlockPresets(Block block) { if (!(block instanceof ISSBlock)) {return ImmutableSet.<IBlockState>of();} IBlockState defaultState = block.getDefaultState(); if (defaultState == null) {defaultState = block.getBlockState().getBaseState();} return getStatesSet(defaultState, ((ISSBlock)block).getPresetProperties()); }
public MutationConditionRequiresResource(String oreDictName) { this.displayName = oreDictName; for (ItemStack ore : OreDictionary.getOres(oreDictName)) { if (!ore.isEmpty()) { Item oreItem = ore.getItem(); Block oreBlock = Block.getBlockFromItem(oreItem); if (oreBlock != Blocks.AIR) { this.acceptedBlockStates.addAll(oreBlock.getBlockState().getValidStates()); } } } }
@SideOnly(Side.CLIENT) private static void registerItemModel(Block block, Map<IProperty<?>, Comparable<?>> stateOverrides) { for (IBlockState state : block.getBlockState().getValidStates()) { HashMap<IProperty<?>, Comparable<?>> stringProperties = new HashMap<>(state.getProperties()); stringProperties.putAll(stateOverrides); //noinspection ConstantConditions ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), block.getMetaFromState(state), new ModelResourceLocation(block.getRegistryName(), statePropertiesToString(stringProperties))); } }
@Nonnull @Override public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (config.getConfig("general.showstates")) { IBlockState actualState = accessor.getBlockState().getBlock().getActualState(accessor.getBlockState(), accessor.getWorld(), accessor.getPosition()); BlockStateContainer container = accessor.getBlock().getBlockState(); for (IProperty<?> property : container.getProperties()) { Comparable<?> value = actualState.getValue(property); tooltip.add(property.getName() + ": " + (property instanceof PropertyBool ? value == Boolean.TRUE ? TextFormatting.GREEN : TextFormatting.RED : "") + value.toString()); } } return tooltip; }
/** * Registers an ItemStack for each valid state of the block */ @SideOnly(Side.CLIENT) public static void registerTypicalBlockItemModels(Block block, String name) { for (IBlockState state : block.getBlockState().getValidStates()) { int meta = block.getMetaFromState(state); registerTypicalItemStackModel(new ItemStack(block, 1, meta), name); } }
@SideOnly(Side.CLIENT) private static void registerItemModel(Block block) { for (IBlockState state : block.getBlockState().getValidStates()) { //noinspection ConstantConditions ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), block.getMetaFromState(state), new ModelResourceLocation(block.getRegistryName(), statePropertiesToString(state.getProperties()))); } }