-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60f7eb5
commit 6191d26
Showing
332 changed files
with
2,985 additions
and
1,491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,8 @@ bin/ | |
# fabric | ||
|
||
run/ | ||
|
||
# minecraft | ||
|
||
generated/ | ||
logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/campanion/advancement/criterion/CountCriterion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.campanion.advancement.criterion; | ||
|
||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import net.minecraft.advancement.criterion.AbstractCriterion; | ||
import net.minecraft.advancement.criterion.AbstractCriterionConditions; | ||
import net.minecraft.predicate.NumberRange; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class CountCriterion extends AbstractCriterion<CountCriterion.Conditions> { | ||
public final Identifier id; | ||
|
||
public CountCriterion(Identifier id) { | ||
this.id = id; | ||
} | ||
|
||
public Identifier getId() { | ||
return id; | ||
} | ||
|
||
public CountCriterion.Conditions conditionsFromJson(JsonObject json, JsonDeserializationContext context) { | ||
NumberRange.IntRange count = NumberRange.IntRange.fromJson(json.get("count")); | ||
return new CountCriterion.Conditions(id, count); | ||
} | ||
|
||
public void trigger(ServerPlayerEntity player, int count) { | ||
this.test(player.getAdvancementTracker(), (conditions) -> conditions.matches(count)); | ||
} | ||
|
||
public static class Conditions extends AbstractCriterionConditions { | ||
private final NumberRange.IntRange count; | ||
|
||
public Conditions(Identifier id, NumberRange.IntRange count) { | ||
super(id); | ||
this.count = count; | ||
} | ||
|
||
public static CountCriterion.Conditions create(Identifier id, NumberRange.IntRange count) { | ||
return new CountCriterion.Conditions(id, count); | ||
} | ||
|
||
public boolean matches(int count) { | ||
return this.count.test(count); | ||
} | ||
|
||
public JsonElement toJson() { | ||
JsonObject json = new JsonObject(); | ||
json.add("count", this.count.toJson()); | ||
return json; | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/campanion/advancement/criterion/KilledWithStoneCriterion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.campanion.advancement.criterion; | ||
|
||
import com.campanion.Campanion; | ||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import net.minecraft.advancement.criterion.AbstractCriterion; | ||
import net.minecraft.advancement.criterion.AbstractCriterionConditions; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.predicate.NumberRange; | ||
import net.minecraft.predicate.entity.EntityPredicate; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class KilledWithStoneCriterion extends AbstractCriterion<KilledWithStoneCriterion.Conditions> { | ||
public static final Identifier ID = new Identifier(Campanion.MOD_ID, "killed_with_stone"); | ||
|
||
public Identifier getId() { | ||
return ID; | ||
} | ||
|
||
public KilledWithStoneCriterion.Conditions conditionsFromJson(JsonObject json, JsonDeserializationContext context) { | ||
return new KilledWithStoneCriterion.Conditions(EntityPredicate.fromJson(json.get("entity")), NumberRange.IntRange.fromJson(json.get("skips"))); | ||
} | ||
|
||
public void trigger(ServerPlayerEntity player, Entity entity, int count) { | ||
this.test(player.getAdvancementTracker(), (conditions) -> conditions.matches(player, entity, count)); | ||
} | ||
|
||
public static class Conditions extends AbstractCriterionConditions { | ||
private final EntityPredicate entity; | ||
private final NumberRange.IntRange skips; | ||
|
||
public Conditions(EntityPredicate entity, NumberRange.IntRange skips) { | ||
super(KilledWithStoneCriterion.ID); | ||
this.entity = entity; | ||
this.skips = skips; | ||
} | ||
|
||
public static KilledWithStoneCriterion.Conditions create(EntityPredicate entity, NumberRange.IntRange count) { | ||
return new KilledWithStoneCriterion.Conditions(entity, count); | ||
} | ||
|
||
public boolean matches(ServerPlayerEntity player, Entity entity, int count) { | ||
return this.skips.test(count) && this.entity.test(player, entity); | ||
} | ||
|
||
public JsonElement toJson() { | ||
JsonObject json = new JsonObject(); | ||
json.add("entity", this.entity.serialize()); | ||
json.add("skips", this.skips.toJson()); | ||
return json; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.