mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Javelins now can be used properly as melee and ranged weapons
This commit is contained in:
1 parent
62904b92dc
commit
9d7d33fea3
4 files changed
+44
-2
No files matched your search
@@ -106,6 +106,8 @@ public class TinkerWeaponry {
|
||||
ItemStack redstoneBlock = new ItemStack(Blocks.redstone_block);
|
||||
ModifyBuilder.registerModifier(new ModWindup(2, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }));
|
||||
ModifyBuilder.registerModifier(new ModAmmoRestock());
|
||||
|
||||
TConstructRegistry.registerActiveToolMod(new WeaponryActiveToolMod());
|
||||
}
|
||||
|
||||
@Handler
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package tconstruct.weaponry;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
|
||||
public class WeaponryActiveToolMod extends ActiveToolMod {
|
||||
@Override
|
||||
public boolean damageTool(ItemStack stack, int damage, EntityLivingBase entity) {
|
||||
if(stack.getItem() == TinkerWeaponry.javelin && stack.hasTagCompound()) {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
IAmmo ammo =(IAmmo)stack.getItem();
|
||||
if(tags.getInteger("Damage") == 0)
|
||||
{
|
||||
int rem = ammo.consumeAmmo(1, stack);
|
||||
if(rem > 0)
|
||||
return true;
|
||||
}
|
||||
else if(ammo.getAmmoCount(stack) > 0)
|
||||
{
|
||||
int d = tags.getInteger("Damage") + damage;
|
||||
int max = tags.getInteger("TotalDurability");
|
||||
if(d > max)
|
||||
{
|
||||
tags.setInteger("Damage", 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class Javelin extends AmmoWeapon {
|
||||
case 0:
|
||||
return "_javelin_head";
|
||||
case 1:
|
||||
return ""; // no broken, since it runs out of ammo
|
||||
return "_javelin_head_broken"; // no broken, since it runs out of ammo
|
||||
case 2:
|
||||
return "_javelin_handle";
|
||||
case 3:
|
||||
@@ -145,7 +145,12 @@ public class Javelin extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
public float getAmmoModifier() {
|
||||
return 0.02f;
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDurabilityModifier() {
|
||||
return 0.1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user