Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
-Primal Destroyer will now correctly have Essence Harvester III when taken from Creative or JEI.
-Fix optional ores in Ore Diviner's recipe not correctly showing up when the mods that add them are also installed.
  • Loading branch information
IcarussOne committed Aug 25, 2024
1 parent 1b13a48 commit fc7a528
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,16 @@ private static void initInfusionRecipes() {
divinerIngredients.add("oreIron");
divinerIngredients.add("oreGold");
if (OreDictionary.doesOreNameExist("oreCopper") && !OreDictionary.getOres("oreCopper", false).isEmpty()) {
ingredients.add("oreCopper");
divinerIngredients.add("oreCopper");
}
if (OreDictionary.doesOreNameExist("oreTin") && !OreDictionary.getOres("oreTin", false).isEmpty()) {
ingredients.add("oreTin");
divinerIngredients.add("oreTin");
}
if (OreDictionary.doesOreNameExist("oreSilver") && !OreDictionary.getOres("oreSilver", false).isEmpty()) {
ingredients.add("oreSilver");
divinerIngredients.add("oreSilver");
}
if (OreDictionary.doesOreNameExist("oreLead") && !OreDictionary.getOres("oreLead", false).isEmpty()) {
ingredients.add("oreLead");
divinerIngredients.add("oreLead");
}
divinerIngredients.add("oreCinnabar");
ThaumcraftApi.addInfusionCraftingRecipe(new ResourceLocation(ThaumicWonders.MODID, "ore_diviner"), new InfusionRecipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -20,6 +21,7 @@
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.EnumHelper;
Expand All @@ -30,12 +32,13 @@
import thaumcraft.api.capabilities.ThaumcraftCapabilities;
import thaumcraft.api.items.IWarpingGear;
import thaumcraft.api.items.ItemsTC;
import thaumcraft.common.lib.enchantment.EnumInfusionEnchantment;

public class ItemPrimalDestroyer extends ItemSword implements IWarpingGear {
public static final int MAX_HUNGER = 600;

public static Item.ToolMaterial toolMatVoidflame = EnumHelper.addToolMaterial("VOIDFLAME", 4, 200, 8.0F, 8.0F, 20).setRepairItem(new ItemStack(ItemsTC.ingots, 1, 1));

public ItemPrimalDestroyer() {
super(toolMatVoidflame);
this.setCreativeTab(ThaumicWonders.CREATIVE_TAB);
Expand All @@ -52,11 +55,11 @@ public int getWarp(ItemStack itemStack, EntityPlayer player) {
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
if (!worldIn.isRemote && entityIn != null && (entityIn.ticksExisted % 20 == 0) && entityIn instanceof EntityPlayer) {
EntityPlayer entityPlayer = (EntityPlayer)entityIn;
EntityPlayer entityPlayer = (EntityPlayer) entityIn;
if (stack.isItemDamaged()) {
stack.damageItem(-1, entityPlayer);
}

boolean inOffHand = itemSlot == 0 && ItemStack.areItemStacksEqual(stack, entityPlayer.getHeldItemOffhand());
boolean held = isSelected || inOffHand;
boolean onHotbar = (itemSlot >= 0 && itemSlot <= 8);
Expand All @@ -69,18 +72,18 @@ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSl
if (hunger >= MAX_HUNGER) {
// Damage player and reset hunger
if (entityIn instanceof EntityPlayerMP) {
PacketHandler.INSTANCE.sendTo(new PacketLocalizedMessage("event.primal_destroyer.hunger_full"), (EntityPlayerMP)entityIn);
PacketHandler.INSTANCE.sendTo(new PacketLocalizedMessage("event.primal_destroyer.hunger_full"), (EntityPlayerMP) entityIn);
}
entityPlayer.attackEntityFrom(new DamageSource("primalDestroyerHunger"), 12.0F);
entityPlayer.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 60));
entityPlayer.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 120));
hunger = 0;

// Give addenda research
IPlayerKnowledge knowledge = ThaumcraftCapabilities.getKnowledge(entityPlayer);
if (!knowledge.isResearchKnown("f_thevoidhungers")) {
knowledge.addResearch("f_thevoidhungers");
knowledge.sync((EntityPlayerMP)entityPlayer);
knowledge.sync((EntityPlayerMP) entityPlayer);
}
} else {
hunger++;
Expand All @@ -89,7 +92,7 @@ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSl
}
}
}

@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
if (oldStack.getItem() == newStack.getItem() && !slotChanged) {
Expand All @@ -108,7 +111,8 @@ public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingB
target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 60));
target.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 120));
target.setFire(3);
} catch (Exception e) {}
} catch (Exception e) {
}
}
if (!target.world.isRemote) {
if (target.getHealth() <= 0.0F) {
Expand All @@ -119,24 +123,34 @@ public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingB
}
return super.hitEntity(stack, target, attacker);
}

private void decreaseHunger(ItemStack stack, int delta) {
int hunger = 0;
if (stack.hasTagCompound()) {
hunger = stack.getTagCompound().getInteger("hunger");
}

hunger = Math.max(0, hunger - delta);
stack.setTagInfo("hunger", new NBTTagInt(hunger));
}

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this.isInCreativeTab(tab)) {
ItemStack stack = new ItemStack(this);
EnumInfusionEnchantment.addInfusionEnchantment(stack, EnumInfusionEnchantment.ESSENCE, 3);
items.add(stack);
}
}

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
tooltip.add(TextFormatting.GOLD + I18n.format("enchantment.special.sapgreat"));
tooltip.add(TextFormatting.GOLD + I18n.format("enchantment.special.voidflame"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}

@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
Expand Down

0 comments on commit fc7a528

Please sign in to comment.