base mod created

This commit is contained in:
Mohammad-Ali Minaie
2018-10-08 09:07:47 -04:00
parent 0a7700c356
commit b86dedad2f
7848 changed files with 584664 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
package net.minecraft.block.properties;
import com.google.common.base.Optional;
import java.util.Collection;
public interface IProperty<T extends Comparable<T>>
{
String getName();
Collection<T> getAllowedValues();
/**
* The class of the values of this property
*/
Class<T> getValueClass();
Optional<T> parseValue(String value);
/**
* Get the name for the given value.
*/
String getName(T value);
}

View File

@@ -0,0 +1,60 @@
package net.minecraft.block.properties;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import java.util.Collection;
public class PropertyBool extends PropertyHelper<Boolean>
{
private final ImmutableSet<Boolean> allowedValues = ImmutableSet.<Boolean>of(Boolean.valueOf(true), Boolean.valueOf(false));
protected PropertyBool(String name)
{
super(name, Boolean.class);
}
public Collection<Boolean> getAllowedValues()
{
return this.allowedValues;
}
public static PropertyBool create(String name)
{
return new PropertyBool(name);
}
public Optional<Boolean> parseValue(String value)
{
return !"true".equals(value) && !"false".equals(value) ? Optional.absent() : Optional.of(Boolean.valueOf(value));
}
/**
* Get the name for the given value.
*/
public String getName(Boolean value)
{
return value.toString();
}
public boolean equals(Object p_equals_1_)
{
if (this == p_equals_1_)
{
return true;
}
else if (p_equals_1_ instanceof PropertyBool && super.equals(p_equals_1_))
{
PropertyBool propertybool = (PropertyBool)p_equals_1_;
return this.allowedValues.equals(propertybool.allowedValues);
}
else
{
return false;
}
}
public int hashCode()
{
return 31 * super.hashCode() + this.allowedValues.hashCode();
}
}

View File

@@ -0,0 +1,40 @@
package net.minecraft.block.properties;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import java.util.Collection;
import net.minecraft.util.EnumFacing;
public class PropertyDirection extends PropertyEnum<EnumFacing>
{
protected PropertyDirection(String name, Collection<EnumFacing> values)
{
super(name, EnumFacing.class, values);
}
/**
* Create a new PropertyDirection with the given name
*/
public static PropertyDirection create(String name)
{
return create(name, Predicates.alwaysTrue());
}
/**
* Create a new PropertyDirection with all directions that match the given Predicate
*/
public static PropertyDirection create(String name, Predicate<EnumFacing> filter)
{
return create(name, Collections2.filter(Lists.newArrayList(EnumFacing.values()), filter));
}
/**
* Create a new PropertyDirection for the given direction values
*/
public static PropertyDirection create(String name, Collection<EnumFacing> values)
{
return new PropertyDirection(name, values);
}
}

View File

@@ -0,0 +1,112 @@
package net.minecraft.block.properties;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.Map;
import net.minecraft.util.IStringSerializable;
public class PropertyEnum<T extends Enum<T> & IStringSerializable> extends PropertyHelper<T>
{
private final ImmutableSet<T> allowedValues;
/** Map of names to Enum values */
private final Map<String, T> nameToValue = Maps.<String, T>newHashMap();
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
super(name, valueClass);
this.allowedValues = ImmutableSet.copyOf(allowedValues);
for (T t : allowedValues)
{
String s = ((IStringSerializable)t).getName();
if (this.nameToValue.containsKey(s))
{
throw new IllegalArgumentException("Multiple values have the same name '" + s + "'");
}
this.nameToValue.put(s, t);
}
}
public Collection<T> getAllowedValues()
{
return this.allowedValues;
}
public Optional<T> parseValue(String value)
{
return Optional.<T>fromNullable(this.nameToValue.get(value));
}
/**
* Get the name for the given value.
*/
public String getName(T value)
{
return ((IStringSerializable)value).getName();
}
public boolean equals(Object p_equals_1_)
{
if (this == p_equals_1_)
{
return true;
}
else if (p_equals_1_ instanceof PropertyEnum && super.equals(p_equals_1_))
{
PropertyEnum<?> propertyenum = (PropertyEnum)p_equals_1_;
return this.allowedValues.equals(propertyenum.allowedValues) && this.nameToValue.equals(propertyenum.nameToValue);
}
else
{
return false;
}
}
public int hashCode()
{
int i = super.hashCode();
i = 31 * i + this.allowedValues.hashCode();
i = 31 * i + this.nameToValue.hashCode();
return i;
}
/**
* Create a new PropertyEnum with all Enum constants of the given class.
*/
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz)
{
return create(name, clazz, Predicates.alwaysTrue());
}
/**
* Create a new PropertyEnum with all Enum constants of the given class that match the given Predicate.
*/
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Predicate<T> filter)
{
return create(name, clazz, Collections2.filter(Lists.newArrayList(clazz.getEnumConstants()), filter));
}
/**
* Create a new PropertyEnum with the specified values
*/
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, T... values)
{
return create(name, clazz, Lists.newArrayList(values));
}
/**
* Create a new PropertyEnum with the specified values
*/
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Collection<T> values)
{
return new PropertyEnum<T>(name, clazz, values);
}
}

View File

@@ -0,0 +1,55 @@
package net.minecraft.block.properties;
import com.google.common.base.MoreObjects;
public abstract class PropertyHelper<T extends Comparable<T>> implements IProperty<T>
{
private final Class<T> valueClass;
private final String name;
protected PropertyHelper(String name, Class<T> valueClass)
{
this.valueClass = valueClass;
this.name = name;
}
public String getName()
{
return this.name;
}
/**
* The class of the values of this property
*/
public Class<T> getValueClass()
{
return this.valueClass;
}
public String toString()
{
return MoreObjects.toStringHelper(this).add("name", this.name).add("clazz", this.valueClass).add("values", this.getAllowedValues()).toString();
}
public boolean equals(Object p_equals_1_)
{
if (this == p_equals_1_)
{
return true;
}
else if (!(p_equals_1_ instanceof PropertyHelper))
{
return false;
}
else
{
PropertyHelper<?> propertyhelper = (PropertyHelper)p_equals_1_;
return this.valueClass.equals(propertyhelper.valueClass) && this.name.equals(propertyhelper.name);
}
}
public int hashCode()
{
return 31 * this.valueClass.hashCode() + this.name.hashCode();
}
}

View File

@@ -0,0 +1,90 @@
package net.minecraft.block.properties;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.Set;
public class PropertyInteger extends PropertyHelper<Integer>
{
private final ImmutableSet<Integer> allowedValues;
protected PropertyInteger(String name, int min, int max)
{
super(name, Integer.class);
if (min < 0)
{
throw new IllegalArgumentException("Min value of " + name + " must be 0 or greater");
}
else if (max <= min)
{
throw new IllegalArgumentException("Max value of " + name + " must be greater than min (" + min + ")");
}
else
{
Set<Integer> set = Sets.<Integer>newHashSet();
for (int i = min; i <= max; ++i)
{
set.add(Integer.valueOf(i));
}
this.allowedValues = ImmutableSet.copyOf(set);
}
}
public Collection<Integer> getAllowedValues()
{
return this.allowedValues;
}
public boolean equals(Object p_equals_1_)
{
if (this == p_equals_1_)
{
return true;
}
else if (p_equals_1_ instanceof PropertyInteger && super.equals(p_equals_1_))
{
PropertyInteger propertyinteger = (PropertyInteger)p_equals_1_;
return this.allowedValues.equals(propertyinteger.allowedValues);
}
else
{
return false;
}
}
public int hashCode()
{
return 31 * super.hashCode() + this.allowedValues.hashCode();
}
public static PropertyInteger create(String name, int min, int max)
{
return new PropertyInteger(name, min, max);
}
public Optional<Integer> parseValue(String value)
{
try
{
Integer integer = Integer.valueOf(value);
return this.allowedValues.contains(integer) ? Optional.of(integer) : Optional.absent();
}
catch (NumberFormatException var3)
{
return Optional.<Integer>absent();
}
}
/**
* Get the name for the given value.
*/
public String getName(Integer value)
{
return value.toString();
}
}

View File

@@ -0,0 +1,7 @@
// Auto generated package-info by MCP
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraft.block.properties;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;