mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Fix the rest of the "easy" compile errors (#5151)
* Add Entity.changeDimension patch and transitively required patches * Fix throws declaration on CommandSetDimension#execute * Fix rest of errors in fluid package * Add PLAYER_REACH attribute * Fix compile errors in fml.client.config and add GuiButton patch * Delete unnecessary client.config classes, fix all config errors * Comment some fluid errors in models * Fix all errors in common package root, except ForgeHooks * Mass comment network package * Experimental conversion of extended states to generic base class * Fix errors in common.util * Remove config annotation stuff cuz lex said so * Make extended state stuff compile fully
This commit is contained in:
1 parent
6814cbf0df
commit
c4cf950863
72 files changed
+610
-5996
No files matched your search
+31
-29
@@ -38,15 +38,16 @@ import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.state.AbstractStateHolder;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.IStateHolder;
|
||||
import net.minecraft.state.StateContainer;
|
||||
|
||||
public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
// TODO Extended states gotta go, I doubt this works at all
|
||||
public class ExtendedStateContainer<O, S extends IExtendedState<S>> extends StateContainer<O, S>
|
||||
{
|
||||
private final ImmutableSet<IUnlistedProperty<?>> unlistedProperties;
|
||||
|
||||
public <A extends AbstractStateHolder<Block, IBlockState>> ExtendedBlockState(Block blockIn, StateContainer.IFactory<Block, IBlockState, ?> stateFactory, net.minecraft.state.IProperty<?>[] properties, IUnlistedProperty<?>[] unlistedProperties)
|
||||
public <A extends AbstractStateHolder<O, S>> ExtendedStateContainer(O blockIn, StateContainer.IFactory<O, S, A> stateFactory, net.minecraft.state.IProperty<?>[] properties, IUnlistedProperty<?>[] unlistedProperties)
|
||||
{
|
||||
super(blockIn, stateFactory, buildListedMap(properties));// TODO Unlisted properties?, buildUnlistedMap(unlistedProperties));
|
||||
super(blockIn, getProxyFactory(unlistedProperties, stateFactory), buildListedMap(properties));// TODO Unlisted properties?, buildUnlistedMap(unlistedProperties));
|
||||
ImmutableSet.Builder<IUnlistedProperty<?>> builder = ImmutableSet.builder();
|
||||
for(IUnlistedProperty<?> property : unlistedProperties)
|
||||
{
|
||||
@@ -54,6 +55,15 @@ public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
}
|
||||
this.unlistedProperties = builder.build();
|
||||
}
|
||||
|
||||
private static <O, S extends IExtendedState<S>, A extends AbstractStateHolder<O, S>>
|
||||
StateContainer.IFactory<O, S, AbstractStateHolder<O,S>> getProxyFactory(IUnlistedProperty<?>[] unlistedProperties, StateContainer.IFactory<O, S, A> proxy)
|
||||
{
|
||||
return (o, props) -> {
|
||||
if (unlistedProperties == null || unlistedProperties.length == 0) return proxy.create(o, props);
|
||||
return new ExtendedStateHolder<O, S>(o, props, buildUnlistedMap(unlistedProperties), null);
|
||||
};
|
||||
}
|
||||
|
||||
public Collection<IUnlistedProperty<?>> getUnlistedProperties()
|
||||
{
|
||||
@@ -75,33 +85,25 @@ public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
protected StateImplementation createState(@Nonnull Block block, @Nonnull ImmutableMap<IProperty<?>, Comparable<?>> properties, @Nullable ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties)
|
||||
{
|
||||
if (unlistedProperties == null || unlistedProperties.isEmpty()) return super.createState(block, properties, unlistedProperties);
|
||||
return new ExtendedStateImplementation(block, properties, unlistedProperties, null, null);
|
||||
}
|
||||
|
||||
protected static class ExtendedStateImplementation extends StateImplementation implements IExtendedBlockState
|
||||
protected static class ExtendedStateHolder<O, S extends IExtendedState<S>> extends AbstractStateHolder<O, S> implements IExtendedState<S>
|
||||
{
|
||||
private final ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties;
|
||||
private IBlockState cleanState;
|
||||
private S cleanState;
|
||||
|
||||
protected ExtendedStateImplementation(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties, @Nullable ImmutableTable<IProperty<?>, Comparable<?>, IBlockState> table, IBlockState clean)
|
||||
protected ExtendedStateHolder(O block, ImmutableMap<IProperty<?>, Comparable<?>> properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties, S clean)
|
||||
{
|
||||
super(block, properties, table);
|
||||
super(block, properties);
|
||||
this.unlistedProperties = unlistedProperties;
|
||||
this.cleanState = clean == null ? this : clean;
|
||||
this.cleanState = clean == null ? (S) this : clean;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public <T extends Comparable<T>, V extends T> IBlockState withProperty(@Nonnull IProperty<T> property, @Nonnull V value)
|
||||
public <T extends Comparable<T>, V extends T> S func_206870_a(@Nonnull IProperty<T> property, @Nonnull V value)
|
||||
{
|
||||
IBlockState clean = super.withProperty(property, value);
|
||||
S clean = super.func_206870_a(property, value);
|
||||
if (clean == this.cleanState) {
|
||||
return this;
|
||||
return (S) this;
|
||||
}
|
||||
|
||||
if (this == this.cleanState)
|
||||
@@ -109,24 +111,24 @@ public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
return clean;
|
||||
}
|
||||
|
||||
return new ExtendedStateImplementation(getBlock(), clean.getProperties(), unlistedProperties, ((StateImplementation)clean).getPropertyValueTable(), this.cleanState);
|
||||
return (S) new ExtendedStateHolder(field_206876_a, ((BlockState)clean).func_206871_b(), unlistedProperties, this.cleanState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> IExtendedBlockState withProperty(IUnlistedProperty<V> property, @Nullable V value)
|
||||
public <V> S 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());
|
||||
throw new IllegalArgumentException("Cannot set unlisted property " + property + " as it does not exist in " + this);
|
||||
}
|
||||
if (Objects.equals(oldValue.orElse(null), value))
|
||||
{
|
||||
return this;
|
||||
return (S) 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");
|
||||
throw new IllegalArgumentException("Cannot set unlisted property " + property + " to " + value + " on object " + field_206876_a + ", it is not an allowed value");
|
||||
}
|
||||
boolean clean = true;
|
||||
ImmutableMap.Builder<IUnlistedProperty<?>, Optional<?>> builder = ImmutableMap.builder();
|
||||
@@ -139,9 +141,9 @@ public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
}
|
||||
if (clean)
|
||||
{ // no dynamic properties, lookup normal state
|
||||
return (IExtendedBlockState) cleanState;
|
||||
return (S) cleanState;
|
||||
}
|
||||
return new ExtendedStateImplementation(getBlock(), getProperties(), builder.build(), propertyValueTable, this.cleanState);
|
||||
return (S) new ExtendedStateHolder(field_206876_a, func_206871_b(), builder.build(), this.cleanState);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +159,7 @@ public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
Optional<?> value = unlistedProperties.get(property);
|
||||
if (value == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot get unlisted property " + property + " as it does not exist in " + getBlock().getBlockState());
|
||||
throw new IllegalArgumentException("Cannot get unlisted property " + property + " as it does not exist in " + this);
|
||||
}
|
||||
return property.getType().cast(value.orElse(null));
|
||||
}
|
||||
@@ -168,7 +170,7 @@ public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getClean()
|
||||
public S getClean()
|
||||
{
|
||||
return cleanState;
|
||||
}
|
||||
@@ -1,40 +1,8 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2018.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.property;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
import java.util.Optional;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public interface IExtendedBlockState extends IBlockState
|
||||
public interface IExtendedBlockState extends IExtendedState<IBlockState>, IBlockState
|
||||
{
|
||||
Collection<IUnlistedProperty<?>> getUnlistedNames();
|
||||
|
||||
<V>V getValue(IUnlistedProperty<V> property);
|
||||
|
||||
<V>IExtendedBlockState withProperty(IUnlistedProperty<V> property, V value);
|
||||
|
||||
ImmutableMap<IUnlistedProperty<?>, Optional<?>> getUnlistedProperties();
|
||||
|
||||
IBlockState getClean();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2018.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.property;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.state.IStateHolder;
|
||||
|
||||
import java.util.Optional;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public interface IExtendedState<C> extends IStateHolder<C>
|
||||
{
|
||||
Collection<IUnlistedProperty<?>> getUnlistedNames();
|
||||
|
||||
<V>V getValue(IUnlistedProperty<V> property);
|
||||
|
||||
<V>C withProperty(IUnlistedProperty<V> property, V value);
|
||||
|
||||
ImmutableMap<IUnlistedProperty<?>, Optional<?>> getUnlistedProperties();
|
||||
|
||||
C getClean();
|
||||
}
|
||||
Reference in new issue
Block a user