Files
BloodMagic/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryFuelHandler.java
T
LyftsGitHub GTNH Actionsgithub-actions[bot]
fcddb56254 Fix client-side crash on servers (#52)
* update deps

* fix client crash on servers

* spotlessApply (#53)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-10 09:36:17 +02:00

62 lines
1.8 KiB
Java

package WayofTime.alchemicalWizardry.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.LavaCrystal;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IFuelHandler;
public class AlchemicalWizardryFuelHandler implements IFuelHandler {
@Override
public int getBurnTime(ItemStack fuel) {
if (fuel == null) {
return 0;
}
Item fuelItem = fuel.getItem();
if (fuelItem.equals(ModItems.lavaCrystal)) {
LavaCrystal item = (LavaCrystal) fuel.getItem();
if (item.hasEnoughEssence(fuel)) {
return 200;
} else {
NBTTagCompound tag = fuel.getTagCompound();
if (tag == null) {
return 0;
}
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
return 0;
}
if (mcServer.getConfigurationManager() == null) {
return 0;
}
EntityPlayer owner = SpellHelper.getPlayerForUsername(tag.getString("ownerName"));
if (owner == null) {
return 0;
}
owner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
return 0;
}
}
return 0;
}
}