Criterion and advancements stuff part 1
This commit is contained in:
parent
c699f46b75
commit
da67369796
5 changed files with 59 additions and 0 deletions
|
@ -47,6 +47,11 @@ public class AdvancementTab implements Consumer<Consumer<Advancement>> {
|
|||
.display(makeDisplay(ModItems.RIFT_BLADE, "root"))
|
||||
.criterion("inventory_changed", InventoryChangedCriterion.Conditions.items(Items.ENDER_PEARL))
|
||||
.build(advancementConsumer, "dimdoors:dimdoors/root");
|
||||
Advancement.Task.create()
|
||||
.display(makeDisplay(ModItems.WORLD_THREAD, "string_theory"))
|
||||
.criterion("inventory_changed", InventoryChangedCriterion.Conditions.items(ModItems.WORLD_THREAD))
|
||||
.parent(root)
|
||||
.build(advancementConsumer, "dimdoors:dimdoors/string_theory");
|
||||
|
||||
// Advancement.Task.create()
|
||||
// .display(makeDisplay(ModItems.IRON_DIMENSIONAL_DOOR, "public_pocket"))
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.dimdev.dimdoors.block.door.data.condition.Condition;
|
|||
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
|
||||
import org.dimdev.dimdoors.command.ModCommands;
|
||||
import org.dimdev.dimdoors.entity.ModEntityTypes;
|
||||
import org.dimdev.dimdoors.entity.advancement.ModCriteria;
|
||||
import org.dimdev.dimdoors.entity.stat.ModStats;
|
||||
import org.dimdev.dimdoors.api.event.UseItemOnBlockCallback;
|
||||
import org.dimdev.dimdoors.fluid.ModFluids;
|
||||
|
@ -121,6 +122,7 @@ public class DimensionalDoorsInitializer implements ModInitializer {
|
|||
ModFluids.init();
|
||||
ModSoundEvents.init();
|
||||
ModParticleTypes.init();
|
||||
ModCriteria.init();
|
||||
|
||||
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(PocketLoader.getInstance());
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("dimdoors", "default_pockets"), dimDoorsMod, ResourcePackActivationType.DEFAULT_ENABLED);
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dimdev.dimdoors.block.CoordinateTransformerBlock;
|
||||
import org.dimdev.dimdoors.entity.advancement.ModCriteria;
|
||||
import org.dimdev.dimdoors.rift.registry.LinkProperties;
|
||||
import org.dimdev.dimdoors.rift.registry.Rift;
|
||||
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
|
||||
|
@ -34,6 +35,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
|
||||
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
|
||||
|
||||
public abstract class RiftBlockEntity extends BlockEntity implements BlockEntityClientSerializable, Target, EntityTarget {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
@ -110,6 +112,12 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
|
|||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toInitialChunkDataNbt() {
|
||||
PlayerLookup.tracking(this).forEach(ModCriteria.RIFT_TRACKED::trigger);
|
||||
return super.toInitialChunkDataNbt();
|
||||
}
|
||||
|
||||
public void markStateChanged() {
|
||||
this.riftStateChanged = true;
|
||||
this.markDirty();
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package org.dimdev.dimdoors.entity.advancement;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.advancement.CriterionRegistry;
|
||||
|
||||
public class ModCriteria {
|
||||
public static final RiftTrackedCriterion RIFT_TRACKED = CriterionRegistry.register(new RiftTrackedCriterion());
|
||||
|
||||
public static void init() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package org.dimdev.dimdoors.entity.advancement;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class RiftTrackedCriterion extends AbstractCriterion<RiftTrackedCriterion.Conditions> {
|
||||
public static final Identifier ID = new Identifier("dimdoors", "rift_tracked");
|
||||
|
||||
@Override
|
||||
protected Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new Conditions(playerPredicate);
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
this.test(player, t -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions(EntityPredicate.Extended playerPredicate) {
|
||||
super(ID, playerPredicate);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue