use of mods.railcraft.common.advancements.criterion.MultiBlockFormedTrigger.Instance 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);
}
use of mods.railcraft.common.advancements.criterion.MultiBlockFormedTrigger.Instance in project Railcraft by Railcraft.
the class MultiBlockFormedTrigger method onMultiBlockForm.
@SubscribeEvent
public void onMultiBlockForm(MultiBlockEvent.Form event) {
TileRailcraft tile = event.getMaster();
GameProfile owner = tile.getOwner();
MinecraftServer server = requireNonNull(Game.getServer());
EntityPlayerMP player = server.getPlayerList().getPlayerByUUID(owner.getId());
if (player == null) {
// Offline
return;
}
PlayerAdvancements advancements = player.getAdvancements();
Collection<Listener<Instance>> done = manager.get(advancements).stream().filter(listener -> listener.getCriterionInstance().matches(tile)).collect(Collectors.toList());
for (Listener<Instance> listener : done) {
listener.grantCriterion(advancements);
}
}
Aggregations