diff --git a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java index fd76818f..e45190fb 100644 --- a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java +++ b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java @@ -1,11 +1,28 @@ package WayofTime.bloodmagic.core; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.IBMBlock; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.item.*; +import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid; +import WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.item.armour.ItemSentientArmour; +import WayofTime.bloodmagic.item.gear.ItemPackSacrifice; +import WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice; +import WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter; +import WayofTime.bloodmagic.item.routing.ItemNodeRouter; +import WayofTime.bloodmagic.item.routing.ItemRouterFilter; +import WayofTime.bloodmagic.item.sigil.*; +import WayofTime.bloodmagic.item.soul.*; +import WayofTime.bloodmagic.item.soulBreath.ItemFlightScroll; +import WayofTime.bloodmagic.item.types.ComponentTypes; +import WayofTime.bloodmagic.item.types.ShardType; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; - -import java.util.List; -import java.util.Set; - import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; @@ -20,81 +37,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.IBMBlock; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.item.ItemActivationCrystal; -import WayofTime.bloodmagic.item.ItemAlchemicVial; -import WayofTime.bloodmagic.item.ItemAltarMaker; -import WayofTime.bloodmagic.item.ItemArcaneAshes; -import WayofTime.bloodmagic.item.ItemBloodOrb; -import WayofTime.bloodmagic.item.ItemBoundAxe; -import WayofTime.bloodmagic.item.ItemBoundPickaxe; -import WayofTime.bloodmagic.item.ItemBoundShovel; -import WayofTime.bloodmagic.item.ItemBoundSword; -import WayofTime.bloodmagic.item.ItemDaggerOfSacrifice; -import WayofTime.bloodmagic.item.ItemDemonCrystal; -import WayofTime.bloodmagic.item.ItemDemonWillGauge; -import WayofTime.bloodmagic.item.ItemEnum; -import WayofTime.bloodmagic.item.ItemExperienceBook; -import WayofTime.bloodmagic.item.ItemInscriptionTool; -import WayofTime.bloodmagic.item.ItemLavaCrystal; -import WayofTime.bloodmagic.item.ItemPotionFlask; -import WayofTime.bloodmagic.item.ItemRitualDiviner; -import WayofTime.bloodmagic.item.ItemRitualReader; -import WayofTime.bloodmagic.item.ItemSacrificialDagger; -import WayofTime.bloodmagic.item.ItemSanguineBook; -import WayofTime.bloodmagic.item.ItemSlate; -import WayofTime.bloodmagic.item.ItemTelepositionFocus; -import WayofTime.bloodmagic.item.ItemUpgradeTome; -import WayofTime.bloodmagic.item.ItemUpgradeTrainer; -import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid; -import WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.item.armour.ItemSentientArmour; -import WayofTime.bloodmagic.item.gear.ItemPackSacrifice; -import WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice; -import WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter; -import WayofTime.bloodmagic.item.routing.ItemNodeRouter; -import WayofTime.bloodmagic.item.routing.ItemRouterFilter; -import WayofTime.bloodmagic.item.sigil.ItemSigilAir; -import WayofTime.bloodmagic.item.sigil.ItemSigilBloodLight; -import WayofTime.bloodmagic.item.sigil.ItemSigilBounce; -import WayofTime.bloodmagic.item.sigil.ItemSigilClaw; -import WayofTime.bloodmagic.item.sigil.ItemSigilCompression; -import WayofTime.bloodmagic.item.sigil.ItemSigilDivination; -import WayofTime.bloodmagic.item.sigil.ItemSigilElementalAffinity; -import WayofTime.bloodmagic.item.sigil.ItemSigilEnderSeverance; -import WayofTime.bloodmagic.item.sigil.ItemSigilFastMiner; -import WayofTime.bloodmagic.item.sigil.ItemSigilFrost; -import WayofTime.bloodmagic.item.sigil.ItemSigilGreenGrove; -import WayofTime.bloodmagic.item.sigil.ItemSigilHaste; -import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; -import WayofTime.bloodmagic.item.sigil.ItemSigilLava; -import WayofTime.bloodmagic.item.sigil.ItemSigilMagnetism; -import WayofTime.bloodmagic.item.sigil.ItemSigilPhantomBridge; -import WayofTime.bloodmagic.item.sigil.ItemSigilSuppression; -import WayofTime.bloodmagic.item.sigil.ItemSigilTeleposition; -import WayofTime.bloodmagic.item.sigil.ItemSigilTransposition; -import WayofTime.bloodmagic.item.sigil.ItemSigilVoid; -import WayofTime.bloodmagic.item.sigil.ItemSigilWater; -import WayofTime.bloodmagic.item.sigil.ItemSigilWhirlwind; -import WayofTime.bloodmagic.item.soul.ItemMonsterSoul; -import WayofTime.bloodmagic.item.soul.ItemSentientArmourGem; -import WayofTime.bloodmagic.item.soul.ItemSentientAxe; -import WayofTime.bloodmagic.item.soul.ItemSentientBow; -import WayofTime.bloodmagic.item.soul.ItemSentientPickaxe; -import WayofTime.bloodmagic.item.soul.ItemSentientShovel; -import WayofTime.bloodmagic.item.soul.ItemSentientSword; -import WayofTime.bloodmagic.item.soul.ItemSoulGem; -import WayofTime.bloodmagic.item.soul.ItemSoulSnare; -import WayofTime.bloodmagic.item.soulBreath.ItemFlightScroll; -import WayofTime.bloodmagic.item.types.ComponentTypes; -import WayofTime.bloodmagic.item.types.ShardType; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; +import java.util.List; +import java.util.Set; @Mod.EventBusSubscriber(modid = BloodMagic.MODID) @GameRegistry.ObjectHolder(BloodMagic.MODID) @@ -111,6 +56,7 @@ public class RegistrarBloodMagicItems public static final Item PACK_SACRIFICE = Items.AIR; public static final Item DAGGER_OF_SACRIFICE = Items.AIR; public static final Item RITUAL_DIVINER = Items.AIR; + public static final Item RITUAL_DISMANTLER = Items.AIR; public static final Item RITUAL_READER = Items.AIR; public static final Item LAVA_CRYSTAL = Items.AIR; public static final Item BOUND_SWORD = Items.AIR; @@ -203,6 +149,7 @@ public class RegistrarBloodMagicItems new ItemPackSelfSacrifice().setRegistryName("pack_self_sacrifice"), new ItemDaggerOfSacrifice().setRegistryName("dagger_of_sacrifice"), new ItemRitualDiviner().setRegistryName("ritual_diviner"), + new ItemRitualDismantler().setRegistryName("ritual_dismantler"), new ItemRitualReader().setRegistryName("ritual_reader"), new ItemLavaCrystal().setRegistryName("lava_crystal"), new ItemBoundSword().setRegistryName("bound_sword"), diff --git a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicRecipes.java b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicRecipes.java index cbb2c54a..05f40732 100644 --- a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicRecipes.java +++ b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicRecipes.java @@ -213,6 +213,7 @@ public class RegistrarBloodMagicRecipes registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_PYLON), 400, 50, "blockIron", "stone", "gemLapis", RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL); registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTALLIZER), 500, 100, RegistrarBloodMagicBlocks.SOUL_FORGE, "stone", "gemLapis", "blockGlass"); registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.DEMON_WILL_GAUGE), 400, 50, "ingotGold", "dustRedstone", "blockGlass", RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL); + registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.RITUAL_DISMANTLER), 500, 100, new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, 2), new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, 2), new ItemStack(RegistrarBloodMagicItems.RITUAL_DIVINER), new ItemStack(RegistrarBloodMagicItems.BLOOD_SHARD)); } public static void registerAlchemyArrayRecipes(BloodMagicRecipeRegistrar registrar) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDismantler.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDismantler.java new file mode 100644 index 00000000..744b7129 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDismantler.java @@ -0,0 +1,78 @@ +package WayofTime.bloodmagic.item; + +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.BlockRitualStone; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.core.data.SoulTicket; +import WayofTime.bloodmagic.ritual.Ritual; +import WayofTime.bloodmagic.ritual.RitualComponent; +import WayofTime.bloodmagic.tile.TileMasterRitualStone; +import WayofTime.bloodmagic.util.helper.NetworkHelper; +import WayofTime.bloodmagic.util.helper.RitualHelper; +import com.google.common.collect.Lists; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.items.ItemHandlerHelper; + +import java.util.List; + +public class ItemRitualDismantler extends Item implements IVariantProvider { + public ItemRitualDismantler() { + setUnlocalizedName(BloodMagic.MODID + ".ritualDismantler"); + setCreativeTab(BloodMagic.TAB_BM); + setMaxStackSize(1); + } + + @Override + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + Block block = world.getBlockState(pos).getBlock(); + TileEntity tileEntity = world.getTileEntity(pos); + ItemStack stack = player.getHeldItem(hand); + + if (tileEntity instanceof TileMasterRitualStone) { + TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tileEntity; + EnumFacing direction = masterRitualStone.getDirection(); + + String ritualName = RitualHelper.getValidRitual(world, pos); + masterRitualStone.setActive(false); + + if (ritualName.equals("")) { + world.setBlockToAir(pos); + ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(RegistrarBloodMagicBlocks.RITUAL_CONTROLLER)); + NetworkHelper.getSoulNetwork(player).syphon(SoulTicket.item(stack, 100)); + return EnumActionResult.SUCCESS; + } + + Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(ritualName); + List components = Lists.newArrayList(); + ritual.gatherComponents(components::add); + for (RitualComponent component : components) { + BlockPos newPos = pos.add(component.getOffset(direction)); + if (world.getBlockState(newPos).getBlock() instanceof BlockRitualStone) { + world.setBlockToAir(newPos); + ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(RegistrarBloodMagicBlocks.RITUAL_STONE)); + } + } + + NetworkHelper.getSoulNetwork(player).syphon(SoulTicket.item(stack, 200)); // smallest Ritual has 4 stones + return EnumActionResult.SUCCESS; + + } else if (player.isSneaking() && block instanceof BlockRitualStone) { + block.removedByPlayer(world.getBlockState(pos), world, pos, player, false); + ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(RegistrarBloodMagicBlocks.RITUAL_STONE)); + NetworkHelper.getSoulNetwork(player).syphon(SoulTicket.item(stack, 50)); + return EnumActionResult.SUCCESS; + } + + return EnumActionResult.FAIL; + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index 03702e15..0fcd5be5 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -152,6 +152,7 @@ item.bloodmagic.sentientArmour.boots.name=Sentient Boots item.bloodmagic.altarMaker.name=Altar Maker +item.bloodmagic.ritualDismantler.name=Ritual Dismantler item.bloodmagic.ritualDivinernormal.name=Ritual Diviner item.bloodmagic.ritualDivinerdusk.name=Ritual Diviner [Dusk] item.bloodmagic.ritualDivinerdawn.name=Ritual Diviner [Dawn] diff --git a/src/main/resources/assets/bloodmagic/models/item/ritual_dismantler.json b/src/main/resources/assets/bloodmagic/models/item/ritual_dismantler.json new file mode 100644 index 00000000..dc88c182 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/ritual_dismantler.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bloodmagic:items/ritual_dismantler" + } +} \ No newline at end of file