1.1.17
All checks were successful
SorceryCraft/pipeline/head This commit looks good

Update Mappings
Add Spell-related Advancements
This commit is contained in:
TheBrokenRail 2020-03-17 20:42:02 -04:00
parent 1dbbd55376
commit 1c033d5a0d
17 changed files with 233 additions and 13 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
**1.1.17**
* Update Mappings
* Add Spell-related Advancements
**1.1.16** **1.1.16**
* Consistent Gradle Project Name * Consistent Gradle Project Name

View File

@ -6,11 +6,11 @@ org.gradle.jvmargs = -Xmx1G
minecraft_version = 20w11a minecraft_version = 20w11a
curseforge_id = 365308 curseforge_id = 365308
simple_minecraft_version = 1.16-Snapshot simple_minecraft_version = 1.16-Snapshot
yarn_mappings = 20w11a+build.11 yarn_mappings = 20w11a+build.17
fabric_loader_version = 0.7.8+build.187 fabric_loader_version = 0.7.8+build.187
# Mod Properties # Mod Properties
mod_version = 1.1.16 mod_version = 1.1.17
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
archives_base_name = sorcerycraft archives_base_name = sorcerycraft

View File

@ -1,5 +1,7 @@
package com.thebrokenrail.sorcerycraft; package com.thebrokenrail.sorcerycraft;
import com.thebrokenrail.sorcerycraft.advancement.CreateSpellCriterion;
import com.thebrokenrail.sorcerycraft.advancement.DiscoverAllSpellsCriterion;
import com.thebrokenrail.sorcerycraft.block.CastingTableBlock; import com.thebrokenrail.sorcerycraft.block.CastingTableBlock;
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler; import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
import com.thebrokenrail.sorcerycraft.client.gui.CastingTableScreen; import com.thebrokenrail.sorcerycraft.client.gui.CastingTableScreen;
@ -7,6 +9,7 @@ import com.thebrokenrail.sorcerycraft.client.entity.SpellEntityRenderer;
import com.thebrokenrail.sorcerycraft.command.SpellCommand; import com.thebrokenrail.sorcerycraft.command.SpellCommand;
import com.thebrokenrail.sorcerycraft.entity.SpellEntity; import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
import com.thebrokenrail.sorcerycraft.item.SpellItem; import com.thebrokenrail.sorcerycraft.item.SpellItem;
import com.thebrokenrail.sorcerycraft.mixin.CriterionRegistryHook;
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket; import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket; import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket;
import com.thebrokenrail.sorcerycraft.spell.util.RandomSpellLootTableFunction; import com.thebrokenrail.sorcerycraft.spell.util.RandomSpellLootTableFunction;
@ -62,11 +65,16 @@ import java.util.Objects;
public class SorceryCraft implements ModInitializer, ClientModInitializer { public class SorceryCraft implements ModInitializer, ClientModInitializer {
public static final String NAMESPACE = "sorcerycraft"; public static final String NAMESPACE = "sorcerycraft";
public static SpellItem SPELL_ITEM; public static SpellItem SPELL_ITEM;
public static CastingTableBlock CASTING_TABLE_BLOCK; public static CastingTableBlock CASTING_TABLE_BLOCK;
public static BlockItem CASTING_TABLE_BLOCK_ITEM; public static BlockItem CASTING_TABLE_BLOCK_ITEM;
public static ItemGroup ITEM_GROUP; public static ItemGroup ITEM_GROUP;
public static EntityType<SpellEntity> SPELL_ENTITY; public static EntityType<SpellEntity> SPELL_ENTITY;
public static final Identifier[] LOOT_TABLES = new Identifier[]{ public static final Identifier[] LOOT_TABLES = new Identifier[]{
LootTables.SIMPLE_DUNGEON_CHEST, LootTables.SIMPLE_DUNGEON_CHEST,
LootTables.END_CITY_TREASURE_CHEST, LootTables.END_CITY_TREASURE_CHEST,
@ -79,8 +87,12 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
LootTables.PILLAGER_OUTPOST_CHEST, LootTables.PILLAGER_OUTPOST_CHEST,
LootTables.WOODLAND_MANSION_CHEST LootTables.WOODLAND_MANSION_CHEST
}; };
public static Identifier STAT_INTERACT_WITH_CASTING_TABLE;
public static Identifier STAT_CAST_SPELL; public static Identifier INTERACT_WITH_CASTING_TABLE_STAT;
public static Identifier CAST_SPELL_STAT;
public static DiscoverAllSpellsCriterion DISCOVER_ALL_SPELLS_CRITERION;
public static CreateSpellCriterion CREATE_SPELL_CRITERION;
public static ModConfig getConfig() { public static ModConfig getConfig() {
return AutoConfig.getConfigHolder(ModConfig.class).getConfig(); return AutoConfig.getConfigHolder(ModConfig.class).getConfig();
@ -158,8 +170,11 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
} }
}); });
STAT_INTERACT_WITH_CASTING_TABLE = registerStat("interact_with_casting_table"); INTERACT_WITH_CASTING_TABLE_STAT = registerStat("interact_with_casting_table");
STAT_CAST_SPELL = registerStat("cast_spell"); CAST_SPELL_STAT = registerStat("cast_spell");
DISCOVER_ALL_SPELLS_CRITERION = CriterionRegistryHook.callRegister(new DiscoverAllSpellsCriterion());
CREATE_SPELL_CRITERION = CriterionRegistryHook.callRegister(new CreateSpellCriterion());
} }
private Identifier registerStat(String name) { private Identifier registerStat(String name) {

View File

@ -0,0 +1,34 @@
package com.thebrokenrail.sorcerycraft.advancement;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.thebrokenrail.sorcerycraft.SorceryCraft;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
public class CreateSpellCriterion extends AbstractCriterion<CreateSpellCriterion.Conditions> {
private static final Identifier ID = new Identifier(SorceryCraft.NAMESPACE, "create_spell");
public CreateSpellCriterion() {
}
public Identifier getId() {
return ID;
}
public CreateSpellCriterion.Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
return new CreateSpellCriterion.Conditions();
}
public void trigger(ServerPlayerEntity player) {
test(player.getAdvancementTracker(), (conditions) -> true);
}
public static class Conditions extends AbstractCriterionConditions {
public Conditions() {
super(ID);
}
}
}

View File

@ -0,0 +1,51 @@
package com.thebrokenrail.sorcerycraft.advancement;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.thebrokenrail.sorcerycraft.SorceryCraft;
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import java.util.Map;
public class DiscoverAllSpellsCriterion extends AbstractCriterion<DiscoverAllSpellsCriterion.Conditions> {
private static final Identifier ID = new Identifier(SorceryCraft.NAMESPACE, "discover_all_spells");
public DiscoverAllSpellsCriterion() {
}
public Identifier getId() {
return ID;
}
public DiscoverAllSpellsCriterion.Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
return new DiscoverAllSpellsCriterion.Conditions();
}
public void trigger(ServerPlayerEntity player) {
test(player.getAdvancementTracker(), (conditions) -> {
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
Map<Identifier, Integer> spells = spellPlayer.getDiscoveredSpells();
Spell[] maxSpells = SpellRegistry.getMaxSpells();
boolean match = true;
for (Spell spell : maxSpells) {
if (!spells.containsKey(spell.getID()) || spells.get(spell.getID()) < (spell.getLevel() - 1)) {
match = false;
break;
}
}
return match;
});
}
public static class Conditions extends AbstractCriterionConditions {
public Conditions() {
super(ID);
}
}
}

View File

@ -29,7 +29,7 @@ public class CastingTableBlock extends Block {
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient()) { if (!world.isClient()) {
ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), player, (buf) -> buf.writeBlockPos(pos)); ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(SorceryCraft.NAMESPACE, "casting_table"), player, (buf) -> buf.writeBlockPos(pos));
player.incrementStat(SorceryCraft.STAT_INTERACT_WITH_CASTING_TABLE); player.incrementStat(SorceryCraft.INTERACT_WITH_CASTING_TABLE_STAT);
} }
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }

View File

@ -15,6 +15,7 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -97,7 +98,12 @@ public class CastingTableScreenHandler extends ScreenHandler {
player.addExperienceLevels(-spells[index].getXPCost()); player.addExperienceLevels(-spells[index].getXPCost());
} }
context.run((BiConsumer<World, BlockPos>) SorceryCraft::playSpellSound); context.run((world, blockPos) -> {
SorceryCraft.playSpellSound(world, blockPos);
if (!world.isClient()) {
SorceryCraft.CREATE_SPELL_CRITERION.trigger((ServerPlayerEntity) player);
}
});
CastingTableScreenHandler.this.inventory.setInvStack(0, ItemStack.EMPTY); CastingTableScreenHandler.this.inventory.setInvStack(0, ItemStack.EMPTY);
CastingTableScreenHandler.this.inventory.takeInvStack(1, spells[index].getItemCost().getCount()); CastingTableScreenHandler.this.inventory.takeInvStack(1, spells[index].getItemCost().getCount());

View File

@ -13,11 +13,11 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity; import net.minecraft.util.Rarity;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.HashMap; import java.util.HashMap;
@ -36,7 +36,7 @@ public class SpellItem extends Item {
if (!world.isClient()) { if (!world.isClient()) {
SorceryCraft.playSpellSound(playerEntity); SorceryCraft.playSpellSound(playerEntity);
playerEntity.incrementStat(SorceryCraft.STAT_CAST_SPELL); playerEntity.incrementStat(SorceryCraft.CAST_SPELL_STAT);
SpellEntity entity = new SpellEntity(world, playerEntity); SpellEntity entity = new SpellEntity(world, playerEntity);
entity.setItem(itemStack); entity.setItem(itemStack);

View File

@ -0,0 +1,15 @@
package com.thebrokenrail.sorcerycraft.mixin;
import net.minecraft.advancement.criterion.Criterion;
import net.minecraft.advancement.criterion.Criterions;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@SuppressWarnings("PublicStaticMixinMember")
@Mixin(Criterions.class)
public interface CriterionRegistryHook {
@Invoker("register")
static <T extends Criterion<?>> T callRegister(T criterion) {
return criterion;
}
}

View File

@ -5,10 +5,10 @@ import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.network.PacketContext; import net.fabricmc.fabric.api.network.PacketContext;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket; import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
public class SelectSpellC2SPacket { public class SelectSpellC2SPacket {
public static void handle(PacketContext context, PacketByteBuf bytes) { public static void handle(PacketContext context, PacketByteBuf bytes) {

View File

@ -6,10 +6,10 @@ import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.network.PacketContext; import net.fabricmc.fabric.api.network.PacketContext;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
public class UpdateKnownSpellsS2CPacket { public class UpdateKnownSpellsS2CPacket {
public static void handle(PacketContext context, PacketByteBuf bytes) { public static void handle(PacketContext context, PacketByteBuf bytes) {

View File

@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
@ -124,6 +125,7 @@ public class SpellTag {
if (changed) { if (changed) {
SorceryCraft.playSpellSound(player); SorceryCraft.playSpellSound(player);
spellPlayer.setDiscoveredSpells(playerSpells); spellPlayer.setDiscoveredSpells(playerSpells);
SorceryCraft.DISCOVER_ALL_SPELLS_CRITERION.trigger((ServerPlayerEntity) player);
} }
} }
} }

View File

@ -19,6 +19,12 @@
"text.autoconfig.sorcerycraft.option.limitCastingTable": "Limit Casting Table To Discovered Spells", "text.autoconfig.sorcerycraft.option.limitCastingTable": "Limit Casting Table To Discovered Spells",
"text.autoconfig.sorcerycraft.option.limitCastingTable.creative": "Creative Mode", "text.autoconfig.sorcerycraft.option.limitCastingTable.creative": "Creative Mode",
"text.autoconfig.sorcerycraft.option.limitCastingTable.survival": "Survival Mode", "text.autoconfig.sorcerycraft.option.limitCastingTable.survival": "Survival Mode",
"advancements.sorcerycraft.adventure.discover_spell.title": "Witchcraft!",
"advancements.sorcerycraft.adventure.discover_spell.description": "Discover a spell",
"advancements.sorcerycraft.adventure.create_spell.title": "Spellbinding!",
"advancements.sorcerycraft.adventure.create_spell.description": "Cast a spell using a Casting Table",
"advancements.sorcerycraft.adventure.discover_all_spells.title": "Master of Magic!",
"advancements.sorcerycraft.adventure.discover_all_spells.description": "Discover all spells",
"spell.sorcerycraft.damage_spell": "Damage", "spell.sorcerycraft.damage_spell": "Damage",
"spell.sorcerycraft.heal_spell": "Heal", "spell.sorcerycraft.heal_spell": "Heal",
"spell.sorcerycraft.dissolve_spell": "Dissolve", "spell.sorcerycraft.dissolve_spell": "Dissolve",

View File

@ -0,0 +1,23 @@
{
"parent": "sorcerycraft:adventure/discover_spell",
"display": {
"icon": {
"item": "sorcerycraft:casting_table"
},
"title": {
"translate": "advancements.sorcerycraft.adventure.create_spell.title"
},
"description": {
"translate": "advancements.sorcerycraft.adventure.create_spell.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"sorcerycraft:casting_table": {
"trigger": "sorcerycraft:create_spell"
}
}
}

View File

@ -0,0 +1,27 @@
{
"parent": "sorcerycraft:adventure/create_spell",
"display": {
"icon": {
"item": "sorcerycraft:spell",
"nbt": "{Spells: [{id: \"sorcerycraft:damage_spell\", level: 0}]}"
},
"title": {
"translate": "advancements.sorcerycraft.adventure.discover_all_spells.title"
},
"description": {
"translate": "advancements.sorcerycraft.adventure.discover_all_spells.description"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"sorcerycraft:spell": {
"trigger": "sorcerycraft:discover_all_spells"
}
},
"rewards": {
"experience": 100
}
}

View File

@ -0,0 +1,36 @@
{
"parent": "minecraft:adventure/root",
"display": {
"icon": {
"item": "sorcerycraft:spell"
},
"title": {
"translate": "advancements.sorcerycraft.adventure.discover_spell.title"
},
"description": {
"translate": "advancements.sorcerycraft.adventure.discover_spell.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"sorcerycraft:spell": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "sorcerycraft:spell"
}
]
}
}
},
"rewards": {
"recipes": [
"sorcerycraft:spell",
"sorcerycraft:casting_table"
]
}
}

View File

@ -7,7 +7,8 @@
], ],
"mixins": [ "mixins": [
"MixinPlayerEntity", "MixinPlayerEntity",
"MixinServerPlayerEntity" "MixinServerPlayerEntity",
"CriterionRegistryHook"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1