net.minecraftforge.common.property.IUnlistedProperty Java Examples

The following examples show how to use net.minecraftforge.common.property.IUnlistedProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockMixin.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@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));
    }
}
 
Example #2
Source File: BlockBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 });
}
 
Example #3
Source File: BlockLeaves2.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/*******************************************************************************
 * 3. Blockstate 
 *******************************************************************************/

@Override
protected BlockStateContainer createBlockState()
{
	return new ExtendedBlockState(this, new IProperty[]{META_PROPERTY, BlockLeaves.FANCY}, new IUnlistedProperty[]{ B3DLoader.B3DFrameProperty.INSTANCE });
}
 
Example #4
Source File: BlockFirepit.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/*******************************************************************************
 * 3. Blockstate 
 *******************************************************************************/


@Override
protected BlockStateContainer createBlockState()
{
	return new ExtendedBlockState(this, new IProperty[]{LIT, TOOL}, new IUnlistedProperty[]{});
}
 
Example #5
Source File: BlockCrop.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public IUnlistedProperty[] getUnlistedPropertyArray() {
    return new IUnlistedProperty[]{
        AgriProperties.CROP_PLANT,
        AgriProperties.GROWTH_STAGE,
        AgriProperties.CROSS_CROP
    };
}
 
Example #6
Source File: NumericalExtendedBlockState.java    From VanillaFix with MIT License 5 votes vote down vote up
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;
}
 
Example #7
Source File: BlockCustomWood.java    From AgriCraft with MIT License 5 votes vote down vote up
@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()]);
}
 
Example #8
Source File: NumericalExtendedBlockState.java    From VanillaFix with MIT License 5 votes vote down vote up
@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));
}
 
Example #9
Source File: NumericalExtendedBlockState.java    From VanillaFix with MIT License 5 votes vote down vote up
@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);
}
 
Example #10
Source File: MixinBlockStateContainer.java    From VanillaFix with MIT License 5 votes vote down vote up
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);
    }
}
 
Example #11
Source File: MixinBlockStateContainer.java    From VanillaFix with MIT License 5 votes vote down vote up
@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;
}
 
Example #12
Source File: MixinExtendedBlockState.java    From VanillaFix with MIT License 5 votes vote down vote up
@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);
}
 
Example #13
Source File: BlockWaterTank.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
protected void addUnlistedProperties(Consumer<IUnlistedProperty> consumer) {
    super.addUnlistedProperties(consumer);
    AgriSideMetaMatrix.addUnlistedProperties(consumer);
}
 
Example #14
Source File: BlockPitKiln.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState()
{
	return new ExtendedBlockState(this, new IProperty[]{FILL, FILLTYPE}, new IUnlistedProperty[]{INVENTORY});
}
 
Example #15
Source File: BlockAnvil.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState()
{
	return new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{INVENTORY});
}
 
Example #16
Source File: AgriSideMetaMatrix.java    From AgriCraft with MIT License 4 votes vote down vote up
public static void addUnlistedProperties(Consumer<IUnlistedProperty> consumer) {
    for (ConnectionSide side : ConnectionSide.values()) {
        consumer.accept(side.property);
    }
}
 
Example #17
Source File: AbstractBlockWaterChannel.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
protected void addUnlistedProperties(Consumer<IUnlistedProperty> consumer) {
    super.addUnlistedProperties(consumer);
    AgriSideMetaMatrix.addUnlistedProperties(consumer);
}
 
Example #18
Source File: BlockSprinkler.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
public final IUnlistedProperty[] getUnlistedPropertyArray() {
    return new IUnlistedProperty[]{AgriProperties.CUSTOM_WOOD_TYPE};
}
 
Example #19
Source File: PipeChassisMkI.java    From Logistics-Pipes-2 with MIT License 4 votes vote down vote up
@Override
public BlockStateContainer createBlockState() {
	return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {Properties.AnimationProperty});
}
 
Example #20
Source File: BlockWaterPad.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
protected IUnlistedProperty[] getUnlistedPropertyArray() {
    final List<IUnlistedProperty> props = new ArrayList<>();
    AgriSideMetaMatrix.addUnlistedProperties(props::add);
    return props.toArray(new IUnlistedProperty[6]);
}
 
Example #21
Source File: BlockCustomWood.java    From AgriCraft with MIT License 4 votes vote down vote up
protected void addUnlistedProperties(Consumer<IUnlistedProperty> consumer) {
    // Nothing to do here.
}
 
Example #22
Source File: BlockPortalFrame.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState()
{
    return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty<?>[] { CAMOBLOCKSTATE, CAMOBLOCKSTATEEXTENDED });
}
 
Example #23
Source File: BlockElevator.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState()
{
    return new ExtendedBlockState(this, new IProperty[] { COLOR }, new IUnlistedProperty<?>[] { CAMOBLOCKSTATE, CAMOBLOCKSTATEEXTENDED });
}
 
Example #24
Source File: BlockDrawbridge.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState()
{
    return new ExtendedBlockState(this, new IProperty[] { ADVANCED, FACING }, new IUnlistedProperty<?>[] { CAMOBLOCKSTATE, CAMOBLOCKSTATEEXTENDED });
}
 
Example #25
Source File: BlockElevatorSlab.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState()
{
    return new ExtendedBlockState(this, new IProperty[] { COLOR, HALF }, new IUnlistedProperty<?>[] { CAMOBLOCKSTATE, CAMOBLOCKSTATEEXTENDED });
}
 
Example #26
Source File: SimpleUnlistedProperty.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static <T> IUnlistedProperty<T> create(Class<T> type, String name) {
	return new SimpleUnlistedProperty<>(type, name);
}
 
Example #27
Source File: NumericalExtendedBlockState.java    From VanillaFix with MIT License 4 votes vote down vote up
@Override
public Collection<IUnlistedProperty<?>> getUnlistedNames() {
    return unlistedProperties.keySet();
}
 
Example #28
Source File: Scrubber.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Override
public ExtendedBlockState createBlockState() {
    return new ExtendedBlockState(this, new IProperty[] { FACING, Properties.StaticProperty }, new IUnlistedProperty[]{ Properties.AnimationProperty });
}
 
Example #29
Source File: Harvester.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Override
public ExtendedBlockState createBlockState() {
    return new ExtendedBlockState(this, new IProperty[] { FACING, Properties.StaticProperty },
            new IUnlistedProperty[] { Properties.AnimationProperty });
}
 
Example #30
Source File: Wind.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Override
public ExtendedBlockState createBlockState() {
    return new ExtendedBlockState(this, new IProperty[] { FACING, Properties.StaticProperty }, new IUnlistedProperty[]{ Properties.AnimationProperty });
}