Skip to content

Commit

Permalink
Add armor modifiers rendering in books.
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Sep 9, 2014
1 parent 1e44b11 commit 26de0a4
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 24 deletions.
17 changes: 11 additions & 6 deletions resources/assets/tinker/manuals/firstday.xml
Expand Up @@ -291,9 +291,12 @@ Type: Single-use
Stackable: yes</text>
</page>

<page type="modifier">
<tooltype>travelwings</tooltype>
<recipe>featherfall</recipe>
<page type="crafting">
<text>Tool Station + Forge</text>
<recipe>
<name>featherfall</name>
<size>three</size>
</recipe>
</page>

<page type="sectionpage">
Expand Down Expand Up @@ -363,7 +366,7 @@ Stackable: yes</text>

<page type="modifier">
<tooltype>travelglove</tooltype>
<recipe>redstonemod</recipe>
<recipe>glovehaste</recipe>
</page>

<page type="sectionpage">
Expand All @@ -373,14 +376,15 @@ Stackable: yes</text>
Effects:
- The tool slowly repairs itself
- Sunlight speeds up the process
- Can be applied to all travellers gear

Type: Single-use
Stackable: yes</text>
</page>

<page type="modifier">
<tooltype>travelmulti</tooltype>
<recipe>mossmod</recipe>
<recipe>moss</recipe>
</page>

<page type="sectionpage">
Expand All @@ -389,14 +393,15 @@ Stackable: yes</text>

Effects:
- Jump during jumping to jump
- Can be applied to wings as well

Type: Single-use
Stackable: yes</text>
</page>

<page type="modifier">
<tooltype>travelmulti</tooltype>
<recipe>mossmod</recipe>
<recipe>doublejump</recipe>
</page>

</book>
Binary file modified resources/assets/tinker/textures/gui/bookmodify.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 14 additions & 9 deletions src/main/java/tconstruct/armor/ArmorProxyClient.java
Expand Up @@ -33,6 +33,7 @@
import tconstruct.library.accessory.IAccessoryModel;
import tconstruct.library.client.TConstructClientRegistry;
import tconstruct.library.crafting.ModifyBuilder;
import tconstruct.tools.TinkerTools;
import tconstruct.world.TinkerWorld;

public class ArmorProxyClient extends ArmorProxyCommon
Expand Down Expand Up @@ -72,22 +73,19 @@ private void registerManualRecipes ()
ItemStack feather = new ItemStack(Items.feather);
ItemStack redstone = new ItemStack(Items.redstone);
ItemStack goggles = TinkerArmor.travelGoggles.getDefaultItem();
//MantleClientRegistry.registerManualSmallRecipe("nightvision", goggles.copy(), new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.golden_carrot), null);
ItemStack g2 = goggles.copy();

g2 = ModifyBuilder.instance.modifyItem(g2, new ItemStack[] { new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.golden_carrot)});
MantleClientRegistry.registerManualSmallRecipe("nightvision", g2, new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 8198), new ItemStack(Items.golden_carrot), null);
TConstructClientRegistry.registerManualModifier("nightvision", goggles.copy(), new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 8198), new ItemStack(Items.golden_carrot), null);

ItemStack vest = TinkerArmor.travelVest.getDefaultItem();
MantleClientRegistry.registerManualSmallRecipe("dodge", vest.copy(), new ItemStack(Items.ender_eye), new ItemStack(Items.ender_pearl), new ItemStack(Items.sugar), null);
MantleClientRegistry.registerManualSmallRecipe("stealth", vest.copy(), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.golden_carrot));
TConstructClientRegistry.registerManualModifier("dodge", vest.copy(), new ItemStack(Items.ender_eye), new ItemStack(Items.ender_pearl), new ItemStack(Items.sugar), null);
TConstructClientRegistry.registerManualModifier("stealth", vest.copy(), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.golden_carrot));

ItemStack wings = new ItemStack(TinkerArmor.travelWings);
MantleClientRegistry.registerManualSmallRecipe("doublejump", wings.copy(), new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 0), new ItemStack(Blocks.piston), null);
ItemStack wings = TinkerArmor.travelWings.getDefaultItem();
TConstructClientRegistry.registerManualModifier("doublejumpwings", wings.copy(), new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 0), new ItemStack(Blocks.piston), null);
MantleClientRegistry.registerManualLargeRecipe("featherfall", wings.copy(), new ItemStack(TinkerWorld.slimeGel, 1, 0), feather, feather, feather, wings.copy(), feather, feather, new ItemStack(Items.ender_pearl), feather);

ItemStack boots = TinkerArmor.travelBoots.getDefaultItem();
MantleClientRegistry.registerManualSmallRecipe("doublejumpboots", boots.copy(), new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 1), new ItemStack(Blocks.piston), null);
TConstructClientRegistry.registerManualModifier("doublejumpboots", boots.copy(), new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 1), new ItemStack(Blocks.piston), null);
TConstructClientRegistry.registerManualModifier("waterwalk", boots.copy(), new ItemStack(Blocks.waterlily), new ItemStack(Blocks.waterlily));
TConstructClientRegistry.registerManualModifier("leadboots", boots.copy(), new ItemStack(Blocks.iron_block));
TConstructClientRegistry.registerManualModifier("slimysoles", boots.copy(), new ItemStack(TinkerWorld.slimePad, 1, 0), new ItemStack(TinkerWorld.slimePad, 1, 0));
Expand All @@ -96,6 +94,13 @@ private void registerManualRecipes ()
TConstructClientRegistry.registerManualModifier("glovehaste", gloves.copy(), redstone, new ItemStack(Blocks.redstone_block));
//MantleClientRegistry.registerManualSmallRecipe("gloveclimb", gloves.copy(), new ItemStack(Items.slime_ball), new ItemStack(Blocks.web), new ItemStack(TinkerTools.materials, 1, 25), null);
TConstructClientRegistry.registerManualModifier("gloveknuckles", gloves.copy(), new ItemStack(Items.quartz), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE));

// moss
ItemStack moss = new ItemStack(TinkerTools.materials, 1, 6);
TConstructClientRegistry.registerManualModifier("mossgoggles", goggles.copy(), moss.copy());
TConstructClientRegistry.registerManualModifier("mossvest", vest.copy(), moss.copy());
TConstructClientRegistry.registerManualModifier("mosswings", wings.copy(), moss.copy());
TConstructClientRegistry.registerManualModifier("mossboots", boots.copy(), moss.copy());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/armor/TinkerArmor.java
Expand Up @@ -226,7 +226,7 @@ private void registerModifiers ()
TConstructRegistry.registerActiveArmorMod(new ActiveTinkerArmor());

//Head
ModifyBuilder.registerModifier(new AModBoolean(0, "Night Vision", EnumSet.of(ArmorPart.Head), new ItemStack[] { new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.golden_carrot) }, "\u00a78", "Night Vision"));
ModifyBuilder.registerModifier(new AModBoolean(0, "Night Vision", EnumSet.of(ArmorPart.Head), new ItemStack[] { new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 8198), new ItemStack(Items.golden_carrot) }, "\u00a78", "Night Vision"));

//Chest
ModifyBuilder.registerModifier(new AModInteger(0, "Perfect Dodge", EnumSet.of(ArmorPart.Chest), new ItemStack[] { new ItemStack(Items.ender_eye), new ItemStack(Items.ender_pearl), new ItemStack(Items.sugar) }, 1, "\u00a7d", "Perfect Dodge"));
Expand Down
83 changes: 75 additions & 8 deletions src/main/java/tconstruct/client/pages/ModifierPage.java
Expand Up @@ -8,10 +8,18 @@
import org.lwjgl.opengl.*;
import org.w3c.dom.*;

import java.util.LinkedList;
import java.util.List;

public class ModifierPage extends BookPage
{
String type;
ItemStack[] icons;
ItemStack[][] iconsMulti;
ItemStack[] toolMulti;

long lastUpdate;
int counter;

@Override
public void readPageFromXML (Element element)
Expand All @@ -21,14 +29,45 @@ public void readPageFromXML (Element element)
type = nodes.item(0).getTextContent();

nodes = element.getElementsByTagName("recipe");
if (nodes != null)
icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent());
if (nodes != null) {
String recipe = nodes.item(0).getTextContent();
icons = MantleClientRegistry.getRecipeIcons(recipe);

if(type.equals("travelmulti"))
{
List<ItemStack[]> stacks = new LinkedList<ItemStack[]>();
List<String> tools = new LinkedList<String>();
String[] suffixes = new String[] { "goggles", "vest", "wings", "boots", "glove", "belt" };
for(String suffix : suffixes)
{
ItemStack[] icons2 = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent() + suffix);
if(icons2 != null) {
stacks.add(icons2);
tools.add(suffix);
}
}

iconsMulti = new ItemStack[stacks.size()][];
toolMulti = new ItemStack[stacks.size()];
for(int i = 0; i < stacks.size(); i++) {
iconsMulti[i] = stacks.get(i);
toolMulti[i] = MantleClientRegistry.getManualIcon("travel" + tools.get(i));
}

icons = iconsMulti[0];

lastUpdate = System.currentTimeMillis();
counter = 0;
}
}
}

@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
String tStation = new String("Tool Station");
if(icons.length > 3)
tStation = new String("Tool Forge");
if (isTranslatable)
tStation = StatCollector.translateToLocal(tStation);
manual.fonts.drawString("\u00a7n" + tStation, localWidth + 60, localHeight + 4, 0);
Expand All @@ -51,13 +90,38 @@ public void renderContentLayer (int localWidth, int localHeight, boolean isTrans
toolstack = MantleClientRegistry.getManualIcon("travelbelt");
if(type.equals("travelglove"))
toolstack = MantleClientRegistry.getManualIcon("travelglove");
if(type.equals("travelmulti"))
toolstack = toolMulti[counter];

// update displayed item
if(iconsMulti != null && iconsMulti.length > 0 && type.equals("travelmulti") && System.currentTimeMillis() - lastUpdate > 1000)
{
lastUpdate = System.currentTimeMillis();
counter++;
if(counter >= iconsMulti.length)
counter = 0;
icons = iconsMulti[counter];
toolstack = toolMulti[counter];
}

manual.renderitem.zLevel = 100;
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, toolstack, (localWidth + 54) / 2, (localHeight + 54) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 130) / 2, (localHeight + 54) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth + 18) / 2, (localHeight + 36) / 2);
if (icons[2] != null)
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[2], (localWidth + 18) / 2, (localHeight + 74) / 2);
if(icons.length < 4) {
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, toolstack, (localWidth + 54) / 2, (localHeight + 54) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 130) / 2, (localHeight + 54) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth + 18) / 2, (localHeight + 36) / 2);
if (icons[2] != null)
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[2], (localWidth + 18) / 2, (localHeight + 74) / 2);
}
else
{
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, toolstack, (localWidth + 74) / 2, (localHeight + 54) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 140) / 2, (localHeight + 54) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth - 2) / 2, (localHeight + 36) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[2], (localWidth - 2) / 2, (localHeight + 74) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[3], (localWidth + 36) / 2, (localHeight + 36) / 2);
if(icons[4] != null)
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[4], (localWidth + 36) / 2, (localHeight + 74) / 2);
}
manual.renderitem.zLevel = 0;

GL11.glScalef(0.5F, 0.5F, 0.5F);
Expand All @@ -71,6 +135,9 @@ public void renderContentLayer (int localWidth, int localHeight, boolean isTrans
public void renderBackgroundLayer (int localWidth, int localHeight)
{
manual.getMC().getTextureManager().bindTexture(background);
manual.drawTexturedModalRect(localWidth + 12, localHeight + 32, 0, 0, 154, 78);
if(icons.length > 3)
manual.drawTexturedModalRect(localWidth - 7, localHeight + 32, 0, 80, 182, 78);
else
manual.drawTexturedModalRect(localWidth + 12, localHeight + 32, 0, 0, 154, 78);
}
}
Expand Up @@ -92,6 +92,22 @@ public static void registerManualModifier (String name, ItemStack output, ItemSt
MantleClientRegistry.recipeIcons.put(name, recipe);
}

public static void registerManualModifier (String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3)
{
registerManualModifier(name, output, input1, input2, input3, null);
}

public static void registerManualModifier (String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3, ItemStack input4)
{
ItemStack[] recipe = new ItemStack[5];
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] { input1, input2, input3, input4 });
recipe[1] = input1;
recipe[2] = input2;
recipe[3] = input3;
recipe[4] = input4;
MantleClientRegistry.recipeIcons.put(name, recipe);
}

public static void registerManualSmeltery (String name, ItemStack output, ItemStack liquid, ItemStack cast)
{
ItemStack[] recipe = new ItemStack[3];
Expand Down

0 comments on commit 26de0a4

Please sign in to comment.