mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 11:59:14 +00:00
First armor modifier
This commit is contained in:
1 parent
8b154a9cb4
commit
90f09b7e2d
12 files changed
+299
-19
No files matched your search
@@ -9,6 +9,8 @@ import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.network.*;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.crash.CallableMinecraftVersion;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
@@ -68,6 +70,11 @@ public class TConstruct
|
||||
{
|
||||
System.out.println("[TConstruct] Preparing to take over the world");
|
||||
}
|
||||
|
||||
System.out.println("[UUID] Armor Speed: "+UUID.randomUUID());
|
||||
System.out.println("[UUID] Armor Attack: "+UUID.randomUUID());
|
||||
System.out.println("[UUID] Armor Health: "+UUID.randomUUID());
|
||||
System.out.println("[UUID] Armor Knockback: "+UUID.randomUUID());
|
||||
|
||||
EnvironmentChecks.verifyEnvironmentSanity();
|
||||
MinecraftForge.EVENT_BUS.register(events = new TEventHandler());
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class CraftingStationGui extends GuiContainer
|
||||
@@ -67,6 +68,26 @@ public class CraftingStationGui extends GuiContainer
|
||||
|
||||
drawModularToolStats(stack, tool, tags);
|
||||
}
|
||||
else if (stack.getItem() instanceof ArmorCore)
|
||||
{
|
||||
ArmorCore armor = (ArmorCore) stack.getItem();
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("TinkerArmor");
|
||||
this.drawCenteredString(fontRenderer, "\u00A7n" + armor.getClass().getSimpleName(), xSize + 63, 8, 0xffffff);
|
||||
|
||||
drawModularArmorStats(stack, armor, tags);
|
||||
}
|
||||
}
|
||||
|
||||
void drawModularArmorStats (ItemStack stack, ArmorCore tool, NBTTagCompound tags)
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
int base = 24;
|
||||
int offset = 0;
|
||||
if (modifiers > 0)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
|
||||
|
||||
@@ -590,9 +590,9 @@ public class TContent implements IFuelHandler
|
||||
GameRegistry.registerItem(TRepo.bootsWood, "bootsWood");
|
||||
|
||||
TRepo.exoGoggles = new ExoArmor(PHConstruct.exoGoggles, EnumArmorPart.HELMET, "exosuit").setUnlocalizedName("tconstruct.exoGoggles");
|
||||
TRepo.exoChest = new ExoArmor(PHConstruct.exoChest, EnumArmorPart.CHESTPLATE, "exosuit").setUnlocalizedName("tconstruct.exoChest");
|
||||
TRepo.exoPants = new ExoArmor(PHConstruct.exoPants, EnumArmorPart.LEGGINGS, "exosuit").setUnlocalizedName("tconstruct.exoPants");
|
||||
TRepo.exoShoes = new ExoArmor(PHConstruct.exoShoes, EnumArmorPart.BOOTS, "exosuit").setUnlocalizedName("tconstruct.exoShoes");
|
||||
TRepo.exoChest = new ExoArmor(PHConstruct.exoChest, EnumArmorPart.CHEST, "exosuit").setUnlocalizedName("tconstruct.exoChest");
|
||||
TRepo.exoPants = new ExoArmor(PHConstruct.exoPants, EnumArmorPart.PANTS, "exosuit").setUnlocalizedName("tconstruct.exoPants");
|
||||
TRepo.exoShoes = new ExoArmor(PHConstruct.exoShoes, EnumArmorPart.SHOES, "exosuit").setUnlocalizedName("tconstruct.exoShoes");
|
||||
|
||||
String[] materialStrings = { "paperStack", "greenSlimeCrystal", "searedBrick", "ingotCobalt", "ingotArdite", "ingotManyullyn", "mossBall", "lavaCrystal", "necroticBone", "ingotCopper",
|
||||
"ingotTin", "ingotAluminum", "rawAluminum", "ingotBronze", "ingotAluminumBrass", "ingotAlumite", "ingotSteel", "blueSlimeCrystal", "ingotObsidian", "nuggetIron", "nuggetCopper",
|
||||
|
||||
@@ -3,6 +3,7 @@ package tconstruct.common;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,9 +25,12 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.*;
|
||||
import tconstruct.items.blocks.*;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.armor.ArmorMod;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.crafting.*;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.modifiers.armor.AModMoveSpeed;
|
||||
import tconstruct.modifiers.tools.*;
|
||||
import tconstruct.util.RecipeRemover;
|
||||
import tconstruct.util.TDispenserBehaviorArrow;
|
||||
@@ -241,9 +245,11 @@ public class TRecipes
|
||||
TRepo.modFlux = new ModFlux();
|
||||
tb.registerToolMod(TRepo.modFlux);
|
||||
|
||||
EnumSet<EnumArmorPart> allArmors = EnumSet.of(EnumArmorPart.HELMET, EnumArmorPart.CHEST, EnumArmorPart.PANTS, EnumArmorPart.SHOES);
|
||||
ItemStack redstoneItem = new ItemStack(Item.redstone);
|
||||
ItemStack redstoneBlock = new ItemStack(Block.blockRedstone);
|
||||
tb.registerToolMod(new ModRedstone(2, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }));
|
||||
tb.registerArmorMod(new AModMoveSpeed(2, allArmors, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }, false));
|
||||
|
||||
ItemStack lapisItem = new ItemStack(Item.dyePowder, 1, 4);
|
||||
ItemStack lapisBlock = new ItemStack(Block.blockLapis);
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
@@ -114,6 +115,18 @@ public class CraftingStationContainer extends Container
|
||||
if (output != null)
|
||||
return output;
|
||||
}
|
||||
else if (item instanceof ArmorCore)
|
||||
{
|
||||
ItemStack[] slots = new ItemStack[8];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
slots[i] = craftMatrix.getStackInSlot(i);
|
||||
slots[i + 4] = craftMatrix.getStackInSlot(i + 5);
|
||||
}
|
||||
ItemStack output = ToolBuilder.instance.modifyArmor(input, slots, "");
|
||||
if (output != null)
|
||||
return output;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -49,12 +49,16 @@ public class ExoArmor extends ArmorCore
|
||||
NBTTagCompound baseTag = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
list.appendTag(getAttributeTag("generic.attackDamage", "ExoAttack", 10.0, true, knockback));
|
||||
list.appendTag(getAttributeTag("generic.movementSpeed", "ExoSpeed", 1.5, false, speed));
|
||||
list.appendTag(getAttributeTag("generic.maxHealth", "ExoHealth", 10.0, true, health));
|
||||
list.appendTag(getAttributeTag("generic.knockbackResistance", "ExoKnockback", 0.5, false, knockback));
|
||||
//list.appendTag(getAttributeTag("generic.attackDamage", "ExoAttack", 10.0, true, knockback));
|
||||
//list.appendTag(getAttributeTag("generic.movementSpeed", "ExoSpeed", 1.5, false, speed));
|
||||
//list.appendTag(getAttributeTag("generic.maxHealth", "ExoHealth", 10.0, true, health));
|
||||
//list.appendTag(getAttributeTag("generic.knockbackResistance", "ExoKnockback", 0.5, false, knockback));
|
||||
//baseTag.setTag("AttributeModifiers", list);
|
||||
|
||||
NBTTagCompound armorTag = new NBTTagCompound();
|
||||
armorTag.setInteger("Modifiers", 30);
|
||||
baseTag.setTag(SET_NAME, armorTag);
|
||||
|
||||
baseTag.setTag("AttributeModifiers", list);
|
||||
armor.setTagCompound(baseTag);
|
||||
par3List.add(armor);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,54 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.EnumSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
public abstract class ArmorMod extends ToolMod
|
||||
{
|
||||
public ArmorMod(ItemStack[] items, int effect, String dataKey)
|
||||
protected final EnumSet<EnumArmorPart> armorTypes;
|
||||
|
||||
public ArmorMod(int effect, String dataKey, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items)
|
||||
{
|
||||
super(items, effect, dataKey);
|
||||
this.armorTypes = armorTypes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getTagName()
|
||||
protected boolean canModify (ItemStack armor, ItemStack[] input)
|
||||
{
|
||||
ArmorCore item = (ArmorCore) armor.getItem();
|
||||
if (armorTypes.contains(item.armorPart))
|
||||
{
|
||||
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getTagName());
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTagName ()
|
||||
{
|
||||
return "TinkerArmor";
|
||||
}
|
||||
|
||||
public boolean validArmorType(ArmorCore armor)
|
||||
|
||||
public boolean validArmorType (ArmorCore armor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected NBTTagCompound getAttributeTag(String attributeType, String modifierName, double amount, boolean flat, UUID uuid)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("AttributeName", attributeType);
|
||||
tag.setString("Name", modifierName);
|
||||
tag.setDouble("Amount", amount);
|
||||
tag.setInteger("Operation", flat ? 0 : 1);//0 = flat increase, 1 = % increase
|
||||
tag.setLong("UUIDMost", uuid.getMostSignificantBits());
|
||||
tag.setLong("UUIDLeast", uuid.getLeastSignificantBits());
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package tconstruct.library.armor;
|
||||
public enum EnumArmorPart
|
||||
{
|
||||
|
||||
HELMET(0), CHESTPLATE(1), LEGGINGS(2), BOOTS(3);
|
||||
HELMET(0), CHEST(1), PANTS(2), SHOES(3);
|
||||
|
||||
private final int partID;
|
||||
|
||||
|
||||
@@ -493,6 +493,15 @@ public class ToolBuilder
|
||||
|
||||
public static void registerToolMod (ToolMod mod)
|
||||
{
|
||||
if (mod == null)
|
||||
throw new NullPointerException("Tool modifier cannot be null.");
|
||||
instance.toolMods.add(mod);
|
||||
}
|
||||
|
||||
public static void registerArmorMod(ArmorMod mod)
|
||||
{
|
||||
if (mod == null)
|
||||
throw new NullPointerException("Armor modifier cannot be null.");
|
||||
instance.armorMods.add(mod);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package tconstruct.modifiers.armor;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
public class AModMoveSpeed extends ArmorModTypeFilter
|
||||
{
|
||||
final boolean modifierType;
|
||||
|
||||
public AModMoveSpeed(int effect, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items, int[] values, boolean type)
|
||||
{
|
||||
super(effect, "ExoSpeed" + (type ? "Percent" : "Flat"), armorTypes, items, values);
|
||||
this.modifierType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(getTagName());
|
||||
int amount = matchingAmount(input);
|
||||
return tags.getInteger("Modifiers") >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack armor)
|
||||
{
|
||||
NBTTagCompound baseTag = armor.getTagCompound();
|
||||
NBTTagCompound armorTag = armor.getTagCompound().getCompoundTag(getTagName());
|
||||
|
||||
int amount = matchingAmount(input);
|
||||
int modifiers = armorTag.getInteger("Modifiers");
|
||||
modifiers -= amount;
|
||||
armorTag.setInteger("Modifiers", modifiers);
|
||||
|
||||
if (armorTag.hasKey(key))
|
||||
{
|
||||
amount += armorTag.getInteger(key);
|
||||
}
|
||||
armorTag.setInteger(key, amount);
|
||||
|
||||
NBTTagList attributes;
|
||||
if (baseTag.hasKey("AttributeModifiers"))
|
||||
{
|
||||
attributes = baseTag.getTagList("AttributeModifiers");
|
||||
for (int iter = 0; iter < attributes.tagCount(); iter++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) attributes.tagAt(iter);
|
||||
if (tag.getString("AttributeName").equals(key))
|
||||
attributes.removeTag(iter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes = new NBTTagList();
|
||||
baseTag.setTag("AttributeModifiers", attributes);
|
||||
}
|
||||
attributes.appendTag(getAttributeTag("generic.movementSpeed", key, amount / 100d, modifierType, getUUIDFromItem(armor)));
|
||||
}
|
||||
|
||||
private static final UUID head = UUID.fromString("2ba6c8ae-4a19-49c6-aab4-ca3a5eb7c730");
|
||||
private static final UUID chest = UUID.fromString("2ba6c8ae-4a19-49c6-aab4-ca3a5eb7c731");
|
||||
private static final UUID pants = UUID.fromString("2ba6c8ae-4a19-49c6-aab4-ca3a5eb7c732");
|
||||
private static final UUID shoes = UUID.fromString("2ba6c8ae-4a19-49c6-aab4-ca3a5eb7c733");
|
||||
|
||||
UUID getUUIDFromItem (ItemStack stack)
|
||||
{
|
||||
ArmorCore item = (ArmorCore) stack.getItem();
|
||||
switch (item.armorPart)
|
||||
{
|
||||
case HELMET:
|
||||
return head;
|
||||
case CHEST:
|
||||
return chest;
|
||||
case PANTS:
|
||||
return pants;
|
||||
case SHOES:
|
||||
return shoes;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package tconstruct.modifiers.armor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.armor.ArmorMod;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
{
|
||||
public final List<Integer> increase;
|
||||
|
||||
public ArmorModTypeFilter(int effect, String dataKey, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, dataKey, armorTypes, items);
|
||||
assert items.length == values.length : "Itemstacks and their values for armor modifiers must be the same length";
|
||||
this.increase = new ArrayList<Integer>();
|
||||
for (int i = 0; i < values.length; i++)
|
||||
{
|
||||
increase.add(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks to see if the inputs match the stored items
|
||||
* Note: Filters types, doesn't care about amount
|
||||
*
|
||||
* @param input The ItemStacks to compare against
|
||||
* @param tool Item to modify, used for restrictions
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
if (!canModify(tool, input))
|
||||
return false;
|
||||
|
||||
boolean minimumMatch = false;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
|
||||
boolean match = false;
|
||||
for (Object check : stacks)
|
||||
{
|
||||
ItemStack stack = (ItemStack) check;
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
return false;
|
||||
|
||||
minimumMatch = true;
|
||||
}
|
||||
return minimumMatch;
|
||||
}
|
||||
|
||||
public int matchingAmount (ItemStack[] input)
|
||||
{
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
for (int iter = 0; iter < stacks.size(); iter++)
|
||||
{
|
||||
ItemStack stack = (ItemStack) stacks.get(iter);
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
/** Adds a new itemstack to the list for increases
|
||||
*
|
||||
* @param stack ItemStack to compare against
|
||||
* @param amount Amount to increase
|
||||
*/
|
||||
public void addStackToMatchList (ItemStack stack, int amount)
|
||||
{
|
||||
if (stack == null)
|
||||
throw new NullPointerException("ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
stacks.add(stack);
|
||||
increase.add(amount);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
public abstract class ToolModTypeFilter extends ToolMod//boobs.java
|
||||
public abstract class ToolModTypeFilter extends ToolMod
|
||||
{
|
||||
public final List<Integer> increase;
|
||||
|
||||
|
||||
Reference in new issue
Block a user