类net.minecraftforge.common.property.IUnlistedProperty源码实例Demo

下面列出了怎么用net.minecraftforge.common.property.IUnlistedProperty的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: customstuff4   文件: BlockMixin.java
@Override
protected BlockStateContainer createBlockState()
{
    BlockStateContainer superState = super.createBlockState();
    List<IProperty<?>> superProperties = Lists.newArrayList(superState.getProperties());
    superProperties.addAll(Arrays.asList(getProperties()));

    if (superState instanceof ExtendedBlockState)
    {
        IUnlistedProperty<?>[] unlistedProperties = ((ExtendedBlockState) superState).getUnlistedProperties().toArray(new IUnlistedProperty<?>[0]);

        return new ExtendedBlockState(this, ContentBlockBaseWithSubtypes.insertSubtype(superProperties), unlistedProperties);
    } else
    {
        return new BlockStateContainer(this, ContentBlockBaseWithSubtypes.insertSubtype(superProperties));
    }
}
 
源代码2 项目: VanillaFix   文件: NumericalExtendedBlockState.java
public static NumericalExtendedBlockState getClean(IBlockState normalState, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties) {
    Pair<IBlockState, ImmutableMap<IUnlistedProperty<?>, Optional<?>>> key = new ImmutablePair<>(normalState, unlistedProperties);
    NumericalExtendedBlockState state = cleanStates.get(key);

    if (state == null) {
        state = new NumericalExtendedBlockState(normalState, unlistedProperties);
        cleanStates.put(key, state);
    }

    return state;
}
 
源代码3 项目: VanillaFix   文件: NumericalExtendedBlockState.java
@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));
}
 
源代码4 项目: VanillaFix   文件: NumericalExtendedBlockState.java
@Override
public <V> IExtendedBlockState withProperty(IUnlistedProperty<V> property, @Nullable V value) {
    Optional<?> oldValue = unlistedProperties.get(property);
    if (oldValue == null) {
        throw new IllegalArgumentException("Cannot set unlisted property " + property + " as it does not exist in " + getBlock().getBlockState());
    }

    if (Objects.equals(oldValue.orElse(null), value)) {
        return this;
    }

    if (!property.isValid(value)) {
        throw new IllegalArgumentException("Cannot set unlisted property " + property + " to " + value + " on block " + Block.REGISTRY.getNameForObject(getBlock()) + ", it is not an allowed value");
    }

    boolean clean = true;
    ImmutableMap.Builder<IUnlistedProperty<?>, Optional<?>> builder = ImmutableMap.builder();
    for (Map.Entry<IUnlistedProperty<?>, Optional<?>> entry : unlistedProperties.entrySet()) {
        IUnlistedProperty<?> key = entry.getKey();
        Optional<?> newValue = key.equals(property) ? Optional.ofNullable(value) : entry.getValue();
        if (newValue.isPresent()) clean = false;
        builder.put(key, newValue);
    }

    if (clean) { // no dynamic properties, lookup normal state
        return cleanState;
    }

    return new NumericalExtendedBlockState(normalState, builder.build(), cleanState);
}
 
源代码5 项目: VanillaFix   文件: MixinExtendedBlockState.java
@Override
protected IBlockState createState(ImmutableMap<IProperty<?>, Comparable<?>> properties, @Nullable ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties) {
    if (getClass() != MixinExtendedBlockState.class) {
        return createState(getBlock(), properties, unlistedProperties);
    }

    IBlockState normalState = super.createState(properties, unlistedProperties);
    if (unlistedProperties == null || unlistedProperties.isEmpty()) {
        return normalState;
    }

    return NumericalExtendedBlockState.getClean(normalState, unlistedProperties);
}
 
源代码6 项目: VanillaFix   文件: MixinBlockStateContainer.java
@Overwrite(remap = false)
protected BlockStateContainer.StateImplementation createState(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, @Nullable ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties) {
    if (!isNumerical) {
        return new BlockStateContainer.StateImplementation(block, properties);
    }

    return null;
}
 
源代码7 项目: VanillaFix   文件: MixinBlockStateContainer.java
protected IBlockState createState(ImmutableMap<IProperty<?>, Comparable<?>> properties, @Nullable ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties) {
    BlockStateContainer.StateImplementation state = createState(block, properties, unlistedProperties);
    if (state != null) {
        return state;
    } else {
        return NumericalBlockState.fromPropertyValueMap((BlockStateContainer) (Object) this, properties);
    }
}
 
源代码8 项目: TFC2   文件: BlockLeaves2.java
/*******************************************************************************
 * 3. Blockstate 
 *******************************************************************************/

@Override
protected BlockStateContainer createBlockState()
{
	return new ExtendedBlockState(this, new IProperty[]{META_PROPERTY, BlockLeaves.FANCY}, new IUnlistedProperty[]{ B3DLoader.B3DFrameProperty.INSTANCE });
}
 
源代码9 项目: TFC2   文件: BlockFirepit.java
/*******************************************************************************
 * 3. Blockstate 
 *******************************************************************************/


@Override
protected BlockStateContainer createBlockState()
{
	return new ExtendedBlockState(this, new IProperty[]{LIT, TOOL}, new IUnlistedProperty[]{});
}
 
源代码10 项目: AgriCraft   文件: BlockCrop.java
@Override
public IUnlistedProperty[] getUnlistedPropertyArray() {
    return new IUnlistedProperty[]{
        AgriProperties.CROP_PLANT,
        AgriProperties.GROWTH_STAGE,
        AgriProperties.CROSS_CROP
    };
}
 
源代码11 项目: AgriCraft   文件: BlockCustomWood.java
@Override
public final IUnlistedProperty[] getUnlistedPropertyArray() {
    final List<IUnlistedProperty> list = new ArrayList<>();
    this.addUnlistedProperties(list::add);
    list.add(AgriProperties.CUSTOM_WOOD_TYPE);
    return list.toArray(new IUnlistedProperty[list.size()]);
}
 
源代码12 项目: enderutilities   文件: BlockBarrel.java
@Override
protected BlockStateContainer createBlockState()
{
    return new ExtendedBlockState(this, new IProperty[] { FACING_H, CREATIVE,
            LABEL_UP, LABEL_DOWN, LABEL_FRONT, LABEL_BACK, LABEL_LEFT, LABEL_RIGHT },
            new IUnlistedProperty<?>[] { CAMOBLOCKSTATE, CAMOBLOCKSTATEEXTENDED });
}
 
源代码13 项目: EmergingTechnology   文件: TidalGenerator.java
@Override
public ExtendedBlockState createBlockState() {
    return new ExtendedBlockState(this, new IProperty[] { FACING, Properties.StaticProperty },
            new IUnlistedProperty[] { Properties.AnimationProperty });
}
 
源代码14 项目: EmergingTechnology   文件: Scrubber.java
@Override
public ExtendedBlockState createBlockState() {
    return new ExtendedBlockState(this, new IProperty[] { FACING, Properties.StaticProperty }, new IUnlistedProperty[]{ Properties.AnimationProperty });
}
 
源代码15 项目: EmergingTechnology   文件: Harvester.java
@Override
public ExtendedBlockState createBlockState() {
    return new ExtendedBlockState(this, new IProperty[] { FACING, Properties.StaticProperty },
            new IUnlistedProperty[] { Properties.AnimationProperty });
}
 
源代码16 项目: EmergingTechnology   文件: Wind.java
@Override
public ExtendedBlockState createBlockState() {
    return new ExtendedBlockState(this, new IProperty[] { FACING, Properties.StaticProperty }, new IUnlistedProperty[]{ Properties.AnimationProperty });
}
 
源代码17 项目: GregTech   文件: BlockMachine.java
@Override
protected BlockStateContainer createBlockState() {
    return new ExtendedBlockState(this, new IProperty[]{OPAQUE}, new IUnlistedProperty[]{HARVEST_TOOL, HARVEST_LEVEL});
}
 
源代码18 项目: YouTubeModdingTutorial   文件: BlockGenerator.java
@Override
protected BlockStateContainer createBlockState() {
    return new ExtendedBlockState(this,
            new IProperty[] {Properties.StaticProperty, FACING_HORIZ },
            new IUnlistedProperty[] {Properties.AnimationProperty});
}
 
源代码19 项目: VanillaFix   文件: NumericalExtendedBlockState.java
public NumericalExtendedBlockState(IBlockState normalState, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties) {
    this(normalState, unlistedProperties, null);
}
 
源代码20 项目: VanillaFix   文件: NumericalExtendedBlockState.java
private NumericalExtendedBlockState(IBlockState normalState, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties, NumericalExtendedBlockState cleanState) {
    this.normalState = normalState;
    this.unlistedProperties = unlistedProperties;
    this.cleanState = cleanState == null ? this : cleanState;
}
 
源代码21 项目: VanillaFix   文件: NumericalExtendedBlockState.java
@Override
public ImmutableMap<IUnlistedProperty<?>, Optional<?>> getUnlistedProperties() {
    return unlistedProperties;
}
 
源代码22 项目: VanillaFix   文件: NumericalExtendedBlockState.java
@Override
public Collection<IUnlistedProperty<?>> getUnlistedNames() {
    return unlistedProperties.keySet();
}
 
源代码23 项目: VanillaFix   文件: MixinExtendedBlockState.java
public MixinExtendedBlockState(Block block, IProperty<?>[] properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties) {
    super(block, properties, unlistedProperties);
}
 
源代码24 项目: VanillaFix   文件: MixinExtendedBlockState.java
@Inject(method = "createState", remap = false, at = @At("HEAD"), cancellable = true)
protected void overrideCreateState(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, @Nullable ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties, CallbackInfoReturnable<BlockStateContainer.StateImplementation> cir) {
    if (isNumerical) {
        cir.setReturnValue(null);
    }
}
 
源代码25 项目: VanillaFix   文件: MixinBlockStateContainer.java
@Overwrite
public MixinBlockStateContainer(Block block, IProperty<?>[] properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties) {
    this.block = block;
    this.unlistedProperties = unlistedProperties;

    // Immutable map builder won't work, some mods have duplicate properties
    Map<String, IProperty<?>> propertyMap = new LinkedHashMap<>();
    int offset = 0;

    for (IProperty<?> property : properties) {
        validateProperty(block, property);
        propertyMap.put(property.getName(), property);

        if (isNumerical) {
            NumericalBlockState.makePropertyInfo(property);
            propertyOffsets.put(property, offset);
            offset += MathHelper.log2(property.getAllowedValues().size()) + 1;
        }
    }

    this.properties = ImmutableSortedMap.copyOf(propertyMap);

    if (!isNumerical) {
        Map<Map<IProperty<?>, Comparable<?>>, BlockStateContainer.StateImplementation> map2 = Maps.newLinkedHashMap();
        List<BlockStateContainer.StateImplementation> validStates = Lists.newArrayList();

        for (List<Comparable<?>> list : Cartesian.cartesianProduct(getAllowedValues())) {
            Map<IProperty<?>, Comparable<?>> map1 = MapPopulator.createMap(this.properties.values(), list);
            BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation = createState(block, ImmutableMap.copyOf(map1), unlistedProperties);
            map2.put(map1, blockstatecontainer$stateimplementation);
            validStates.add(blockstatecontainer$stateimplementation);
        }

        for (BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation1 : validStates) {
            blockstatecontainer$stateimplementation1.buildPropertyValueTable(map2);
        }

        this.validStates = ImmutableList.copyOf(validStates);
    }

    x = new Object();
}
 
源代码26 项目: Logistics-Pipes-2   文件: PipeRouted.java
@Override
public BlockStateContainer createBlockState() {
	return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {Properties.AnimationProperty});
}
 
源代码27 项目: Logistics-Pipes-2   文件: PipeChassisMkI.java
@Override
public BlockStateContainer createBlockState() {
	return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {Properties.AnimationProperty});
}
 
源代码28 项目: Logistics-Pipes-2   文件: PipeBlocking.java
@Override
public BlockStateContainer createBlockState() {
	return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {Properties.AnimationProperty});
}
 
源代码29 项目: Logistics-Pipes-2   文件: PipeBasic.java
@Override
public BlockStateContainer createBlockState() {
	return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {Properties.AnimationProperty});
}
 
源代码30 项目: TFC2   文件: BlockSmallVessel.java
@Override
protected BlockStateContainer createBlockState()
{
	return new ExtendedBlockState(this, new IProperty[]{}, new IUnlistedProperty[]{INVENTORY});
}
 
 类方法
 同包方法