Search in sources :

Example 1 with NbtPredicate

use of net.minecraft.advancements.critereon.NbtPredicate in project Railcraft by Railcraft.

the class MultiBlockFormedTrigger method deserializeInstance.

@Override
public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) {
    Class<? extends TileEntity> type;
    if (json.has("type")) {
        String id = JsonUtils.getString(json, "type");
        type = TileEntity.REGISTRY.getObject(new ResourceLocation(id));
    } else {
        type = null;
    }
    NBTPredicate nbt = JsonTools.whenPresent(json, "nbt", NBTPredicate::deserialize, NBTPredicate.ANY);
    return new Instance(type, nbt);
}
Also used : ICriterionInstance(net.minecraft.advancements.ICriterionInstance) Instance(mods.railcraft.common.advancements.criterion.MultiBlockFormedTrigger.Instance) ResourceLocation(net.minecraft.util.ResourceLocation) NBTPredicate(net.minecraft.advancements.critereon.NBTPredicate)

Example 2 with NbtPredicate

use of net.minecraft.advancements.critereon.NbtPredicate in project Railcraft by Railcraft.

the class UseTrackKitTrigger method deserializeInstance.

@Override
public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) {
    NBTPredicate nbt = JsonTools.whenPresent(json, "data", NBTPredicate::deserialize, NBTPredicate.ANY);
    ItemPredicate used = JsonTools.whenPresent(json, "used", ItemPredicate::deserialize, ItemPredicate.ANY);
    LocationPredicate location = JsonTools.whenPresent(json, "location", LocationPredicate::deserialize, LocationPredicate.ANY);
    return new Instance(nbt, used, location);
}
Also used : ItemPredicate(net.minecraft.advancements.critereon.ItemPredicate) Instance(mods.railcraft.common.advancements.criterion.UseTrackKitTrigger.Instance) ICriterionInstance(net.minecraft.advancements.ICriterionInstance) NBTPredicate(net.minecraft.advancements.critereon.NBTPredicate) LocationPredicate(net.minecraft.advancements.critereon.LocationPredicate)

Example 3 with NbtPredicate

use of net.minecraft.advancements.critereon.NbtPredicate in project Railcraft by Railcraft.

the class SpikeMaulUseTrigger method deserializeInstance.

@Override
public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) {
    NBTPredicate nbt = JsonTools.whenPresent(json, "nbt", NBTPredicate::deserialize, NBTPredicate.ANY);
    ItemPredicate tool = JsonTools.whenPresent(json, "tool", ItemPredicate::deserialize, ItemPredicate.ANY);
    LocationPredicate locationPredicate = JsonTools.whenPresent(json, "location", LocationPredicate::deserialize, LocationPredicate.ANY);
    return new Instance(nbt, tool, locationPredicate);
}
Also used : ItemPredicate(net.minecraft.advancements.critereon.ItemPredicate) Instance(mods.railcraft.common.advancements.criterion.SpikeMaulUseTrigger.Instance) ICriterionInstance(net.minecraft.advancements.ICriterionInstance) NBTPredicate(net.minecraft.advancements.critereon.NBTPredicate) LocationPredicate(net.minecraft.advancements.critereon.LocationPredicate)

Aggregations

ICriterionInstance (net.minecraft.advancements.ICriterionInstance)3 NBTPredicate (net.minecraft.advancements.critereon.NBTPredicate)3 ItemPredicate (net.minecraft.advancements.critereon.ItemPredicate)2 LocationPredicate (net.minecraft.advancements.critereon.LocationPredicate)2 Instance (mods.railcraft.common.advancements.criterion.MultiBlockFormedTrigger.Instance)1 Instance (mods.railcraft.common.advancements.criterion.SpikeMaulUseTrigger.Instance)1 Instance (mods.railcraft.common.advancements.criterion.UseTrackKitTrigger.Instance)1 ResourceLocation (net.minecraft.util.ResourceLocation)1