本文整理了Java中net.minecraft.block.Block.getBlockState()
方法的一些代码示例,展示了Block.getBlockState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getBlockState()
方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getBlockState
暂无
代码示例来源:origin: EngineHub/WorldEdit
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;
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
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;
}
}
代码示例来源:origin: Chisel-Team/Chisel
@Override
protected BlockStateContainer createBlockState() {
return Blocks.AIR.getBlockState();
}
代码示例来源:origin: AlgorithmX2/Chisels-and-Bits
@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;
}
} );
代码示例来源:origin: CyclopsMC/IntegratedDynamics
@Override
public BlockStateContainer getBaseBlockState() {
return getBlock().getBlockState();
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
public ImmutableList<IBlockState> getValidStates() {
return block.getBlockState().getValidStates();
}
代码示例来源:origin: DimensionalDevelopment/VanillaFix
@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));
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
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);
}
代码示例来源:origin: WayofTime/BloodMagic
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);
}
}
代码示例来源:origin: WayofTime/BloodMagic
public void addTeleposer(@Nonnull Block block) {
for (IBlockState state : block.getBlockState().getValidStates())
addTeleposer(state);
}
代码示例来源:origin: WayofTime/BloodMagic
public void addTransposition(@Nonnull Block block) {
for (IBlockState state : block.getBlockState().getValidStates())
addTransposition(state);
}
代码示例来源:origin: WayofTime/BloodMagic
public void addGreenGrove(@Nonnull Block block) {
for (IBlockState state : block.getBlockState().getValidStates())
addGreenGrove(state);
}
代码示例来源:origin: Chisel-Team/Chisel
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));
}
}
代码示例来源:origin: Glitchfiend/ToughAsNails
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());
}
代码示例来源:origin: Glitchfiend/SereneSeasons
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());
}
代码示例来源:origin: ForestryMC/ForestryMC
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());
}
}
}
}
代码示例来源:origin: GregTechCE/GregTech
@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)));
}
}
代码示例来源:origin: TehNut/HWYLA
@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;
}
代码示例来源:origin: squeek502/VeganOption
/**
* 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);
}
}
代码示例来源:origin: GregTechCE/GregTech
@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())));
}
}
内容来源于网络,如有侵权,请联系作者删除!