aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2024-08-15 18:48:11 +0200
committerGitHub <noreply@github.com>2024-08-15 18:48:11 +0200
commit799d5edf98e7e9f6152f432cdc48eac858398c8a (patch)
tree63e6640225fb9e68dd79897a8856e42690ad93d3
parent0b9eadb8c1532a34c524a5fb2374e66d209616de (diff)
downloadGT5-Unofficial-799d5edf98e7e9f6152f432cdc48eac858398c8a.tar.gz
GT5-Unofficial-799d5edf98e7e9f6152f432cdc48eac858398c8a.tar.bz2
GT5-Unofficial-799d5edf98e7e9f6152f432cdc48eac858398c8a.zip
Move coremod drops to coremod (#2891)
-rw-r--r--dependencies.gradle2
-rw-r--r--src/main/java/kubatech/loaders/MobHandlerLoader.java103
2 files changed, 9 insertions, 96 deletions
diff --git a/dependencies.gradle b/dependencies.gradle
index a8aca2eae3..bcc5705cd7 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -47,7 +47,7 @@ dependencies {
api('com.github.GTNewHorizons:Yamcl:0.6.0:dev')
compileOnlyApi('com.github.GTNewHorizons:ThaumicTinkerer:2.10.1:dev')
- compileOnlyApi("com.github.GTNewHorizons:Mobs-Info:0.3.2-GTNH:dev")
+ compileOnlyApi("com.github.GTNewHorizons:Mobs-Info:0.4.1-GTNH:dev")
compileOnlyApi("com.github.GTNewHorizons:Navigator:1.0.6:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:Infernal-Mobs:1.8.1-GTNH:dev")
diff --git a/src/main/java/kubatech/loaders/MobHandlerLoader.java b/src/main/java/kubatech/loaders/MobHandlerLoader.java
index 5e30ad2aad..c7932dd00c 100644
--- a/src/main/java/kubatech/loaders/MobHandlerLoader.java
+++ b/src/main/java/kubatech/loaders/MobHandlerLoader.java
@@ -21,12 +21,10 @@
package kubatech.loaders;
import static gregtech.api.enums.Mods.InfernalMobs;
-import static gregtech.api.enums.Mods.NewHorizonsCoreMod;
import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeEntityCrusher.DIAMOND_SPIKES_DAMAGE;
import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeEntityCrusher.MOB_SPAWN_INTERVAL;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -35,11 +33,8 @@ import java.util.Map;
import java.util.Random;
import net.minecraft.enchantment.EnchantmentHelper;
-import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.JsonToNBT;
-import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.MinecraftForge;
@@ -48,19 +43,15 @@ import org.apache.logging.log4j.Logger;
import com.kuba6000.mobsinfo.api.IChanceModifier;
import com.kuba6000.mobsinfo.api.MobDrop;
-import com.kuba6000.mobsinfo.api.MobOverride;
import com.kuba6000.mobsinfo.api.MobRecipe;
import com.kuba6000.mobsinfo.api.event.MobNEIRegistrationEvent;
import com.kuba6000.mobsinfo.api.event.PostMobRegistrationEvent;
-import com.kuba6000.mobsinfo.api.event.PostMobsOverridesLoadEvent;
import com.kuba6000.mobsinfo.api.event.PreMobsRegistrationEvent;
import atomicstryker.infernalmobs.common.InfernalMobsCore;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.util.GT_Utility;
import kubatech.Tags;
-import kubatech.api.helpers.ReflectionHelper;
import kubatech.config.Config;
import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeEntityCrusher;
@@ -221,6 +212,14 @@ public class MobHandlerLoader {
@SuppressWarnings("unused")
public void onPostMobRegistration(PostMobRegistrationEvent event) {
if (!event.drops.isEmpty() && event.recipe.isUsableInVial) {
+ for (MobDrop drop : event.drops) {
+ if (drop.playerOnly) {
+ drop.additionalInfo.add(
+ StatCollector.translateToLocalFormatted(
+ "kubatech.mobhandler.eec_chance",
+ (((double) drop.chance / 100d) * Config.MobHandler.playerOnlyDropsModifier)));
+ }
+ }
@SuppressWarnings("unchecked")
ArrayList<MobDrop> drops = (ArrayList<MobDrop>) event.drops.clone();
if (!drops.isEmpty()) {
@@ -231,92 +230,6 @@ public class MobHandlerLoader {
@SubscribeEvent
@SuppressWarnings("unused")
- public void onPostOverridesConfigLoad(PostMobsOverridesLoadEvent event) throws ReflectiveOperationException {
- if (NewHorizonsCoreMod.isModLoaded()) {
- LOG.info("Detected GTNH Core Mod, parsing custom drops from there.");
- final Class<?> cMainRegistry = Class.forName("com.dreammaster.main.MainRegistry");
- final Object dropsHandler = cMainRegistry.getField("Module_CustomDrops")
- .get(null);
- if (dropsHandler == null) return;
- final Class<?> cDrops = Class.forName("com.dreammaster.modcustomdrops.CustomDrops");
- final Object coredrops = ReflectionHelper.getField(dropsHandler, "_mCustomDrops", null);
- final Method mGetCustomDrops = cDrops.getMethod("getCustomDrops");
-
- final Class<?> cCustomDrop = Class.forName("com.dreammaster.modcustomdrops.CustomDrops$CustomDrop");
- final Method mGetCustomDropEntityName = cCustomDrop.getMethod("getEntityName");
- final Method mGetCustomDropDrops = cCustomDrop.getMethod("getDrops");
-
- final Class<?> cDrop = Class.forName("com.dreammaster.modcustomdrops.CustomDrops$CustomDrop$Drop");
- final Method mDropGetItemName = cDrop.getMethod("getItemName");
- final Method mDropGetChance = cDrop.getMethod("getChance");
- final Method mDropGetAmount = cDrop.getMethod("getAmount");
- final Method mDropGetIsRandomAmount = cDrop.getMethod("getIsRandomAmount");
-
- if (coredrops != null) {
- final ArrayList<?> customDrops = new ArrayList<>((ArrayList<?>) mGetCustomDrops.invoke(coredrops));
- for (final Object customDrop : customDrops) {
- try {
- final String entityName = (String) mGetCustomDropEntityName.invoke(customDrop);
-
- final Class<?> eclass = Class.forName(entityName);
- if (!EntityLiving.class.isAssignableFrom(eclass)) continue;
- final String ename = EntityList.classToStringMapping.get(eclass);
- if (ename == null) continue;
- final MobOverride override = event.overrides.computeIfAbsent(ename, k -> new MobOverride());
- final List<?> entityDrops = (List<?>) mGetCustomDropDrops.invoke(customDrop);
-
- for (final Object drop : entityDrops) {
- final String itemName = (String) mDropGetItemName.invoke(drop);
- String[] parts = itemName.split(":");
- ItemStack stack = GameRegistry.findItemStack(parts[0], parts[1], 1);
- if (stack == null) continue;
- if (parts.length > 2) stack.setItemDamage(Integer.parseInt(parts[2]));
- String pNBT = ReflectionHelper.getField(drop, "mTag", null);
- if (pNBT != null && !pNBT.isEmpty()) {
- try {
- stack.stackTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(pNBT);
- } catch (Exception ignored) {}
- }
- int chance = ((int) mDropGetChance.invoke(drop)) * 100;
- int amount = (int) mDropGetAmount.invoke(drop);
- if ((boolean) mDropGetIsRandomAmount.invoke(drop)) {
- // average chance formula
- // chance *= ((((amount * (amount + 1d)) / 2d)) + 1d) / (amount + 1d);
- chance *= (2d + (amount * amount) + amount) / (2d * (amount + 1d));
- amount = 1;
- if (chance > 10000) {
- int div = (int) Math.ceil(chance / 10000d);
- amount *= div;
- chance /= div;
- }
- }
- stack.stackSize = amount;
- // Drops from coremod are player only
- MobDrop mobDrop = new MobDrop(
- stack,
- MobDrop.DropType.Normal,
- chance,
- null,
- null,
- false,
- true);
- mobDrop.additionalInfo.add(
- StatCollector.translateToLocalFormatted(
- "kubatech.mobhandler.eec_chance",
- (((double) chance / 100d) * Config.MobHandler.playerOnlyDropsModifier)));
- override.additions.add(mobDrop);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- }
-
- @SubscribeEvent
- @SuppressWarnings("unused")
public void onMobNEIRegistration(MobNEIRegistrationEvent event) {
MobEECRecipe recipe = recipeMap.get(event.mobName);
if (recipe != null) {