Easier handling of meta blocks
This commit is contained in:
parent
fb94914b91
commit
9035f800e2
16 changed files with 436 additions and 277 deletions
|
@ -0,0 +1,41 @@
|
|||
package WayofTime.bloodmagic.block.property;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.block.properties.PropertyHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PropertyString extends PropertyHelper {
|
||||
|
||||
private final ImmutableSet allowedValues;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected PropertyString(String name, String[] values) {
|
||||
super(name, String.class);
|
||||
|
||||
HashSet hashSet = Sets.newHashSet();
|
||||
hashSet.addAll(Arrays.asList(values));
|
||||
allowedValues = ImmutableSet.copyOf(hashSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection getAllowedValues() {
|
||||
return allowedValues;
|
||||
}
|
||||
|
||||
public String getName0(String value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(Comparable value) {
|
||||
return this.getName0(value.toString());
|
||||
}
|
||||
|
||||
public static PropertyString create(String name, String[] values) {
|
||||
return new PropertyString(name, values);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package WayofTime.bloodmagic.block.property;
|
||||
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
public class UnlistedPropertyInteger implements IUnlistedProperty<Integer> {
|
||||
|
||||
private int maxMeta;
|
||||
private String propName;
|
||||
|
||||
public UnlistedPropertyInteger(int maxMeta, String propName) {
|
||||
this.maxMeta = maxMeta;
|
||||
this.propName = propName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Integer value) {
|
||||
return value <= maxMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Integer> getType() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(Integer value) {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package WayofTime.bloodmagic.block.property;
|
||||
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class UnlistedPropertyString implements IUnlistedProperty<String> {
|
||||
|
||||
private List values;
|
||||
private String propName;
|
||||
|
||||
public UnlistedPropertyString(String[] values, String propName) {
|
||||
this.values = Arrays.asList(values);
|
||||
this.propName = propName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value) {
|
||||
return values.contains(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(String value) {
|
||||
return value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue