From 2de0ba95a6b9ff617f4cd77103c9ee6810994389 Mon Sep 17 00:00:00 2001 From: ProfessorProspector Date: Sun, 16 Oct 2016 20:48:47 -0700 Subject: [PATCH] Add ruby ore dropping garnets based on ore dict, not the ore itself. Closes #595 # Conflicts: # src/main/java/techreborn/Core.java --- src/main/java/techreborn/Core.java | 2 ++ src/main/java/techreborn/blocks/BlockOre.java | 2 +- .../techreborn/events/BlockBreakHandler.java | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/java/techreborn/events/BlockBreakHandler.java diff --git a/src/main/java/techreborn/Core.java b/src/main/java/techreborn/Core.java index 1589fd4cf..14448b321 100644 --- a/src/main/java/techreborn/Core.java +++ b/src/main/java/techreborn/Core.java @@ -33,6 +33,7 @@ import techreborn.compat.ICompatModule; import techreborn.config.ConfigTechReborn; import techreborn.dispenser.BehaviorDispenseScrapbox; import techreborn.entitys.EntityNukePrimed; +import techreborn.events.BlockBreakHandler; import techreborn.events.OreUnifier; import techreborn.events.TRTickHandler; import techreborn.init.*; @@ -127,6 +128,7 @@ public class Core { compatModule.init(event); } MinecraftForge.EVENT_BUS.register(new StackWIPHandler()); + MinecraftForge.EVENT_BUS.register(new BlockBreakHandler()); //Ore Dictionary OreDict.init(); diff --git a/src/main/java/techreborn/blocks/BlockOre.java b/src/main/java/techreborn/blocks/BlockOre.java index 07dc3b1c0..ca3618060 100644 --- a/src/main/java/techreborn/blocks/BlockOre.java +++ b/src/main/java/techreborn/blocks/BlockOre.java @@ -91,7 +91,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby"), ConfigTechReborn.FortuneSecondaryOreMultiplierPerLevel); OreDrop redGarnet = new OreDrop(ItemGems.getGemByName("redGarnet"), 0.02); - OreDropSet set = new OreDropSet(ruby, redGarnet); + OreDropSet set = new OreDropSet(ruby); return set.drop(fortune, random); } diff --git a/src/main/java/techreborn/events/BlockBreakHandler.java b/src/main/java/techreborn/events/BlockBreakHandler.java new file mode 100644 index 000000000..34cae0642 --- /dev/null +++ b/src/main/java/techreborn/events/BlockBreakHandler.java @@ -0,0 +1,26 @@ +package techreborn.events; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.world.BlockEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import techreborn.items.ItemGems; +import techreborn.items.ItemParts; +import techreborn.utils.OreDictUtils; + +/** + * Created by McKeever on 10/16/2016. + */ +public class BlockBreakHandler { + + @SubscribeEvent + public void onBlockHarvest(BlockEvent.HarvestDropsEvent event) { + for (ItemStack ore : event.getDrops()) { + if (OreDictUtils.isOre(ore, "gemRuby")) { + EntityItem item = new EntityItem(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), + ItemGems.getGemByName("redGarnet").copy()); + event.getWorld().spawnEntityInWorld(item); + } + } + } +}