mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-26 15:03:01 +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
@@ -88,7 +88,7 @@ public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "throwing", "ammo"};
|
||||
return new String[] {"weapon", "throwing", "ammo", "windup"};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -157,4 +157,9 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
|
||||
return super.getDefaultColor(renderPass, materialID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "ranged", "bow", "windup"};
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ModRedstone extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 50;
|
||||
public String tooltipName;
|
||||
public int max = 50;
|
||||
|
||||
public ModRedstone(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
@@ -111,13 +111,6 @@ public class ModRedstone extends ItemModTypeFilter
|
||||
tags.setInteger(type[i], speed);
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.hasKey("DrawSpeed"))
|
||||
{
|
||||
int baseDrawSpeed = tags.getInteger("BaseDrawSpeed");
|
||||
int drawSpeed = (int) (baseDrawSpeed - (0.1f * baseDrawSpeed * (keyPair[0] / 50f)));
|
||||
tags.setInteger("DrawSpeed", drawSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
@@ -136,6 +129,10 @@ public class ModRedstone extends ItemModTypeFilter
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.getTraits());
|
||||
return list.contains("harvest") || list.contains("utility") || list.contains("bow");
|
||||
|
||||
// handled by the windup modifier
|
||||
if(list.contains("windup"))
|
||||
return false;
|
||||
return list.contains("harvest") || list.contains("utility");
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
|
||||
df.setRoundingMode(RoundingMode.DOWN);
|
||||
int drawSpeed = tags.getInteger("DrawSpeed");
|
||||
float flightSpeed = tags.getFloat("FlightSpeed");
|
||||
float trueDraw = drawSpeed / 20f * flightSpeed;
|
||||
float trueDraw = drawSpeed / 20f;
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation6") + df.format(trueDraw) + "s", x, base + offset * 10, 0xffffff);
|
||||
offset++;
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation7") + df.format(flightSpeed) + "x", x, base + offset * 10, 0xffffff);
|
||||
|
||||
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import mantle.pulsar.pulse.Handler;
|
||||
import mantle.pulsar.pulse.Pulse;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -23,6 +24,7 @@ import tconstruct.library.tools.DynamicToolPart;
|
||||
import tconstruct.library.tools.FletchlingLeafMaterial;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.modifiers.tools.ModWindup;
|
||||
import tconstruct.smeltery.TinkerSmeltery;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.items.Bowstring;
|
||||
@@ -96,6 +98,10 @@ public class TinkerWeaponry {
|
||||
addWeaponRecipies();
|
||||
registerBoltCasting();
|
||||
setupCreativeTab();
|
||||
|
||||
ItemStack redstoneItem = new ItemStack(Items.redstone);
|
||||
ItemStack redstoneBlock = new ItemStack(Blocks.redstone_block);
|
||||
ModifyBuilder.registerModifier(new ModWindup(2, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }));
|
||||
}
|
||||
|
||||
@Handler
|
||||
|
||||
@@ -137,6 +137,7 @@ public class WeaponryHandler {
|
||||
}*/
|
||||
|
||||
tags.setInteger("DrawSpeed", drawSpeed);
|
||||
tags.setInteger("BaseDrawSpeed", drawSpeed); // used to calculate correct speed increase with redstone modifier
|
||||
tags.setFloat("FlightSpeed", flightSpeed);
|
||||
}
|
||||
|
||||
|
||||
@@ -402,7 +402,7 @@ public class Crossbow extends ProjectileWeapon {
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "ranged", "crossbow"};
|
||||
return new String[] {"weapon", "ranged", "crossbow", "windup"};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -123,9 +123,4 @@ public class LongBow extends BowBaseAmmo {
|
||||
public Item getExtraItem() {
|
||||
return TinkerTools.largePlate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "ranged", "bow"};
|
||||
}
|
||||
}
|
||||
@@ -105,9 +105,4 @@ public class ShortBow extends BowBaseAmmo {
|
||||
{
|
||||
return TinkerWeaponry.partBowLimb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "ranged", "bow"};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user