From 4bc4821543bb04f93fb7d47ffa53636329a577d4 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 13 Mar 2020 18:05:12 -0400 Subject: [PATCH] 1.1.11 Update Mappings Add Lightning Spell --- CHANGELOG.md | 4 ++ README.md | 1 + gradle.properties | 4 +- .../sorcerycraft/SorceryCraft.java | 6 +-- .../sorcerycraft/block/CastingTableBlock.java | 9 ++-- .../{block => gui}/CastingTableScreen.java | 8 +-- .../CastingTableScreenHandler.java | 8 +-- .../packet/SelectSpellC2SPacket.java | 2 +- .../sorcerycraft/spell/CoolingSpell.java | 2 +- .../sorcerycraft/spell/DamageSpell.java | 4 +- .../sorcerycraft/spell/DissolveSpell.java | 2 +- .../sorcerycraft/spell/FlameSpell.java | 2 +- .../sorcerycraft/spell/HealSpell.java | 4 +- .../sorcerycraft/spell/LevitateSpell.java | 2 +- .../sorcerycraft/spell/LightningSpell.java | 53 +++++++++++++++++++ .../sorcerycraft/spell/registry/Spells.java | 3 ++ .../assets/sorcerycraft/lang/en_us.json | 3 +- 17 files changed, 90 insertions(+), 27 deletions(-) rename src/main/java/com/thebrokenrail/sorcerycraft/client/{block => gui}/CastingTableScreen.java (96%) rename src/main/java/com/thebrokenrail/sorcerycraft/{block => gui}/CastingTableScreenHandler.java (97%) create mode 100644 src/main/java/com/thebrokenrail/sorcerycraft/spell/LightningSpell.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d9abb38..207fc39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### Changelog +**1.1.11** +* Update Mappings +* Add Lightning Spell + **1.1.10** * Update to 20w11a * Enhance Flame Spell diff --git a/README.md b/README.md index 8adbce0..a7c4e33 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ You can apply Spells to blank or existing Spells in the Casting Table. Doing so | Teleport | 2 | Teleports target to random location. | | Inward | 1 | Causes the Spell to target the caster. If the Spell fails instead of rebounding, it will just do nothing. This does nothing on its own. | | Cooling | 1 | Extinguish the target if they are on fire. | +| Lightning | 1 | Strikes the target with lightning. | ## ```/spell``` Command This command requires OP permissions. diff --git a/gradle.properties b/gradle.properties index b0fecfe..ee22620 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,11 +6,11 @@ org.gradle.jvmargs = -Xmx1G minecraft_version = 20w11a curseforge_id = 365308 simple_minecraft_version = 1.16-Snapshot - yarn_mappings = 20w11a+build.1 + yarn_mappings = 20w11a+build.6 loader_version = 0.7.8+build.187 # Mod Properties - mod_version = 1.1.10 + mod_version = 1.1.11 maven_group = com.thebrokenrail archives_base_name = sorcerycraft diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java b/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java index 9d4f674..0da73cc 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/SorceryCraft.java @@ -1,8 +1,8 @@ package com.thebrokenrail.sorcerycraft; import com.thebrokenrail.sorcerycraft.block.CastingTableBlock; -import com.thebrokenrail.sorcerycraft.block.CastingTableScreenHandler; -import com.thebrokenrail.sorcerycraft.client.block.CastingTableScreen; +import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler; +import com.thebrokenrail.sorcerycraft.client.gui.CastingTableScreen; import com.thebrokenrail.sorcerycraft.client.entity.SpellEntityRenderer; import com.thebrokenrail.sorcerycraft.command.SpellCommand; import com.thebrokenrail.sorcerycraft.entity.SpellEntity; @@ -108,7 +108,7 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer { ContainerProviderRegistry.INSTANCE.registerFactory(new Identifier(NAMESPACE, "casting_table"), (syncId, identifier, player, buf) -> { final World world = player.world; final BlockPos pos = buf.readBlockPos(); - return Objects.requireNonNull(world.getBlockState(pos).createContainerFactory(player.world, pos)).createMenu(syncId, player.inventory, player); + return Objects.requireNonNull(world.getBlockState(pos).createScreenHandlerFactory(player.world, pos)).createMenu(syncId, player.inventory, player); }); CommandRegistry.INSTANCE.register(false, SpellCommand::register); diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java b/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java index e6bcc23..e1f96a7 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableBlock.java @@ -1,14 +1,15 @@ package com.thebrokenrail.sorcerycraft.block; import com.thebrokenrail.sorcerycraft.SorceryCraft; +import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler; import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.container.ContainerProviderRegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Material; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.screen.BlockContext; -import net.minecraft.screen.NameableScreenHandlerFactory; +import net.minecraft.screen.NamedScreenHandlerFactory; +import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.SimpleNamedScreenHandlerFactory; import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; @@ -34,7 +35,7 @@ public class CastingTableBlock extends Block { } @Override - public NameableScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) { - return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> new CastingTableScreenHandler(i, playerInventory, BlockContext.create(world, pos)), new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table")); + public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) { + return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> new CastingTableScreenHandler(i, playerInventory, ScreenHandlerContext.create(world, pos)), new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table")); } } diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/client/block/CastingTableScreen.java b/src/main/java/com/thebrokenrail/sorcerycraft/client/gui/CastingTableScreen.java similarity index 96% rename from src/main/java/com/thebrokenrail/sorcerycraft/client/block/CastingTableScreen.java rename to src/main/java/com/thebrokenrail/sorcerycraft/client/gui/CastingTableScreen.java index f5131b4..79edc41 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/client/block/CastingTableScreen.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/client/gui/CastingTableScreen.java @@ -1,15 +1,15 @@ -package com.thebrokenrail.sorcerycraft.client.block; +package com.thebrokenrail.sorcerycraft.client.gui; import com.mojang.blaze3d.systems.RenderSystem; import com.thebrokenrail.sorcerycraft.SorceryCraft; -import com.thebrokenrail.sorcerycraft.block.CastingTableScreenHandler; +import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler; import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket; import com.thebrokenrail.sorcerycraft.spell.api.Spell; import com.thebrokenrail.sorcerycraft.spell.util.SpellTag; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.screen.ingame.ScreenWithHandler; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; @@ -19,7 +19,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @Environment(EnvType.CLIENT) -public class CastingTableScreen extends ScreenWithHandler { +public class CastingTableScreen extends HandledScreen { private static final Identifier TEXTURE = new Identifier("textures/gui/container/villager2.png"); private int selectedIndex; private int indexStartOffset; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableScreenHandler.java b/src/main/java/com/thebrokenrail/sorcerycraft/gui/CastingTableScreenHandler.java similarity index 97% rename from src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableScreenHandler.java rename to src/main/java/com/thebrokenrail/sorcerycraft/gui/CastingTableScreenHandler.java index 85fb401..5f06437 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableScreenHandler.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/gui/CastingTableScreenHandler.java @@ -1,4 +1,4 @@ -package com.thebrokenrail.sorcerycraft.block; +package com.thebrokenrail.sorcerycraft.gui; import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.spell.api.Spell; @@ -11,8 +11,8 @@ import net.minecraft.inventory.BasicInventory; import net.minecraft.inventory.CraftingResultInventory; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; -import net.minecraft.screen.BlockContext; import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.slot.Slot; import net.minecraft.util.Identifier; @@ -28,10 +28,10 @@ public class CastingTableScreenHandler extends ScreenHandler { private final Inventory inventory; private final Inventory result; private final Spell[] spells; - private final BlockContext context; + private final ScreenHandlerContext context; private int index = 0; - public CastingTableScreenHandler(int syncId, PlayerInventory playerInventory, BlockContext blockContext) { + public CastingTableScreenHandler(int syncId, PlayerInventory playerInventory, ScreenHandlerContext blockContext) { super(ScreenHandlerType.STONECUTTER, syncId); inventory = new BasicInventory(2) { diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/packet/SelectSpellC2SPacket.java b/src/main/java/com/thebrokenrail/sorcerycraft/packet/SelectSpellC2SPacket.java index a57308c..7239dad 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/packet/SelectSpellC2SPacket.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/packet/SelectSpellC2SPacket.java @@ -1,7 +1,7 @@ package com.thebrokenrail.sorcerycraft.packet; import com.thebrokenrail.sorcerycraft.SorceryCraft; -import com.thebrokenrail.sorcerycraft.block.CastingTableScreenHandler; +import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler; import io.netty.buffer.Unpooled; import net.fabricmc.fabric.api.network.PacketContext; import net.minecraft.client.MinecraftClient; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java index 64be36d..835a142 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java @@ -35,7 +35,7 @@ public class CoolingSpell extends Spell { @Override public int getXPCost() { - return 13; + return 10; } @Override diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java index eb8a6f4..ea5e3d6 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java @@ -25,10 +25,10 @@ public class DamageSpell extends Spell { public int getXPCost() { switch (getLevel()) { case 0: { - return 5; + return 4; } case 1: { - return 10; + return 8; } } return -1; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java index 077cf24..88ab3b1 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java @@ -22,7 +22,7 @@ public class DissolveSpell extends Spell { @Override public int getXPCost() { - return 12; + return 8; } @Override diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java index cb6398d..a48e573 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java @@ -49,7 +49,7 @@ public class FlameSpell extends Spell { return 8; } case 1: { - return 16; + return 12; } } return -1; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java index feaf8f7..02e3018 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java @@ -25,10 +25,10 @@ public class HealSpell extends Spell { public int getXPCost() { switch (getLevel()) { case 0: { - return 5; + return 4; } case 1: { - return 10; + return 8; } } return -1; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java index e57782b..872ff42 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java @@ -29,7 +29,7 @@ public class LevitateSpell extends Spell { return 12; } case 1: { - return 21; + return 24; } } return -1; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/LightningSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/LightningSpell.java new file mode 100644 index 0000000..55bc7fd --- /dev/null +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/LightningSpell.java @@ -0,0 +1,53 @@ +package com.thebrokenrail.sorcerycraft.spell; + +import com.thebrokenrail.sorcerycraft.spell.api.Spell; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LightningEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.Identifier; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +public class LightningSpell extends Spell { + public LightningSpell(Identifier id, int level) { + super(id, level); + } + + @Override + public void execute(World world, Entity source, Entity attacker, Entity target) { + strike(world, target.getPos(), attacker); + } + + @Override + public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) { + strike(world, hitResult.getPos(), attacker); + } + + private void strike(World world, Vec3d pos, Entity attacker) { + ServerWorld serverWorld = (ServerWorld) world; + LightningEntity lightningEntity = new LightningEntity(world, pos.getX(), pos.getY(), pos.getZ(), false); + if (attacker instanceof ServerPlayerEntity) { + lightningEntity.setChanneller((ServerPlayerEntity) attacker); + } + serverWorld.addLightning(lightningEntity); + } + + @Override + public int getXPCost() { + return 18; + } + + @Override + public ItemStack getItemCost() { + return new ItemStack(Items.END_ROD); + } + + @Override + public int getMaxLevel() { + return 1; + } +} diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/Spells.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/Spells.java index ce3e7cc..9e9fae5 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/Spells.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/Spells.java @@ -8,6 +8,7 @@ import com.thebrokenrail.sorcerycraft.spell.FlameSpell; import com.thebrokenrail.sorcerycraft.spell.HealSpell; import com.thebrokenrail.sorcerycraft.spell.InwardSpell; import com.thebrokenrail.sorcerycraft.spell.LevitateSpell; +import com.thebrokenrail.sorcerycraft.spell.LightningSpell; import com.thebrokenrail.sorcerycraft.spell.SteadfastSpell; import com.thebrokenrail.sorcerycraft.spell.TeleportSpell; import net.minecraft.util.Identifier; @@ -23,6 +24,7 @@ public class Spells { public static final Identifier TELEPORT_SPELL; public static final Identifier INWARD_SPELL; public static final Identifier COOLING_SPELL; + public static final Identifier LIGHTNING_SPELL; static { HEAL_SPELL = SpellRegistry.register(new Identifier(SorceryCraft.NAMESPACE, "heal_spell"), HealSpell.class); @@ -34,5 +36,6 @@ public class Spells { TELEPORT_SPELL = SpellRegistry.register(new Identifier(SorceryCraft.NAMESPACE, "teleport_spell"), TeleportSpell.class); INWARD_SPELL = SpellRegistry.register(new Identifier(SorceryCraft.NAMESPACE, "inward_spell"), InwardSpell.class); COOLING_SPELL = SpellRegistry.register(new Identifier(SorceryCraft.NAMESPACE, "cooling_spell"), CoolingSpell.class); + LIGHTNING_SPELL = SpellRegistry.register(new Identifier(SorceryCraft.NAMESPACE, "lightning_spell"), LightningSpell.class); } } diff --git a/src/main/resources/assets/sorcerycraft/lang/en_us.json b/src/main/resources/assets/sorcerycraft/lang/en_us.json index b441b20..c418abd 100644 --- a/src/main/resources/assets/sorcerycraft/lang/en_us.json +++ b/src/main/resources/assets/sorcerycraft/lang/en_us.json @@ -22,5 +22,6 @@ "spell.sorcerycraft.levitate_spell": "Levitate", "spell.sorcerycraft.teleport_spell": "Teleport", "spell.sorcerycraft.inward_spell": "Inward", - "spell.sorcerycraft.cooling_spell": "Cooling" + "spell.sorcerycraft.cooling_spell": "Cooling", + "spell.sorcerycraft.lightning_spell": "Lightning" } \ No newline at end of file