mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-20 12:19:39 +00:00
Funky stuff for infinity metal tonk
This commit is contained in:
1 parent
a2ae147343
commit
df94126ea8
3 files changed
+115
-31
No files matched your search
@@ -76,40 +76,16 @@ public class LudicrousEvents {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void extraLuck(HarvestDropsEvent event){
|
||||
if(event.harvester == null)
|
||||
public void handleExtraLuck(HarvestDropsEvent event) {
|
||||
if(event.harvester == null)
|
||||
return;
|
||||
if(event.harvester.getHeldItem() == null)
|
||||
return;
|
||||
ItemStack held = event.harvester.getHeldItem();
|
||||
if(held.getItem() == LudicrousItems.infinity_pickaxe){
|
||||
if(event.block.getMaterial() == Material.rock){
|
||||
List<ItemStack> adds = new ArrayList<ItemStack>();
|
||||
List<ItemStack> removals = new ArrayList<ItemStack>();
|
||||
for(ItemStack drop : event.drops){
|
||||
if(drop.getItem() != Item.getItemFromBlock(event.block) && !(drop.getItem() instanceof ItemBlock)){
|
||||
drop.stackSize = Math.min(drop.stackSize * 4, drop.getMaxStackSize());
|
||||
}
|
||||
else if(drop.getItem() == Item.getItemFromBlock(event.block))
|
||||
{
|
||||
ItemFracturedOre ifo = (ItemFracturedOre)LudicrousItems.fractured_ore;
|
||||
int[] oreids = OreDictionary.getOreIDs(drop);
|
||||
for (int i=0; i<oreids.length; i++) {
|
||||
String orename = OreDictionary.getOreName(oreids[i]);
|
||||
if (orename.startsWith("ore")) {
|
||||
// add the fractured ores
|
||||
adds.add(ifo.getStackForOre(drop, Math.min(drop.stackSize * 5, drop.getMaxStackSize())));
|
||||
removals.add(drop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.drops.addAll(adds);
|
||||
event.drops.removeAll(removals);
|
||||
}
|
||||
|
||||
if (held.getTagCompound().getBoolean("hammer")
|
||||
if(held.getItem() == LudicrousItems.infinity_pickaxe) {
|
||||
extraLuck(event, 4);
|
||||
|
||||
if (held.getTagCompound().getBoolean("hammer")
|
||||
&& ToolHelper.hammering.contains(event.harvester)
|
||||
&& ToolHelper.hammerdrops.containsKey(event.harvester)
|
||||
&& ToolHelper.hammerdrops.get(event.harvester) != null) {
|
||||
@@ -119,6 +95,34 @@ public class LudicrousEvents {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void extraLuck(HarvestDropsEvent event, int mult){
|
||||
if(event.block.getMaterial() == Material.rock){
|
||||
List<ItemStack> adds = new ArrayList<ItemStack>();
|
||||
List<ItemStack> removals = new ArrayList<ItemStack>();
|
||||
for(ItemStack drop : event.drops){
|
||||
if(drop.getItem() != Item.getItemFromBlock(event.block) && !(drop.getItem() instanceof ItemBlock)){
|
||||
drop.stackSize = Math.min(drop.stackSize * mult, drop.getMaxStackSize());
|
||||
}
|
||||
else if(drop.getItem() == Item.getItemFromBlock(event.block))
|
||||
{
|
||||
ItemFracturedOre ifo = (ItemFracturedOre)LudicrousItems.fractured_ore;
|
||||
int[] oreids = OreDictionary.getOreIDs(drop);
|
||||
for (int i=0; i<oreids.length; i++) {
|
||||
String orename = OreDictionary.getOreName(oreids[i]);
|
||||
if (orename.startsWith("ore")) {
|
||||
// add the fractured ores
|
||||
adds.add(ifo.getStackForOre(drop, Math.min(drop.stackSize * (mult+1), drop.getMaxStackSize())));
|
||||
removals.add(drop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.drops.addAll(adds);
|
||||
event.drops.removeAll(removals);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItem(ItemStack drop, World world, int x, int y, int z){
|
||||
float f = 0.7F;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package fox.spiteful.avaritia.compat.ticon;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.ToolMaterial;
|
||||
@@ -31,6 +33,8 @@ public class Tonkers {
|
||||
TConstructRegistry.addArrowMaterial(neutroniumId, 5.0f, 0.0f);
|
||||
TConstructRegistry.addArrowMaterial(infinityMetalId, 2.0f, 0.0f);
|
||||
|
||||
|
||||
TonkersEvents events = new TonkersEvents();
|
||||
MinecraftForge.EVENT_BUS.register(events);
|
||||
FMLCommonHandler.instance().bus().register(events);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package fox.spiteful.avaritia.compat.ticon;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
|
||||
import tconstruct.library.event.ToolCraftEvent;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import fox.spiteful.avaritia.LudicrousEvents;
|
||||
|
||||
public class TonkersEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public void craftTool (ToolCraftEvent.NormalTool event)
|
||||
{
|
||||
NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool");
|
||||
handleInfinityMods(toolTag, event.tool);
|
||||
}
|
||||
|
||||
private void handleInfinityMods (NBTTagCompound toolTag, ToolCore tool)
|
||||
{
|
||||
int plusmod = 5;
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
if (toolTag.getInteger("Head") == Tonkers.infinityMetalId)
|
||||
modifiers += plusmod;
|
||||
if (toolTag.getInteger("Handle") == Tonkers.infinityMetalId)
|
||||
modifiers += plusmod;
|
||||
if (toolTag.getInteger("Accessory") == Tonkers.infinityMetalId)
|
||||
modifiers += plusmod;
|
||||
if (toolTag.getInteger("Extra") == Tonkers.infinityMetalId)
|
||||
modifiers += plusmod;
|
||||
|
||||
// 2 part tools gain 2 modifiers for the head
|
||||
if (tool.getPartAmount() == 2 && toolTag.getInteger("Head") == Tonkers.infinityMetalId)
|
||||
modifiers += plusmod;
|
||||
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handleExtraLuck(HarvestDropsEvent event) {
|
||||
if(event.harvester == null)
|
||||
return;
|
||||
if(event.harvester.getHeldItem() == null)
|
||||
return;
|
||||
ItemStack held = event.harvester.getHeldItem();
|
||||
if (held != null && held.hasTagCompound() && held.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore tool = (ToolCore)held.getItem();
|
||||
NBTTagCompound toolTag = held.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
if (toolTag.getInteger("Head") == Tonkers.infinityMetalId) {
|
||||
int parts = 1;
|
||||
if (toolTag.getInteger("Handle") == Tonkers.infinityMetalId) {
|
||||
parts++;
|
||||
}
|
||||
if (toolTag.getInteger("Accessory") == Tonkers.infinityMetalId) {
|
||||
parts++;
|
||||
}
|
||||
if (toolTag.getInteger("Extra") == Tonkers.infinityMetalId) {
|
||||
parts++;
|
||||
}
|
||||
|
||||
int luck = Math.min(3, parts);
|
||||
if (parts == tool.getPartAmount()) {
|
||||
luck++;
|
||||
if (tool.getPartAmount() == 2) {
|
||||
luck++;
|
||||
}
|
||||
}
|
||||
|
||||
LudicrousEvents.extraLuck(event, luck);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user