aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2024-09-04 02:43:47 +0200
committerGitHub <noreply@github.com>2024-09-04 00:43:47 +0000
commitead1385464310f4fddda2c5566d541c187d659fc (patch)
treef7c4065681259b326cf13735576f230e5fc75d32
parent99d7ef252bfd06d963ed5e5ccf59244d248f2fa0 (diff)
downloadGT5-Unofficial-ead1385464310f4fddda2c5566d541c187d659fc.tar.gz
GT5-Unofficial-ead1385464310f4fddda2c5566d541c187d659fc.tar.bz2
GT5-Unofficial-ead1385464310f4fddda2c5566d541c187d659fc.zip
fix (#3038)
-rw-r--r--src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java59
-rw-r--r--src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java45
2 files changed, 101 insertions, 3 deletions
diff --git a/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java
index 008f0db0d4..13dc18c4b1 100644
--- a/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java
+++ b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java
@@ -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;
@@ -28,6 +38,7 @@ public class EnderDragonDeathHandler {
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event) {
+ //
int aCountTotal = 0;
@@ -61,4 +72,50 @@ public class EnderDragonDeathHandler {
.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);
+ }
+ }
}
diff --git a/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java b/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java
index 20d64f2b36..4baa7a80dd 100644
--- a/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java
+++ b/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java
@@ -1,5 +1,6 @@
package gtPlusPlus.core.handler.events;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -8,6 +9,13 @@ import net.minecraft.entity.player.EntityPlayer;
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;
@@ -17,14 +25,15 @@ import gtPlusPlus.core.util.math.MathUtils;
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.
@@ -123,4 +132,36 @@ public class EntityDeathHandler {
}
}
}
+
+ @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);
+ }
+ }
+ }
}