mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 17:04:24 +00:00
Redstone-Modifier for bows and similar!
This commit is contained in:
1 parent
72dcd8ac5f
commit
3427ed6208
10 files changed
+104
-23
No files matched your search
@@ -0,0 +1,82 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ModWindup extends ModRedstone {
|
||||
public ModWindup(int effect, ItemStack[] items, int[] values) {
|
||||
super(effect, items, values);
|
||||
}
|
||||
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.getTraits());
|
||||
return list.contains("windup");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify(ItemStack tool, ItemStack[] input) {
|
||||
if(!super.canModify(tool, input))
|
||||
return false;
|
||||
|
||||
float drawSSpeed = tool.getTagCompound().getCompoundTag("InfiTool").getFloat("DrawSpeed");
|
||||
return drawSSpeed > 0.25f * 20f; // can't get below 1/4s
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int[] keyPair;
|
||||
int increase = matchingAmount(input);
|
||||
int current = 0;
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
keyPair = tags.getIntArray(key);
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
current = keyPair[0];
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a74Redstone (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
keyPair = new int[] { increase, max, tooltipIndex };
|
||||
current = keyPair[0];
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
|
||||
// 0.005 reduction per second, numbers are in ticks -> 0.10 == 0.005s
|
||||
float boost = 0.10f * current;
|
||||
// with added bonus for multiple modifiers of redstone
|
||||
// so every 50 redstone you get a bonus speed
|
||||
for(int i = 0; i < current/50; i++)
|
||||
boost += 2.0f;
|
||||
|
||||
int baseDrawSpeed = tags.getInteger("BaseDrawSpeed");
|
||||
int drawSpeed = baseDrawSpeed - (int)boost;
|
||||
tags.setInteger("DrawSpeed", drawSpeed);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user