mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 19:59:55 +00:00
Allow Thaumometers to be added to travellers goggles.
1 Thaumometer = see nodes 2 Thaumometers = like the goggles of revealing You can upgrade from 1 to 2 thaumometers.
This commit is contained in:
1 parent
920edde7fd
commit
b861a114ca
8 files changed
+263
-3
No files matched your search
@@ -36,7 +36,7 @@ import tconstruct.plugins.ic2.TinkerIC2;
|
||||
import tconstruct.plugins.imc.TinkerAE2;
|
||||
import tconstruct.plugins.imc.TinkerBuildCraft;
|
||||
import tconstruct.plugins.imc.TinkerMystcraft;
|
||||
import tconstruct.plugins.imc.TinkerThaumcraft;
|
||||
import tconstruct.plugins.TinkerThaumcraft;
|
||||
import tconstruct.plugins.mfr.TinkerMFR;
|
||||
import tconstruct.plugins.te4.TinkerTE4;
|
||||
import tconstruct.plugins.waila.TinkerWaila;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.armor.items;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
@@ -12,9 +13,16 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.armor.ArmorProxyClient;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.library.armor.*;
|
||||
import thaumcraft.api.IGoggles;
|
||||
import thaumcraft.api.nodes.IRevealer;
|
||||
|
||||
public class TravelGear extends ArmorCore
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer"),
|
||||
@Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles")
|
||||
})
|
||||
public class TravelGear extends ArmorCore implements IRevealer, IGoggles
|
||||
{
|
||||
|
||||
public TravelGear(ArmorPart part)
|
||||
@@ -138,6 +146,8 @@ public class TravelGear extends ArmorCore
|
||||
case 0:
|
||||
modifiers = new IIcon[5];
|
||||
modifiers[0] = iconRegister.registerIcon("tinker:" + textureFolder + "/" + "goggles" + "_" + "nightvision");
|
||||
modifiers[1] = iconRegister.registerIcon("tinker:" + textureFolder + "/" + "goggles" + "_" + "thaumic1");
|
||||
modifiers[2] = iconRegister.registerIcon("tinker:" + textureFolder + "/" + "goggles" + "_" + "thaumic2");
|
||||
modifiers[4] = iconRegister.registerIcon("tinker:" + textureFolder + "/" + "goggles" + "_" + "moss");
|
||||
break;
|
||||
case 1:
|
||||
@@ -188,4 +198,22 @@ public class TravelGear extends ArmorCore
|
||||
|
||||
super.addInformation(stack, player, list, par4);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
@Override
|
||||
public boolean showNodes(ItemStack itemstack, EntityLivingBase player) {
|
||||
if(itemstack == null || !itemstack.hasTagCompound() || itemstack.getItem() != TinkerArmor.travelGoggles)
|
||||
return false;
|
||||
|
||||
return itemstack.getTagCompound().getCompoundTag(this.getBaseTagName()).getBoolean("Thaumic Senses");
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
@Override
|
||||
public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) {
|
||||
if(itemstack == null || !itemstack.hasTagCompound() || itemstack.getItem() != TinkerArmor.travelGoggles)
|
||||
return false;
|
||||
|
||||
return itemstack.getTagCompound().getCompoundTag(this.getBaseTagName()).getBoolean("Thaumic Vision");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package tconstruct.modifiers.armor;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.library.armor.ArmorMod;
|
||||
import tconstruct.library.armor.ArmorPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class AModThaumicVision extends ArmorMod {
|
||||
private final AModBoolean thaumicSensesMod;
|
||||
private final AModBoolean thaumicVisionMod;
|
||||
|
||||
private final Item thaumometer;
|
||||
|
||||
public AModThaumicVision(ItemStack thaumometer) {
|
||||
super(-1, "", EnumSet.of(ArmorPart.Head), new ItemStack[]{thaumometer});
|
||||
//super(effect, "Thaumic Vision", EnumSet.of(ArmorPart.Head), new ItemStack[]{}, EnumChatFormatting.DARK_PURPLE.toString(), "Thaumic Vision");
|
||||
|
||||
this.thaumometer = thaumometer.getItem();
|
||||
thaumicSensesMod = new AModBoolean(1, "Thaumic Senses", EnumSet.of(ArmorPart.Head), new ItemStack[0], EnumChatFormatting.DARK_PURPLE.toString(), "Thaumic Senses");
|
||||
thaumicVisionMod = new AModBoolean(2, "Thaumic Vision", EnumSet.of(ArmorPart.Head), new ItemStack[0], EnumChatFormatting.DARK_PURPLE.toString(), "Thaumic Vision");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify(ItemStack armor, ItemStack[] recipe) {
|
||||
// return true if one of the two hasn't been applied yet. bam.
|
||||
return thaumicSensesMod.canModify(armor, recipe) || thaumicVisionMod.canModify(armor, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(ItemStack[] recipe, ItemStack input) {
|
||||
int effect = -1;
|
||||
int count = countThaumometers(recipe);
|
||||
if(thaumicSensesMod.canModify(input, recipe)) {
|
||||
// if we add the thaumic vision too, we need to add the graphical effect for the senses too
|
||||
if(count > 1)
|
||||
thaumicSensesMod.addMatchingEffect(input);
|
||||
|
||||
thaumicSensesMod.modify(recipe, input);
|
||||
count--; // one thaumometer used up
|
||||
effect = thaumicSensesMod.effectIndex;
|
||||
}
|
||||
|
||||
// if we still have 1 thaumometer left, we apply vision
|
||||
if(count > 0)
|
||||
{
|
||||
// step 1: remove the thaumic senses tooltip
|
||||
// we re-add the tooltip to find out its index
|
||||
int tipNum = addToolTip(input, thaumicSensesMod.color + thaumicSensesMod.tooltipName, thaumicSensesMod.color + thaumicSensesMod.key);
|
||||
// and now we kill it \o/
|
||||
NBTTagCompound tipTags = input.getTagCompound().getCompoundTag(getTagName(input));
|
||||
tipTags.removeTag("Tooltip" + tipNum);
|
||||
tipTags.removeTag("ModifierTip" + tipNum);
|
||||
|
||||
// step 2: we add a modifier, because thaumic vision is free since we already used a modifier for the senses
|
||||
NBTTagCompound tags = getModifierTag(input);
|
||||
tags.setInteger("Modifiers", tags.getInteger("Modifiers") + 1);
|
||||
|
||||
// step 3: we simply apply thaumic vision now. it should replace the just removed tooltip and the just added modifier
|
||||
thaumicVisionMod.modify(recipe, input);
|
||||
|
||||
effect = thaumicVisionMod.effectIndex;
|
||||
}
|
||||
|
||||
// fix the effect display
|
||||
NBTTagCompound tags = input.getTagCompound().getCompoundTag(getTagName(input));
|
||||
int i = 1;
|
||||
for(; i <= 6; i++)
|
||||
if(tags.getInteger("Effect" + i) == -1)
|
||||
{
|
||||
tags.setInteger("Effect" + i, effect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasThaumicSenses(ItemStack stack)
|
||||
{
|
||||
return stack != null && stack.hasTagCompound() && stack.getTagCompound().getCompoundTag(TinkerArmor.travelGoggles.getBaseTagName()).getBoolean(thaumicSensesMod.key);
|
||||
}
|
||||
|
||||
public boolean matches (ItemStack[] recipe, ItemStack input)
|
||||
{
|
||||
if (!canModify(input, recipe))
|
||||
return false;
|
||||
|
||||
// check how many thaumometers there are
|
||||
int count = countThaumometers(recipe);
|
||||
|
||||
// none? what are you doing!
|
||||
// more than 2? HOW MANY EYES DO YOU HAVE?
|
||||
if(count == 0 || count > 2)
|
||||
return false;
|
||||
|
||||
// one? np since we can modify
|
||||
if(count == 1)
|
||||
return true;
|
||||
|
||||
// 2 thaumometers.. only ok if it has no senses
|
||||
return !hasThaumicSenses(input);
|
||||
}
|
||||
|
||||
private int countThaumometers(ItemStack[] recipe)
|
||||
{
|
||||
int count = 0;
|
||||
for(ItemStack stack : recipe) {
|
||||
if(stack != null && stack.getItem() == thaumometer)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
+24
-1
@@ -1,11 +1,20 @@
|
||||
package tconstruct.plugins.imc;
|
||||
package tconstruct.plugins;
|
||||
|
||||
import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
import mantle.pulsar.pulse.*;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.armor.ArmorPart;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.modifiers.armor.AModBoolean;
|
||||
import tconstruct.modifiers.armor.AModThaumicVision;
|
||||
import tconstruct.world.TinkerWorld;
|
||||
import thaumcraft.api.ItemApi;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
@ObjectHolder(TConstruct.modID)
|
||||
@Pulse(id = "Tinkers Thaumcraft Compatibility", description = "Tinkers Construct compatibility for Thaumcraft", modsRequired = "Thaumcraft", pulsesRequired = "Tinkers' World", forced = true)
|
||||
@@ -16,6 +25,12 @@ public class TinkerThaumcraft
|
||||
public void init (FMLInitializationEvent event)
|
||||
{
|
||||
TConstruct.logger.info("Thaumcraft detected. Registering harvestables.");
|
||||
sendIMC();
|
||||
registerModifiers();
|
||||
}
|
||||
|
||||
private void sendIMC()
|
||||
{
|
||||
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerry, 1, 12));
|
||||
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerry, 1, 13));
|
||||
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerry, 1, 14));
|
||||
@@ -24,4 +39,12 @@ public class TinkerThaumcraft
|
||||
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerrySecond, 1, 13));
|
||||
}
|
||||
|
||||
private void registerModifiers()
|
||||
{
|
||||
ItemStack thaumometer = ItemApi.getItem("itemThaumometer", 0);
|
||||
if(thaumometer != null) {
|
||||
// Thaumometer Vision!
|
||||
ModifyBuilder.registerModifier(new AModThaumicVision(thaumometer));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user