-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModCriteriaTriggers.java
66 lines (50 loc) · 2.3 KB
/
ModCriteriaTriggers.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package net.mehvahdjukaar.selene.common;
import com.google.gson.JsonObject;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.advancements.critereon.*;
import net.minecraft.advancements.CriterionTriggerInstance;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.resources.ResourceLocation;
public class ModCriteriaTriggers {
public static void init(){}
public static final GrindedItem GRIND = CriteriaTriggers.register(new GrindedItem());
public static class GrindedItem extends SimpleCriterionTrigger<GrindedItem.Instance> {
private static final ResourceLocation ID = new ResourceLocation("grind_item");
@Override
public ResourceLocation getId() {
return ID;
}
@Override
public GrindedItem.Instance createInstance(JsonObject json, EntityPredicate.Composite predicate, DeserializationContext p_230241_3_) {
ItemPredicate itempredicate = ItemPredicate.fromJson(json.get("item"));
return new GrindedItem.Instance(predicate, itempredicate);
}
public void trigger(ServerPlayer Player, ItemStack stack) {
this.trigger(Player, (instance) -> instance.matches(stack));
}
public static class Instance extends AbstractCriterionTriggerInstance implements CriterionTriggerInstance {
private final ItemPredicate item;
public Instance(EntityPredicate.Composite p_i231585_1_, ItemPredicate item) {
super();
serializeToJson(GrindedItem.ID, p_i231585_1_);
this.item = item;
}
private void serializeToJson( ResourceLocation id, EntityPredicate.Composite p_i231585_1_ ) {
}
public boolean matches(ItemStack stack) {
return this.item.matches(stack);
}
@Override
public ResourceLocation getCriterion() {
return null;
}
@Override
public JsonObject serializeToJson(SerializationContext serializer) {
JsonObject jsonobject = super.serializeToJson(serializer);
jsonobject.add("item", this.item.serializeToJson());
return jsonobject;
}
}
}
}