use of net.silentchaos512.gear.api.part.MaterialGrade in project Silent-Gear by SilentChaos512.
the class LazyMaterialInstance method read.
public static LazyMaterialInstance read(FriendlyByteBuf buffer) {
ResourceLocation id = buffer.readResourceLocation();
MaterialGrade grade = buffer.readEnum(MaterialGrade.class);
return new LazyMaterialInstance(id, grade);
}
use of net.silentchaos512.gear.api.part.MaterialGrade in project Silent-Gear by SilentChaos512.
the class IMaterialInstance method serialize.
default JsonObject serialize() {
JsonObject json = new JsonObject();
json.addProperty("material", getId().toString());
MaterialGrade grade = getGrade();
if (grade != MaterialGrade.NONE) {
json.addProperty("grade", grade.name());
}
return json;
}
use of net.silentchaos512.gear.api.part.MaterialGrade in project Silent-Gear by SilentChaos512.
the class GraderTileEntity method tryGradeItem.
private void tryGradeItem(ItemStack input, int catalystTier, IMaterialInstance material) {
MaterialGrade targetGrade = MaterialGrade.selectWithCatalyst(SilentGear.RANDOM, catalystTier);
this.lastGradeAttempt = targetGrade;
if (targetGrade.ordinal() > material.getGrade().ordinal()) {
// Assign grade, move to output slot
ItemStack stack = input.split(1);
targetGrade.setGradeOnStack(stack);
InventoryUtils.mergeItem(this, 2, 2 + SLOTS_OUTPUT.length, stack);
}
}
use of net.silentchaos512.gear.api.part.MaterialGrade in project Silent-Gear by SilentChaos512.
the class LazyMaterialInstance method deserialize.
public static LazyMaterialInstance deserialize(JsonObject json) {
ResourceLocation id = new ResourceLocation(GsonHelper.getAsString(json, "material"));
MaterialGrade grade = EnumUtils.byName(GsonHelper.getAsString(json, "grade", "NONE"), MaterialGrade.NONE);
return new LazyMaterialInstance(id, grade);
}
use of net.silentchaos512.gear.api.part.MaterialGrade in project Silent-Gear by SilentChaos512.
the class MaterialInstance method readShorthand.
@Nullable
public static MaterialInstance readShorthand(String str) {
if (str.contains("#")) {
String[] parts = str.split("#");
ResourceLocation id = SilentGear.getIdWithDefaultNamespace(parts[0]);
IMaterial material = MaterialManager.get(id);
if (material != null) {
MaterialGrade grade = MaterialGrade.fromString(parts[1]);
return new MaterialInstance(material, grade);
}
return null;
}
ResourceLocation id = SilentGear.getIdWithDefaultNamespace(str);
IMaterial material = MaterialManager.get(id);
if (material != null) {
return new MaterialInstance(material);
}
return null;
}
Aggregations