Add KingSlime NEI drops as IMobInforProvider (-0.8s from first pack load) (#122)

* Add KingSlime drops provider (-0.8s)

* Fix

* Update dependencies.gradle

* Update dependencies.gradle

* update

---------

Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
JakubandMartin Robertz authored and GitHub committed 2024-08-27 09:54:53 +02:00
1 parent 691a6ef32b
commit 305ecbe6c8
10 files changed
+310 -12

No files matched your search

@@ -1,7 +1,10 @@
package tconstruct.armor;
import java.util.ArrayList;
import java.util.Locale;
import javax.annotation.Nonnull;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.item.EntityItem;
@@ -16,6 +19,11 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
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 tconstruct.TConstruct;
import tconstruct.armor.items.TravelWings;
@@ -24,10 +32,12 @@ import tconstruct.library.modifier.IModifyable;
import tconstruct.util.config.PHConstruct;
import tconstruct.util.network.ArmourGuiSyncPacket;
public class TinkerArmorEvents {
@Optional.Interface(iface = "com.kuba6000.mobsinfo.api.IMobExtraInfoProvider", modid = "mobsinfo")
public class TinkerArmorEvents implements IMobExtraInfoProvider {
@SubscribeEvent
public void onLivingDrop(LivingDropsEvent event) {
// ANY CHANGE MADE IN HERE MUST ALSO BE MADE IN provideDropsInformation!
if (event.entityLiving == null) return;
if (!event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) return;
@@ -65,6 +75,39 @@ public class TinkerArmorEvents {
}
}
@Optional.Method(modid = "mobsinfo")
@Override
public void provideExtraDropsInformation(@Nonnull String entityString, @Nonnull ArrayList<MobDrop> drops,
@Nonnull MobRecipe recipe) {
if (recipe.entity instanceof IMob) {
MobDrop drop = new MobDrop(
new ItemStack(TinkerArmor.heartCanister, 1, 1),
MobDrop.DropType.Normal,
50,
null,
null,
false,
false);
drops.add(drop);
}
if (recipe.entity instanceof IBossDisplayData) {
String entityName = recipe.entity.getClass().getSimpleName().toLowerCase();
for (String name : PHConstruct.heartDropBlacklist)
if (name.toLowerCase(Locale.US).equals(entityName)) return;
MobDrop drop = new MobDrop(
new ItemStack(TinkerArmor.heartCanister, recipe.entity instanceof EntityDragon ? 5 : 1, 3),
MobDrop.DropType.Normal,
10000,
null,
null,
false,
false);
drops.add(drop);
}
}
/* Abilities */
@SubscribeEvent
public void armorMineSpeed(net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed event) {