Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba6000 authored Sep 4, 2024
1 parent 99d7ef2 commit ead1385
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package gtPlusPlus.core.handler.events;

import java.util.ArrayList;

import net.minecraft.entity.boss.EntityDragon;
import net.minecraftforge.event.entity.living.LivingDropsEvent;

import org.jetbrains.annotations.NotNull;

import com.kuba6000.mobsinfo.api.IMobExtraInfoProvider;
import com.kuba6000.mobsinfo.api.MobDrop;
import com.kuba6000.mobsinfo.api.MobRecipe;

import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import gtPlusPlus.core.material.MaterialsElements;
import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;

public class EnderDragonDeathHandler {
@Optional.Interface(iface = "com.kuba6000.mobsinfo.api.IMobExtraInfoProvider", modid = "mobsinfo")
public class EnderDragonDeathHandler implements IMobExtraInfoProvider {

private static final String mDragonClassName = "chylex.hee.entity.boss.EntityBossDragon";
private static final boolean mHEE;
Expand All @@ -28,6 +38,7 @@ public class EnderDragonDeathHandler {

@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event) {
//

int aCountTotal = 0;

Expand Down Expand Up @@ -61,4 +72,50 @@ public void onEntityDrop(LivingDropsEvent event) {
.messageAllPlayers(aCountTotal + " Shards of Dragons Blood have crystalized into a metallic form.");
}
}

@Optional.Method(modid = "mobsinfo")
@Override
public void provideExtraDropsInformation(@NotNull String entityString, @NotNull ArrayList<MobDrop> drops,
@NotNull MobRecipe recipe) {
if (mHEE && mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(recipe.entity)) {
MobDrop drop = new MobDrop(
MaterialsElements.STANDALONE.DRAGON_METAL.getNugget(1),
MobDrop.DropType.Normal,
(int) (MobDrop.getChanceBasedOnFromTo(100, 250) * MobDrop.getChanceBasedOnFromTo(5, 25) * 10000d),
null,
null,
false,
false);

drop.clampChance();

drops.add(drop);
} else if (mDE && mChaoseDragonClass != null && mChaoseDragonClass.isInstance(recipe.entity)) {
MobDrop drop = new MobDrop(
MaterialsElements.STANDALONE.DRAGON_METAL.getIngot(1),
MobDrop.DropType.Normal,
(int) (MobDrop.getChanceBasedOnFromTo(100, 200) * MobDrop.getChanceBasedOnFromTo(1, 5) * 10000d),
null,
null,
false,
false);

drop.clampChance();

drops.add(drop);
} else if (recipe.entity instanceof EntityDragon) {
MobDrop drop = new MobDrop(
MaterialsElements.STANDALONE.DRAGON_METAL.getNugget(1),
MobDrop.DropType.Normal,
(int) (MobDrop.getChanceBasedOnFromTo(25, 50) * MobDrop.getChanceBasedOnFromTo(1, 10) * 10000d),
null,
null,
false,
false);

drop.clampChance();

drops.add(drop);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gtPlusPlus.core.handler.events;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

Expand All @@ -8,6 +9,13 @@
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDropsEvent;

import org.jetbrains.annotations.NotNull;

import com.kuba6000.mobsinfo.api.IMobExtraInfoProvider;
import com.kuba6000.mobsinfo.api.MobDrop;
import com.kuba6000.mobsinfo.api.MobRecipe;

import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
Expand All @@ -17,14 +25,15 @@
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;

public class EntityDeathHandler {
@Optional.Interface(iface = "com.kuba6000.mobsinfo.api.IMobExtraInfoProvider", modid = "mobsinfo")
public class EntityDeathHandler implements IMobExtraInfoProvider {

private static final HashMap<Class, AutoMap<Triplet<ItemStack, Integer, Integer>>> mMobDropMap = new HashMap<>();
private static final HashSet<Class> mInternalClassKeyCache = new HashSet<>();

/**
* Provides the ability to provide custom drops upon the death of EntityLivingBase objects.
*
*
* @param aMobClass - The Base Class you want to drop this item.
* @param aStack - The ItemStack, stack size is not respected.
* @param aMaxAmount - The maximum size of the ItemStack which drops.
Expand Down Expand Up @@ -123,4 +132,36 @@ public void onEntityDrop(LivingDropsEvent event) {
}
}
}

@Optional.Method(modid = "mobsinfo")
@Override
public void provideExtraDropsInformation(@NotNull String entityString, @NotNull ArrayList<MobDrop> drops,
@NotNull MobRecipe recipe) {
AutoMap<Triplet<ItemStack, Integer, Integer>> dropEntry = mMobDropMap.get(recipe.entity.getClass());

if (dropEntry != null && !dropEntry.isEmpty()) {
for (Triplet<ItemStack, Integer, Integer> data : dropEntry) {
ItemStack loot = data.getValue_1();
int maxDrop = data.getValue_2();
int chance = data.getValue_3();
if (loot == null) continue;

loot = loot.copy();
loot.stackSize = 1;

MobDrop drop = new MobDrop(
loot,
MobDrop.DropType.Normal,
(int) (MobDrop.getChanceBasedOnFromTo(1, maxDrop) * 10000d * ((double) chance / 10000d)),
null,
null,
false,
false);

drop.clampChance();

drops.add(drop);
}
}
}
}

0 comments on commit ead1385

Please sign in to comment.