本文整理匯總了Java中net.minecraft.block.properties.IProperty.getValueClass方法的典型用法代碼示例。如果您正苦於以下問題:Java IProperty.getValueClass方法的具體用法?Java IProperty.getValueClass怎麽用?Java IProperty.getValueClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.block.properties.IProperty
的用法示例。
在下文中一共展示了IProperty.getValueClass方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: blockColourMatches
import net.minecraft.block.properties.IProperty; //導入方法依賴的package包/類
/** Test whether this block has a colour attribute which matches the list of allowed colours
* @param bs blockstate to test
* @param allowedColours list of allowed Colour enum values
* @return true if the block matches.
*/
public static boolean blockColourMatches(IBlockState bs, List<Colour> allowedColours)
{
for (IProperty prop : (java.util.Set<IProperty>) bs.getProperties().keySet())
{
if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
{
// The block in question has a colour, so check it is a specified one:
net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)bs.getValue(prop);
for (Colour col : allowedColours)
{
if (current.getName().equalsIgnoreCase(col.name()))
return true;
}
}
}
return false;
}
示例2: applyColour
import net.minecraft.block.properties.IProperty; //導入方法依賴的package包/類
/** Recolour the Minecraft block
* @param state The block to be recoloured
* @param colour The new colour
* @return A new blockstate which is a recoloured version of the original
*/
static IBlockState applyColour(IBlockState state, Colour colour)
{
for (IProperty prop : (java.util.Set<IProperty>)state.getProperties().keySet())
{
if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
{
net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop);
if (!current.getName().equalsIgnoreCase(colour.name()))
{
return state.withProperty(prop, EnumDyeColor.valueOf(colour.name()));
}
}
}
return state;
}
示例3: recolorBlock
import net.minecraft.block.properties.IProperty; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
public boolean recolorBlock(World world, BlockPos pos, EnumFacing side, net.minecraft.item.EnumDyeColor color)
{
IBlockState state = world.getBlockState(pos);
for (IProperty prop : state.getProperties().keySet())
{
if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
{
net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop);
if (current != color)
{
world.setBlockState(pos, state.withProperty(prop, color));
return true;
}
}
}
return false;
}
示例4: rotateBlock
import net.minecraft.block.properties.IProperty; //導入方法依賴的package包/類
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis)
{
IBlockState state = world.getBlockState(pos);
for (IProperty prop : state.getProperties().keySet())
{
if (prop.getName().equals("variant") && prop.getValueClass() == EnumType.class)
{
EnumType current = (EnumType)state.getValue(prop);
EnumType next = current == EnumType.LINES_X ? EnumType.LINES_Y :
current == EnumType.LINES_Y ? EnumType.LINES_Z :
current == EnumType.LINES_Z ? EnumType.LINES_X : current;
if (next == current)
return false;
world.setBlockState(pos, state.withProperty(prop, next));
return true;
}
}
return false;
}
示例5: allowedProperty
import net.minecraft.block.properties.IProperty; //導入方法依賴的package包/類
private boolean allowedProperty(IProperty<?> key) {
Class<?> vc = key.getValueClass();
if (EnumFacing.class.isAssignableFrom(vc)) {
return false;
}
if (Objects.equals(key.getName(), "facing")) {
return false;
}
if (Objects.equals(key.getName(), "direction")) {
return false;
}
return true;
}
示例6: parsePropertyValue
import net.minecraft.block.properties.IProperty; //導入方法依賴的package包/類
public static Comparable parsePropertyValue(IProperty p_parsePropertyValue_0_, String p_parsePropertyValue_1_)
{
Class oclass = p_parsePropertyValue_0_.getValueClass();
Comparable comparable = parseValue(p_parsePropertyValue_1_, oclass);
if (comparable == null)
{
Collection collection = p_parsePropertyValue_0_.getAllowedValues();
comparable = getPropertyValue(p_parsePropertyValue_1_, collection);
}
return comparable;
}
示例7: getValidRotations
import net.minecraft.block.properties.IProperty; //導入方法依賴的package包/類
/**
* Get the rotations that can apply to the block at the specified coordinates. Null means no rotations are possible.
* Note, this is up to the block to decide. It may not be accurate or representative.
* @param world The world
* @param pos Block position in world
* @return An array of valid axes to rotate around, or null for none or unknown
*/
public EnumFacing[] getValidRotations(World world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
for (IProperty<?> prop : state.getProperties().keySet())
{
if (prop.getName().equals("facing") && prop.getValueClass() == EnumFacing.class)
{
@SuppressWarnings("unchecked")
java.util.Collection<EnumFacing> values = ((java.util.Collection<EnumFacing>)prop.getAllowedValues());
return values.toArray(new EnumFacing[values.size()]);
}
}
return null;
}