diff --git a/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyTableRecipeProvider.java b/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyTableRecipeProvider.java index 233e2b07..2f71a351 100644 --- a/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyTableRecipeProvider.java +++ b/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyTableRecipeProvider.java @@ -50,7 +50,7 @@ public class AlchemyTableRecipeProvider implements ISubRecipeProvider AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.HOLY_WATER_ANOINTMENT.get()), 500, 100, 1).addIngredient(Ingredient.fromItems(BloodMagicItems.SLATE_VIAL.get())).addIngredient(Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART)).addIngredient(Ingredient.fromItems(Items.GLISTERING_MELON_SLICE)).addIngredient(Ingredient.fromTag(Tags.Items.GEMS_QUARTZ)).build(consumer, BloodMagic.rl(basePath + "holy_water_anointment")); AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.HIDDEN_KNOWLEDGE_ANOINTMENT.get()), 500, 100, 1).addIngredient(Ingredient.fromItems(BloodMagicItems.SLATE_VIAL.get())).addIngredient(Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART)).addIngredient(Ingredient.fromItems(Items.GLASS_BOTTLE)).addIngredient(Ingredient.fromItems(Items.ENCHANTED_BOOK)).build(consumer, BloodMagic.rl(basePath + "hidden_knowledge_anointment")); AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.QUICK_DRAW_ANOINTMENT.get()), 500, 100, 1).addIngredient(Ingredient.fromItems(BloodMagicItems.SLATE_VIAL.get())).addIngredient(Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART)).addIngredient(Ingredient.fromTag(Tags.Items.STRING)).addIngredient(Ingredient.fromItems(Items.SPECTRAL_ARROW)).build(consumer, BloodMagic.rl(basePath + "quick_draw_anointment")); - AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.LOOTING_ANOINTMENT.get()), 500, 100, 1).addIngredient(Ingredient.fromItems(BloodMagicItems.SLATE_VIAL.get())).addIngredient(Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART)).addIngredient(Ingredient.fromTag(Tags.Items.GEMS_LAPIS)).addIngredient(Ingredient.fromTag(Tags.Items.BONES)).build(consumer, BloodMagic.rl(basePath + "looting_anointment")); +// AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.LOOTING_ANOINTMENT.get()), 500, 100, 1).addIngredient(Ingredient.fromItems(BloodMagicItems.SLATE_VIAL.get())).addIngredient(Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART)).addIngredient(Ingredient.fromTag(Tags.Items.GEMS_LAPIS)).addIngredient(Ingredient.fromTag(Tags.Items.BONES)).build(consumer, BloodMagic.rl(basePath + "looting_anointment")); AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.BOW_POWER_ANOINTMENT.get()), 500, 100, 1).addIngredient(Ingredient.fromItems(BloodMagicItems.SLATE_VIAL.get())).addIngredient(Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART)).addIngredient(Ingredient.fromTag(Tags.Items.INGOTS_IRON)).addIngredient(Ingredient.fromItems(Items.BOW)).build(consumer, BloodMagic.rl(basePath + "bow_power_anointment")); AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.SMELTING_ANOINTMENT.get()), 500, 100, 1).addIngredient(Ingredient.fromItems(BloodMagicItems.SLATE_VIAL.get())).addIngredient(Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART)).addIngredient(Ingredient.fromItems(Items.FURNACE)).addIngredient(Ingredient.fromItems(Items.CHARCOAL, Items.COAL)).build(consumer, BloodMagic.rl(basePath + "smelting_anointment")); diff --git a/src/main/java/wayoftime/bloodmagic/loot/GlobalLootModifier.java b/src/main/java/wayoftime/bloodmagic/loot/GlobalLootModifier.java index 05a51fc9..d2762d38 100644 --- a/src/main/java/wayoftime/bloodmagic/loot/GlobalLootModifier.java +++ b/src/main/java/wayoftime/bloodmagic/loot/GlobalLootModifier.java @@ -166,43 +166,57 @@ public class GlobalLootModifier public List doApply(List generatedLoot, LootContext context) { // System.out.println("Checking for looting"); - ItemStack ctxTool = context.get(LootParameters.TOOL); - // return early if silk-touch is already applied (otherwise we'll get stuck in - // an infinite loop). - if (ctxTool.getTag() != null && ctxTool.getTag().getBoolean("bloodmagic:checked_looting")) - { - return generatedLoot; - } - - if (EnchantmentHelper.getEnchantments(ctxTool).containsKey(Enchantments.SILK_TOUCH)) - return generatedLoot; - AnointmentHolder holder = AnointmentHolder.fromItemStack(ctxTool); - if (holder == null) - { - return generatedLoot; - } - - int additionalLooting = holder.getAnointmentLevel(AnointmentRegistrar.ANOINTMENT_LOOTING.get()); - if (additionalLooting <= 0) - { - return generatedLoot; - } - -// if (holder.getAnointmentLevel(AnointmentRegistrar.ANOINTMENT_SILK_TOUCH.get()) > 0) +// Entity killerEntity = context.get(LootParameters.KILLER_ENTITY); +// if (!(killerEntity instanceof PlayerEntity)) +// { + return generatedLoot; +// } +// Entity killedEntity = context.get(LootParameters.THIS_ENTITY); +// if (!(killedEntity instanceof LivingEntity)) // { // return generatedLoot; // } - - ItemStack fakeTool = ctxTool.copy(); - fakeTool.getOrCreateTag().putBoolean("bloodmagic:checked_looting", true); - int baseLootingLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.LOOTING, ctxTool); - - fakeTool.addEnchantment(Enchantments.LOOTING, baseLootingLevel + additionalLooting); - LootContext.Builder builder = new LootContext.Builder(context); - builder.withParameter(LootParameters.TOOL, fakeTool); - LootContext ctx = builder.build(LootParameterSets.BLOCK); - LootTable loottable = context.getWorld().getServer().getLootTableManager().getLootTableFromLocation(context.get(LootParameters.BLOCK_STATE).getBlock().getLootTable()); - return loottable.generate(ctx); +// ItemStack ctxTool = ((PlayerEntity) killerEntity).getHeldItemMainhand(); +// // return early if silk-touch is already applied (otherwise we'll get stuck in +// // an infinite loop). +// +// System.out.println("Checking looting. ItemStack context: "); +//// EndermanEntity d; +// if (ctxTool.getTag() != null && ctxTool.getTag().getBoolean("bloodmagic:checked_looting")) +// { +// return generatedLoot; +// } +// +// if (EnchantmentHelper.getEnchantments(ctxTool).containsKey(Enchantments.SILK_TOUCH)) +// return generatedLoot; +// AnointmentHolder holder = AnointmentHolder.fromItemStack(ctxTool); +// if (holder == null) +// { +// return generatedLoot; +// } +// +// int additionalLooting = holder.getAnointmentLevel(AnointmentRegistrar.ANOINTMENT_LOOTING.get()) * 20; +// if (additionalLooting <= 0) +// { +// return generatedLoot; +// } +// +//// if (holder.getAnointmentLevel(AnointmentRegistrar.ANOINTMENT_SILK_TOUCH.get()) > 0) +//// { +//// return generatedLoot; +//// } +// +// ItemStack fakeTool = ctxTool.copy(); +// fakeTool.getOrCreateTag().putBoolean("bloodmagic:checked_looting", true); +// int baseLootingLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.LOOTING, ctxTool); +// +// fakeTool.addEnchantment(Enchantments.LOOTING, baseLootingLevel + additionalLooting); +// LootContext.Builder builder = new LootContext.Builder(context); +// builder.withParameter(LootParameters.TOOL, fakeTool); +// LootContext ctx = builder.build(LootParameterSets.ENTITY); +// ResourceLocation resource = ((LivingEntity) killedEntity).getLootTableResourceLocation(); +// LootTable loottable = context.getWorld().getServer().getLootTableManager().getLootTableFromLocation(resource); +// return loottable.generate(ctx); } private static class Serializer extends GlobalLootModifierSerializer @@ -219,6 +233,14 @@ public class GlobalLootModifier return makeConditions(instance.conditions); } } + +// private static class ExtendedLootContext extends LootContext +// { +// public ExtendedLootContext() +// { +// +// } +// } } private static class SmeltingModifier extends LootModifier diff --git a/src/main/resources/data/bloodmagic/loot_modifiers/looting.json b/src/main/resources/data/bloodmagic/loot_modifiers/looting.json index f98ee249..fe391f6f 100644 --- a/src/main/resources/data/bloodmagic/loot_modifiers/looting.json +++ b/src/main/resources/data/bloodmagic/loot_modifiers/looting.json @@ -2,7 +2,8 @@ "type": "bloodmagic:looting", "conditions": [ { - "condition": "minecraft:entity", + "condition": "minecraft:entity_properties", + "entity": "this", "predicate": { }