Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package com.fouristhenumber.utilitiesinexcess.compat.tinkers;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;

import org.jetbrains.annotations.NotNull;

import com.fouristhenumber.utilitiesinexcess.config.OtherConfig;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.ToolCraftEvent;
import tconstruct.library.tools.ToolCore;
import tconstruct.weaponry.ammo.ArrowAmmo;
import tconstruct.weaponry.ammo.BoltAmmo;
import tconstruct.weaponry.weapons.Crossbow;
import tconstruct.weaponry.weapons.LongBow;
import tconstruct.weaponry.weapons.ShortBow;

public class TinkersCompat {

Expand All @@ -21,21 +32,21 @@ public static void init() {
@SuppressWarnings("unused")
public static class Events {

private static final String[] components = new String[] { "Head", "Handle", "Accessory", "Extra" };

@SubscribeEvent
public void craftTool(ToolCraftEvent.NormalTool event) {
NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool");

for (String component : components) {
List<String> componentNames = getComponentNames(event.tool);

for (String component : componentNames) {
if (toolTag.getInteger(component) == OtherConfig.bedrockiumTinkersID) {
toolTag.setBoolean("Heavy", true);
break;
}
}

boolean allInverted = true;
for (String component : components) {
for (String component : componentNames) {
if (toolTag.hasKey(component) && toolTag.getInteger(component) != OtherConfig.invertedTinkersID) {
allInverted = false;
break;
Expand All @@ -44,16 +55,43 @@ public void craftTool(ToolCraftEvent.NormalTool event) {
if (allInverted) toolTag.setInteger("Unbreaking", 10);

boolean allMagicWood = true;
for (String component : components) {
if (toolTag.hasKey(component) && toolTag.getInteger(component) != OtherConfig.magicalWoodTinkersID) {
allMagicWood = false;
break;
int bonusMods = 0;
for (String component : componentNames) {
if (toolTag.hasKey(component)) {
if (toolTag.getInteger(component) != OtherConfig.magicalWoodTinkersID) {
allMagicWood = false;
} else bonusMods++;
}
}
if (allMagicWood) {
toolTag.setInteger("Modifiers", toolTag.getInteger("Modifiers") + 8);
toolTag.setBoolean("MagicallyModifiable", true);
} else {
toolTag.setInteger("Modifiers", toolTag.getInteger("Modifiers") + bonusMods);
}
}
}

// This hardcoded nonsense accounts for the way tools work in ticon. We need to not check the Accessory
// or Handle for arrows, because those can never be made from our materials. We need to not check Accessory
// for Crossbows (that's the bowstring) for the same reason, and Handle for Long and Short Bows (their
// bowstrings). Lastly, we have to not check the Head or Accessory for Crossbow Bolts. Tinker's API doesn't expose
// the information needed to do this more cleanly.
private static @NotNull List<String> getComponentNames(ToolCore tool) {
List<String> componentNames = new ArrayList<>();

componentNames.add("Extra");
if (!(tool instanceof BoltAmmo)) {
componentNames.add("Head");
}
if (!(tool instanceof ArrowAmmo)) {
if (!(tool instanceof Crossbow) && !(tool instanceof BoltAmmo)) {
componentNames.add("Accessory");
}
if (!(tool instanceof LongBow) && !(tool instanceof ShortBow)) {
componentNames.add("Handle");
}
}
return componentNames;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ uie.nei.infopage.chandelier.1=A torch that prevents natural mob spawning in rang
uie.nei.infopage.giga_torch.1=A torch that prevents natural mob spawning in range. Spawners are not affected.
uie.nei.infopage.trading_post.1=This block allows you to trade with every villager in 32 block area all in one place! Simply click on a trade from the list to trade.
uie.nei.infopage.ticon_inverted=If a Tinker's Construct tool is made using entirely inverted parts, it becomes unbreakable.
uie.nei.infopage.ticon_magic_wood=If a Tinker's Construct tool is made using entirely magical wooden parts, it gains 8 additional modifiers.
uie.nei.infopage.ticon_magic_wood=Tinker's Construct tools made using magical wooden parts gain an extra modifier per part. If the entire tool is made using magical wooden parts, it gains a flat 8 modifiers instead!
uie.nei.infopage.ticon_bedrockium=Tinker's Construct tools made with a bedrockium part are heavy and slow the wielder down while held.
uie.nei.infopage.true_greenscreen.0=When you take a screenshot of this block (with [§bF2§0]), it will appear completely transparent in the image, allowing you to take pictures of things without needing to remove the background later.
uie.nei.infopage.true_greenscreen.1=You may need to disable your HUD (with [§bF1§0] by default) before taking a screenshot.\nThis block is a tile entity with intrusive rendering, please remove it when you're done using it.
Expand Down