public DumpMaterialTest() { baseMaterial = new Material("Baseline", TextFormatting.WHITE); baseMaterial.addStats(new HeadMaterialStats(500, 10, 10, 1)); }
/** * Adds the trait as the default trait, will be used if no more specific one is present time. */ public Material addTrait(ITrait materialTrait) { return addTrait(materialTrait, null); }
public boolean isValidMaterial(Material material) { for(String type : neededTypes) { if(!material.hasStats(type)) { return false; } } return true; }
protected String getStatName(String type) { return Material.UNKNOWN.getStats(type).getLocalizedName(); }
@SuppressWarnings("unchecked") public <T extends IMaterialStats> T getStatsOrUnknown(String identifier) { T stats = (T) getStatsSafe(identifier); if(stats == null && this != UNKNOWN) { return UNKNOWN.getStats(identifier); } return stats; }
public ContentMaterial(Material material) { this.material = material; this.materialName = material.getIdentifier(); }
private void safeAdd(Material material, ItemStack itemStack, int value, boolean representative) { if(!itemStack.isEmpty()) { material.addItem(itemStack, 1, value); if(representative) { material.setRepresentativeItem(itemStack); } } }
public boolean hasStats(String identifier) { return getStats(identifier) != null; }
/** * Returns the material stats of the given type of this material. * * @param identifier Identifier of the material. * @param <T> Type of the Stats are determined by return value. Use the correct * @return The stats found or null if none present. */ @SuppressWarnings("unchecked") public <T extends IMaterialStats> T getStats(String identifier) { return (T) getStatsSafe(identifier); }
@Override protected boolean isValidSubitemMaterial(Material material) { return material.isCastable(); } }
public static String formatDurability(int durability) { return formatNumber(LOC_Durability, COLOR_Durability, durability); } }
public static String formatModifier(float quality) { return formatNumber(LOC_Multiplier, COLOR_Modifier, quality); } }
public static String formatAmmo(int durability) { return formatNumber(LOC_Ammo, COLOR_Ammo, durability); } }
public static String formatAccuracy(float accuraccy) { return formatNumberPercent(LOC_Accuracy, COLOR_Accuracy, accuraccy); } }
public static String formatMiningSpeed(float speed) { return formatNumber(LOC_MiningSpeed, COLOR_Speed, speed); }
public static String formatNumber(String loc, String color, int number) { return formatNumber(loc, color, (float) number); }
private void safeAddOredicted(Material material, String oredict, ItemStack representative) { material.addItem(oredict, 1, Material.VALUE_Ingot); material.setRepresentativeItem(representative); }
@Override public boolean canUseMaterial(Material mat) { return mat.hasStats(MaterialTypes.HEAD); }