use of com.microsoft.Malmo.Schemas.Colour in project malmo by Microsoft.
the class MinecraftTypeHelper method getItemStackFromParameterString.
/**
* Take a string of parameters, delimited by spaces, and create an ItemStack from it.
* @param parameters the item name, variation, colour etc of the required item, separated by spaces.
* @return an Itemstack for these parameters, or null if unrecognised.
*/
public static ItemStack getItemStackFromParameterString(String parameters) {
// Split into parameters:
List<String> params = new ArrayList<String>(Arrays.asList(parameters.split(" ")));
Colour col = null;
Variation var = null;
// See if any parameters appear to be a colour:
Iterator<String> it = params.iterator();
while (it.hasNext() && col == null) {
col = MinecraftTypeHelper.attemptToGetAsColour(it.next());
if (col != null)
// This parameter was a colour - we've parsed it, so remove it.
it.remove();
}
// See if any parameters appear to be a variant:
it = params.iterator();
while (it.hasNext() && var == null) {
var = MinecraftTypeHelper.attemptToGetAsVariant(it.next());
if (var != null)
// This parameter was a variant - we've parsed it, so remove it.
it.remove();
}
// Hopefully we have at most one parameter left, which will be the type.
if (params.size() == 0)
// Dunno what to do, really.
return null;
String itemName = params.get(0);
DrawItem di = new DrawItem();
di.setColour(col);
di.setVariant(var);
di.setType(itemName);
return getItemStackFromDrawItem(di);
}
use of com.microsoft.Malmo.Schemas.Colour in project malmo by Microsoft.
the class MovingTargetDecoratorImplementation method isValid.
private boolean isValid(World world, BlockPos pos) {
// In bounds?
if (!blockInBounds(pos, this.arenaBounds))
return false;
// Already in path?
if (this.path.contains(pos))
return false;
// Does there need to be air above the target?
if (this.targetParams.isRequiresAirAbove() && !world.isAirBlock(pos.up()))
return false;
// Check the current block is "permeable"...
IBlockState block = world.getBlockState(pos);
List<IProperty> extraProperties = new ArrayList<IProperty>();
DrawBlock db = MinecraftTypeHelper.getDrawBlockFromBlockState(block, extraProperties);
boolean typesMatch = this.targetParams.getPermeableBlocks().getType().isEmpty();
for (BlockType bt : this.targetParams.getPermeableBlocks().getType()) {
if (db.getType() == bt) {
typesMatch = true;
break;
}
}
if (!typesMatch)
return false;
if (db.getColour() != null) {
boolean coloursMatch = this.targetParams.getPermeableBlocks().getColour().isEmpty();
for (Colour col : this.targetParams.getPermeableBlocks().getColour()) {
if (db.getColour() == col) {
coloursMatch = true;
break;
}
}
if (!coloursMatch)
return false;
}
if (db.getVariant() != null) {
boolean variantsMatch = this.targetParams.getPermeableBlocks().getVariant().isEmpty();
for (Variation var : this.targetParams.getPermeableBlocks().getVariant()) {
if (db.getVariant() == var) {
variantsMatch = true;
break;
}
}
if (!variantsMatch)
return false;
}
return true;
}
Aggregations