Fix JABBA-related issues with crafting station slots (#54)

* Fix shift-merging tools voiding items

fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392>

* Change 0-sized ItemStacks into null stacks in crafting station attached slots

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425>

* Update buildscript

* spotlessApply
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-09-22 20:51:23 +02:00
1 parent 18bfeaff32
commit 39be06c23b
571 files changed
+25959 -28223

No files matched your search

@@ -2,22 +2,16 @@ package tconstruct.library.weaponry;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.StatCollector;
import tconstruct.library.TConstructRegistry;
import tconstruct.weaponry.TinkerWeaponry;
import tconstruct.util.Reference;
import mods.battlegear2.api.PlayerEventChild;
import mods.battlegear2.api.weapons.IBattlegearWeapon;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.ToolCore;
import tconstruct.tools.TinkerTools;
import mods.battlegear2.api.PlayerEventChild;
import mods.battlegear2.api.weapons.IBattlegearWeapon;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import java.util.List;
@Optional.InterfaceList({
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
@@ -30,14 +24,14 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
@Override
public int getAmmoCount(ItemStack stack) {
if(!stack.hasTagCompound()) return 0;
if (!stack.hasTagCompound()) return 0;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
return tags.getInteger("Ammo");
}
@Override
public int getMaxAmmo(ItemStack stack) {
if(!stack.hasTagCompound()) return 0;
if (!stack.hasTagCompound()) return 0;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
return getMaxAmmo(tags);
}
@@ -50,7 +44,7 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
@Override
public int addAmmo(int toAdd, ItemStack stack) {
if(!stack.hasTagCompound()) return toAdd;
if (!stack.hasTagCompound()) return toAdd;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
int oldCount = tags.getInteger("Ammo");
int newCount = Math.min(oldCount + toAdd, getMaxAmmo(stack));
@@ -60,7 +54,7 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
@Override
public int consumeAmmo(int toUse, ItemStack stack) {
if(!stack.hasTagCompound()) return toUse;
if (!stack.hasTagCompound()) return toUse;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
int oldCount = tags.getInteger("Ammo");
int newCount = Math.max(oldCount - toUse, 0);
@@ -70,42 +64,39 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
@Override
public void setAmmo(int count, ItemStack stack) {
if(!stack.hasTagCompound()) return;
if (!stack.hasTagCompound()) return;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
tags.setInteger("Ammo", count);
}
public float getAmmoModifier() { return 0.1f; }
public float getAmmoModifier() {
return 0.1f;
}
public boolean pickupAmmo(ItemStack stack, ItemStack candidate, EntityPlayer player)
{
if(stack.getItem() == null || !stack.hasTagCompound() || !(stack.getItem() instanceof IAmmo))
return false;
public boolean pickupAmmo(ItemStack stack, ItemStack candidate, EntityPlayer player) {
if (stack.getItem() == null || !stack.hasTagCompound() || !(stack.getItem() instanceof IAmmo)) return false;
// check if our candidate fits
if(candidate != null)
{
if (candidate != null) {
// same item
if(testIfAmmoMatches(stack, candidate)) {
if (testIfAmmoMatches(stack, candidate)) {
IAmmo pickedup = ((IAmmo) stack.getItem());
IAmmo ininventory = ((IAmmo) candidate.getItem());
// we can be sure that it's ammo, since stack is ammo and they're equal
int count = pickedup.getAmmoCount(stack);
if(count != ininventory.addAmmo(count, candidate))
return true;
if (count != ininventory.addAmmo(count, candidate)) return true;
}
}
// search the players inventory
for(ItemStack invItem : player.inventory.mainInventory) {
for (ItemStack invItem : player.inventory.mainInventory) {
if (testIfAmmoMatches(stack, invItem)) {
IAmmo pickedup = ((IAmmo) stack.getItem());
IAmmo ininventory = ((IAmmo) invItem.getItem());
// we can be sure that it's ammo, since stack is ammo and they're equal
int count = pickedup.getAmmoCount(stack);
if(count != ininventory.addAmmo(count, invItem))
return true;
if (count != ininventory.addAmmo(count, invItem)) return true;
}
}
@@ -113,15 +104,11 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
return false;
}
private boolean testIfAmmoMatches(ItemStack reference, ItemStack candidate)
{
if(candidate == null)
return false;
if(!candidate.hasTagCompound() || !candidate.getTagCompound().hasKey("InfiTool"))
return false;
private boolean testIfAmmoMatches(ItemStack reference, ItemStack candidate) {
if (candidate == null) return false;
if (!candidate.hasTagCompound() || !candidate.getTagCompound().hasKey("InfiTool")) return false;
if(reference.getItem() != candidate.getItem())
return false;
if (reference.getItem() != candidate.getItem()) return false;
NBTTagCompound referenceTags = getComparisonTags(reference);
NBTTagCompound testTags = getComparisonTags(candidate);
@@ -151,22 +138,18 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
}
private void copyTag(NBTTagCompound out, NBTTagCompound in, String tag) {
if(in.hasKey(tag))
out.setInteger(tag, in.getInteger(tag));
if (in.hasKey(tag)) out.setInteger(tag, in.getInteger(tag));
}
@Override
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
{
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
// ammo doesn't hurt on smacking stuff with it
return false;
}
@Override
@Optional.Method(modid = "battlegear2")
public boolean sheatheOnBack(ItemStack item)
{
public boolean sheatheOnBack(ItemStack item) {
return true;
}
@@ -178,7 +161,8 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
@Override
@Optional.Method(modid = "battlegear2")
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
public boolean offhandAttackEntity(
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
event.cancelParent = false;
event.swingOffhand = false;
event.shouldAttack = false;
@@ -195,7 +179,7 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
@Override
@Optional.Method(modid = "battlegear2")
public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
event.setCanceled(false);
event.setCanceled(false);
return false;
}
@@ -208,9 +192,10 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
@Override
@Optional.Method(modid = "battlegear2")
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
if(offhand == null)
return true;
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
if (offhand == null) return true;
return (mainhand != null
&& mainhand.getItem() != TinkerTools.cleaver
&& mainhand.getItem() != TinkerTools.battleaxe)
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
}
}
@@ -1,18 +1,19 @@
package tconstruct.library.weaponry;
import cpw.mods.fml.common.Optional;
import tconstruct.weaponry.client.CrosshairType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mods.battlegear2.api.PlayerEventChild;
import mods.battlegear2.api.weapons.IBattlegearWeapon;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import tconstruct.tools.TinkerTools;
import mods.battlegear2.api.PlayerEventChild;
import mods.battlegear2.api.weapons.IBattlegearWeapon;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import tconstruct.tools.TinkerTools;
import tconstruct.weaponry.client.CrosshairType;
@Optional.InterfaceList({
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
})
@@ -36,16 +37,23 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
}
@Override
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
{
if(getAmmoCount(stack) > 0)
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (getAmmoCount(stack) > 0) player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
return stack;
}
@Override
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
{
public boolean onItemUse(
ItemStack stack,
EntityPlayer player,
World world,
int x,
int y,
int z,
int side,
float clickX,
float clickY,
float clickZ) {
return false;
}
@@ -53,43 +61,43 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
* How long it takes to "ready" the weapon. To reach the point, where holding the right mouse button any longer doesn't have an impact.
*/
@Override
public int getWindupTime(ItemStack itemStack) { return 0; }
public int getWindupTime(ItemStack itemStack) {
return 0;
}
@Override
public float getMinWindupProgress(ItemStack itemStack) {
return 0;
}
public float getWindupProgress(ItemStack itemStack, int timeInUse)
{
public float getWindupProgress(ItemStack itemStack, int timeInUse) {
float time = (float) timeInUse;
float windup = getWindupTime(itemStack);
if(time > windup)
time = windup;
if (time > windup) time = windup;
return time/windup;
return time / windup;
}
public float minAccuracy(ItemStack itemStack) {
return 0.5f;
}
public float minAccuracy(ItemStack itemStack) { return 0.5f; }
public float maxAccuracy(ItemStack itemStack) { return 0.5f; }
public float maxAccuracy(ItemStack itemStack) {
return 0.5f;
}
@SideOnly(Side.CLIENT)
public float getWindupProgress(ItemStack itemStack, EntityPlayer player)
{
public float getWindupProgress(ItemStack itemStack, EntityPlayer player) {
// what are you doing!
if(player.inventory.getCurrentItem() != itemStack)
return 0f;
if (player.inventory.getCurrentItem() != itemStack) return 0f;
// are we using it?
if(player.getItemInUse() == null)
return 0f;
if (player.getItemInUse() == null) return 0f;
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
}
public float getAccuracy(ItemStack itemStack, int time)
{
public float getAccuracy(ItemStack itemStack, int time) {
float dif = minAccuracy(itemStack) - maxAccuracy(itemStack);
return minAccuracy(itemStack) - dif * getWindupProgress(itemStack, time);
@@ -103,34 +111,35 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int durationLeft) {
int time = this.getMaxItemUseDuration(stack) - durationLeft;
if(getWindupProgress(stack, time) >= getMinWindupProgress(stack))
launchProjectile(stack, world, player, time);
if (getWindupProgress(stack, time) >= getMinWindupProgress(stack)) launchProjectile(stack, world, player, time);
}
protected void launchProjectile(ItemStack stack, World world, EntityPlayer player, int time) {
// spawn projectile on server
if(!world.isRemote) {
if (!world.isRemote) {
ItemStack reference = stack.copy();
reference.stackSize = 1;
((IAmmo)reference.getItem()).setAmmo(1, reference);
((IAmmo) reference.getItem()).setAmmo(1, reference);
Entity projectile = createProjectile(reference, world, player, getAccuracy(stack, time), time);
world.spawnEntityInWorld(projectile);
}
// reduce ammo
if(!player.capabilities.isCreativeMode)
this.consumeAmmo(1, stack);
if (!player.capabilities.isCreativeMode) this.consumeAmmo(1, stack);
}
protected abstract Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, int time);
protected abstract Entity createProjectile(
ItemStack reference, World world, EntityPlayer player, float accuracy, int time);
/** used for displaying the damage, return the value used for pseed in createProjectile/ProjectileBase constructor
*/
public abstract float getProjectileSpeed();
@SideOnly(Side.CLIENT)
public CrosshairType getCrosshairType() { return CrosshairType.SQUARE; }
public CrosshairType getCrosshairType() {
return CrosshairType.SQUARE;
}
@Override
public boolean zoomOnWindup(ItemStack itemStack) {
@@ -146,8 +155,7 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
@Override
@Optional.Method(modid = "battlegear2")
public boolean sheatheOnBack(ItemStack item)
{
public boolean sheatheOnBack(ItemStack item) {
return true;
}
@@ -159,7 +167,8 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
@Override
@Optional.Method(modid = "battlegear2")
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
public boolean offhandAttackEntity(
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
return true;
}
@@ -185,9 +194,10 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
@Override
@Optional.Method(modid = "battlegear2")
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
if(offhand == null)
return true;
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
if (offhand == null) return true;
return (mainhand != null
&& mainhand.getItem() != TinkerTools.cleaver
&& mainhand.getItem() != TinkerTools.battleaxe)
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
}
}
@@ -1,29 +1,45 @@
package tconstruct.library.weaponry;
import tconstruct.weaponry.TinkerWeaponry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import tconstruct.library.tools.CustomMaterial;
import tconstruct.weaponry.TinkerWeaponry;
public class ArrowShaftMaterial extends CustomMaterial {
public final float durabilityModifier; // like the durability modifier of handles, but for arrows!
public final float fragility; // 1.0 = breaks 100%, 0.0 = never breaks
public final float weight; // baseline: 1.0 = default, smaller = lighter, higher = heavier
public ArrowShaftMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float durabilityModifier, float weight, float fragility, int color) {
public ArrowShaftMaterial(
int materialID,
int value,
ItemStack input,
ItemStack craftingItem,
float durabilityModifier,
float weight,
float fragility,
int color) {
super(materialID, value, input, craftingItem, color);
this.durabilityModifier = durabilityModifier;
this.fragility = fragility;
this.weight = weight;
}
public static ArrowShaftMaterial createMaterial(int id, Item input, float durabilityModifier, float weight, float fragility, int color)
{
public static ArrowShaftMaterial createMaterial(
int id, Item input, float durabilityModifier, float weight, float fragility, int color) {
return createMaterial(id, input, 0, durabilityModifier, weight, fragility, color);
}
public static ArrowShaftMaterial createMaterial(int id, Item input, int inputMeta, float durabilityModifier, float weight, float fragility, int color)
{
return new ArrowShaftMaterial(id, 2, new ItemStack(input, 1, inputMeta), new ItemStack(TinkerWeaponry.partArrowShaft, 0, id), durabilityModifier, weight, fragility, color);
public static ArrowShaftMaterial createMaterial(
int id, Item input, int inputMeta, float durabilityModifier, float weight, float fragility, int color) {
return new ArrowShaftMaterial(
id,
2,
new ItemStack(input, 1, inputMeta),
new ItemStack(TinkerWeaponry.partArrowShaft, 0, id),
durabilityModifier,
weight,
fragility,
color);
}
}
@@ -1,10 +1,8 @@
package tconstruct.library.weaponry;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.BowstringMaterial;
import tconstruct.library.tools.CustomMaterial;
import tconstruct.weaponry.ammo.ArrowAmmo;
import tconstruct.weaponry.entity.ArrowEntity;
import cpw.mods.fml.common.Loader;
import java.util.List;
import mods.battlegear2.api.core.InventoryPlayerBattle;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
@@ -14,11 +12,12 @@ import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.ToolBuilder;
import cpw.mods.fml.common.Loader;
import mods.battlegear2.api.core.InventoryPlayerBattle;
import java.util.List;
import tconstruct.library.tools.BowstringMaterial;
import tconstruct.library.tools.CustomMaterial;
import tconstruct.weaponry.ammo.ArrowAmmo;
import tconstruct.weaponry.entity.ArrowEntity;
public abstract class BowBaseAmmo extends ProjectileWeapon {
public BowBaseAmmo(int baseDamage, String name) {
@@ -56,13 +55,11 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
}
@Override
public ItemStack searchForAmmo(EntityPlayer player, ItemStack weapon)
{
public ItemStack searchForAmmo(EntityPlayer player, ItemStack weapon) {
// arrow priority: hotbar > inventory, tinker arrows > regular arrows
if(Loader.isModLoaded("battlegear2")){
if (Loader.isModLoaded("battlegear2")) {
ItemStack offhand = ((InventoryPlayerBattle) player.inventory).getCurrentOffhandWeapon();
if(offhand != null && (checkTinkerArrow(offhand) || checkVanillaArrow(offhand)))
{
if (offhand != null && (checkTinkerArrow(offhand) || checkVanillaArrow(offhand))) {
return offhand;
}
}
@@ -70,103 +67,90 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
ItemStack[] inventory = player.inventory.mainInventory;
// check hotbar for tinker arrows
for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
if(checkTinkerArrow(inventory[i]))
return inventory[i];
for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
if (checkTinkerArrow(inventory[i])) return inventory[i];
// check hotbar for vanilla arrows
for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
if(checkVanillaArrow(inventory[i]))
return inventory[i];
for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
if (checkVanillaArrow(inventory[i])) return inventory[i];
// check the rest of the inventory for tinker arrows
for(int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
if(checkTinkerArrow(inventory[i]))
return inventory[i];
for (int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
if (checkTinkerArrow(inventory[i])) return inventory[i];
// check the rest of the inventory for vanilla arrows
for(int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
if(checkVanillaArrow(inventory[i]))
return inventory[i];
for (int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
if (checkVanillaArrow(inventory[i])) return inventory[i];
// creative mode
if(player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, weapon) > 0)
if (player.capabilities.isCreativeMode
|| EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, weapon) > 0)
return new ItemStack(Items.arrow);
return null;
}
private boolean checkTinkerArrow(ItemStack stack)
{
private boolean checkTinkerArrow(ItemStack stack) {
// null
if(stack == null)
return false;
if (stack == null) return false;
// no tinker arrow
if(!(stack.getItem() instanceof ArrowAmmo))
return false;
if (!(stack.getItem() instanceof ArrowAmmo)) return false;
// no ammo left
if(((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0)
return false;
if (((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0) return false;
return true;
}
private boolean checkVanillaArrow(ItemStack stack)
{
private boolean checkVanillaArrow(ItemStack stack) {
// null
if(stack == null)
return false;
if (stack == null) return false;
// no arrow
if(!(stack.getItem() == Items.arrow))
return false;
if (!(stack.getItem() == Items.arrow)) return false;
// inventory shouldn't contain stacksize 0 items so we don't have to check that.
return true;
}
@Override
protected Entity createProjectile(ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
protected Entity createProjectile(
ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
EntityArrow arrow;
if(arrows.getItem() == Items.arrow) {
arrow = new EntityArrow(world, player, speed/1.5f); // vanilla arrows internally do x1.5
}
else {
if (arrows.getItem() == Items.arrow) {
arrow = new EntityArrow(world, player, speed / 1.5f); // vanilla arrows internally do x1.5
} else {
ItemStack reference = arrows.copy();
reference.stackSize = 1;
reference.getTagCompound().getCompoundTag("InfiTool").setInteger("Ammo", 1);
arrow = new ArrowEntity(world, player, speed, accuracy, reference);
}
if(player.capabilities.isCreativeMode)
arrow.canBePickedUp = 2;
if (player.capabilities.isCreativeMode) arrow.canBePickedUp = 2;
if(windup >= 1f)
arrow.setIsCritical(true);
if (windup >= 1f) arrow.setIsCritical(true);
return arrow;
}
@Override
public void playFiringSound(World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy) {
public void playFiringSound(
World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy) {
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + speed * 0.5F);
}
@Override
public void buildTool (int id, String name, List list)
{
public void buildTool(int id, String name, List list) {
// does the material have a bow material?
if(TConstructRegistry.getBowMaterial(id) == null)
return;
if (TConstructRegistry.getBowMaterial(id) == null) return;
// all creative bows use regular bowstring
ItemStack handleStack = new ItemStack(getHandleItem(), 1, 0); // regular bowstring
ItemStack accessoryStack = getPartAmount() > 2 ? new ItemStack(getAccessoryItem(), 1, id) : null;
ItemStack extraStack = getPartAmount() > 3 ? new ItemStack(getExtraItem(), 1, id) : null;
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, extraStack, "");
if (tool != null)
{
ItemStack tool = ToolBuilder.instance.buildTool(
new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, extraStack, "");
if (tool != null) {
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
list.add(tool);
}
@@ -1,10 +1,11 @@
package tconstruct.library.weaponry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IAccuracy {
public float minAccuracy(ItemStack itemStack);
public float maxAccuracy(ItemStack itemStack);
public float getAccuracy(ItemStack itemStack, int time);
}
@@ -1,8 +1,8 @@
package tconstruct.library.weaponry;
import tconstruct.weaponry.client.CrosshairType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import tconstruct.weaponry.client.CrosshairType;
/**
* This class has a windup time, meaning it takes some time to reach full potency.
@@ -10,11 +10,14 @@ import net.minecraft.item.ItemStack;
*/
public interface IWindup {
public int getWindupTime(ItemStack itemStack); // how long it takes to fully wind up
public float getWindupProgress(ItemStack itemStack, EntityPlayer player); // how far we've winded up, 0.0-1.0
public float getMinWindupProgress(ItemStack itemStack); // how long it has been winded up at least to fire (0.0-1.0)
public CrosshairType getCrosshairType();
public boolean zoomOnWindup(ItemStack itemStack);
public float getZoom(ItemStack itemStack);
}
@@ -1,9 +1,11 @@
package tconstruct.library.weaponry;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mods.battlegear2.api.PlayerEventChild;
import mods.battlegear2.api.weapons.IBattlegearWeapon;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -27,9 +29,6 @@ import tconstruct.library.util.TextureHelper;
import tconstruct.tools.TinkerTools;
import tconstruct.weaponry.TinkerWeaponry;
import tconstruct.weaponry.client.CrosshairType;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Optional.InterfaceList({
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
@@ -76,20 +75,19 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
* @param accuracy the accuracy calculated for the projectile
* @return A banana.
*/
protected abstract Entity createProjectile(ItemStack ammo, World world, EntityPlayer player, float speed, float accuracy, float windup);
protected abstract Entity createProjectile(
ItemStack ammo, World world, EntityPlayer player, float speed, float accuracy, float windup);
/* Accuracy */
public abstract float minAccuracy(ItemStack itemStack);
public abstract float maxAccuracy(ItemStack itemStack);
public float getAccuracy(ItemStack itemStack, EntityPlayer player)
{
return getAccuracy(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
public float getAccuracy(ItemStack itemStack, EntityPlayer player) {
return getAccuracy(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
}
public float getAccuracy(ItemStack itemStack, int time)
{
public float getAccuracy(ItemStack itemStack, int time) {
float dif = minAccuracy(itemStack) - maxAccuracy(itemStack);
return minAccuracy(itemStack) - dif * getWindupProgress(itemStack, time);
@@ -97,40 +95,32 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
/* Windup */
public int getWindupTime(ItemStack itemStack) {
if(itemStack == null || !itemStack.hasTagCompound())
return 1;
if (itemStack == null || !itemStack.hasTagCompound()) return 1;
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
return toolTag.getInteger("DrawSpeed");
}
public float getWindupProgress(ItemStack itemStack, EntityPlayer player)
{
public float getWindupProgress(ItemStack itemStack, EntityPlayer player) {
// what are you doing!
if(player.inventory.getCurrentItem() != itemStack)
return 0f;
if (player.inventory.getCurrentItem() != itemStack) return 0f;
// are we using it?
if(player.getItemInUse() == null)
return 0f;
if (player.getItemInUse() == null) return 0f;
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
}
public float getWindupProgress(ItemStack itemStack, int timeInUse)
{
public float getWindupProgress(ItemStack itemStack, int timeInUse) {
float time = (float) timeInUse;
float windup = getWindupTime(itemStack);
if(time > windup)
return 1.0f;
if (time > windup) return 1.0f;
return time/windup;
return time / windup;
}
public float getProjectileSpeed(ItemStack itemStack)
{
if (itemStack != null && itemStack.hasTagCompound())
{
public float getProjectileSpeed(ItemStack itemStack) {
if (itemStack != null && itemStack.hasTagCompound()) {
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
return toolTag.getFloat("FlightSpeed");
}
@@ -149,26 +139,22 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
}
@Override
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
{
if(getWindupTime(stack) == 0.0f)
return stack;
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (getWindupTime(stack) == 0.0f) return stack;
// broken tool?
if(stack.hasTagCompound() && stack.getTagCompound().hasKey(getBaseTagName()) && stack.getTagCompound().getCompoundTag(getBaseTagName()).getBoolean("Broken"))
return stack;
if (stack.hasTagCompound()
&& stack.getTagCompound().hasKey(getBaseTagName())
&& stack.getTagCompound().getCompoundTag(getBaseTagName()).getBoolean("Broken")) return stack;
// only if ammo is present
if(searchForAmmo(player, stack) != null)
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
if (searchForAmmo(player, stack) != null) player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
return stack;
}
@Override
public void onPlayerStoppedUsing (ItemStack weapon, World world, EntityPlayer player, int useRemaining)
{
if (!weapon.hasTagCompound())
{
public void onPlayerStoppedUsing(ItemStack weapon, World world, EntityPlayer player, int useRemaining) {
if (!weapon.hasTagCompound()) {
return;
}
@@ -177,8 +163,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
// we abuse the arrowLooseEvent for all projectiles
ArrowLooseEvent event = new ArrowLooseEvent(player, weapon, time);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
if (event.isCanceled()) {
return;
}
time = event.charge;
@@ -187,8 +172,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
ItemStack ammo = searchForAmmo(player, weapon);
// no ammo found. :(
if(ammo == null)
return;
if (ammo == null) return;
NBTTagCompound toolTag = weapon.getTagCompound().getCompoundTag("InfiTool");
float projectileSpeed = getProjectileSpeed(weapon);
@@ -196,39 +180,32 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
float accuracy = getAccuracy(weapon, time);
// needs a minimum windup
if(windup < this.getMinWindupProgress(weapon))
return;
if (windup < this.getMinWindupProgress(weapon)) return;
// take windup time into account
projectileSpeed *= windup;
Entity projectile = createProjectile(ammo, world, player, projectileSpeed, accuracy, windup);
int reinforced = 0;
if (toolTag.hasKey("Unbreaking"))
reinforced = toolTag.getInteger("Unbreaking");
if (toolTag.hasKey("Unbreaking")) reinforced = toolTag.getInteger("Unbreaking");
if (random.nextInt(10) < 10 - reinforced)
AbilityHelper.damageTool(weapon, 1, player, false);
if (random.nextInt(10) < 10 - reinforced) AbilityHelper.damageTool(weapon, 1, player, false);
playFiringSound(world, player, weapon, ammo, projectileSpeed, accuracy);
// use up ammo
if(!player.capabilities.isCreativeMode) {
if (ammo.getItem() instanceof IAmmo)
((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
else
player.inventory.consumeInventoryItem(ammo.getItem());
if (!player.capabilities.isCreativeMode) {
if (ammo.getItem() instanceof IAmmo) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
else player.inventory.consumeInventoryItem(ammo.getItem());
}
// FIREEEEEEE
if (!world.isRemote)
world.spawnEntityInWorld(projectile);
if (!world.isRemote) world.spawnEntityInWorld(projectile);
}
public abstract void playFiringSound(World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy);
public abstract void playFiringSound(
World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy);
public HashMap<Integer, IIcon[]> animationHeadIcons = new HashMap<Integer, IIcon[]>();
public HashMap<Integer, IIcon[]> animationHandleIcons = new HashMap<Integer, IIcon[]>();
@@ -243,8 +220,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
* 2 == accessory
* 3 == extra
*/
protected boolean animateLayer(int renderPass)
{
protected boolean animateLayer(int renderPass) {
return false;
}
@@ -252,20 +228,21 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
NBTTagCompound tags = null;
if(stack.hasTagCompound())
tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (stack.hasTagCompound()) tags = stack.getTagCompound().getCompoundTag("InfiTool");
if(tags == null || renderPass > 10)
return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
if (tags == null || renderPass > 10) return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
// are we drawing an effect?
if(renderPass >= getPartAmount()) {
if (renderPass >= getPartAmount()) {
// is the effect animated?
String effect = "Effect" + (1 + renderPass - getPartAmount());
if(tags.hasKey(effect)) {
if (tags.hasKey(effect)) {
int index = tags.getInteger(effect);
if(animationEffectIcons.get(index) != null)
return getCorrectAnimationIcon(animationEffectIcons, index, getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining));
if (animationEffectIcons.get(index) != null)
return getCorrectAnimationIcon(
animationEffectIcons,
index,
getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining));
else
// non-animated
return effectIcons.get(index);
@@ -274,35 +251,35 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
}
// animate?
if(!animateLayer(renderPass))
return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
if (!animateLayer(renderPass)) return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
if(usingItem == null || stack != usingItem || !stack.hasTagCompound())
if (usingItem == null || stack != usingItem || !stack.hasTagCompound())
return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
float progress = getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining);
// get the correct icon
switch (renderPass)
{
case 0: return getCorrectAnimationIcon(animationHandleIcons, tags.getInteger("RenderHandle"), progress);
case 1: return getCorrectAnimationIcon(animationHeadIcons, tags.getInteger("RenderHead"), progress);
case 2: return getCorrectAnimationIcon(animationAccessoryIcons, tags.getInteger("RenderAccessory"), progress);
case 3: return getCorrectAnimationIcon(animationExtraIcons, tags.getInteger("RenderExtra"), progress);
switch (renderPass) {
case 0:
return getCorrectAnimationIcon(animationHandleIcons, tags.getInteger("RenderHandle"), progress);
case 1:
return getCorrectAnimationIcon(animationHeadIcons, tags.getInteger("RenderHead"), progress);
case 2:
return getCorrectAnimationIcon(animationAccessoryIcons, tags.getInteger("RenderAccessory"), progress);
case 3:
return getCorrectAnimationIcon(animationExtraIcons, tags.getInteger("RenderExtra"), progress);
}
return emptyIcon;
}
protected IIcon getCorrectAnimationIcon(Map<Integer, IIcon[]> icons, int id, float progress)
{
protected IIcon getCorrectAnimationIcon(Map<Integer, IIcon[]> icons, int id, float progress) {
// animation count, standard texture as reference
float count = icons.get(-1).length - 1;
int step = Math.round(progress * count);
step = Math.max(0, step);
if(icons.containsKey(id))
return icons.get(id)[step];
if (icons.containsKey(id)) return icons.get(id)[step];
// default icon
return icons.get(-1)[step];
@@ -311,40 +288,30 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
@Override
@SideOnly(Side.CLIENT)
// exactly the same as the ToolCore one but with broken check for Handle instead of Head
public IIcon getIcon (ItemStack stack, int renderPass)
{
public IIcon getIcon(ItemStack stack, int renderPass) {
NBTTagCompound tags = stack.getTagCompound();
if (tags != null)
{
if (tags != null) {
tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (renderPass < getPartAmount())
{
if (renderPass < getPartAmount()) {
// Handle
if (renderPass == 0) {
if (tags.getBoolean("Broken"))
return getCorrectIcon(brokenIcons, tags.getInteger("RenderHandle"));
else
return getCorrectIcon(handleIcons, tags.getInteger("RenderHandle"));
if (tags.getBoolean("Broken")) return getCorrectIcon(brokenIcons, tags.getInteger("RenderHandle"));
else return getCorrectIcon(handleIcons, tags.getInteger("RenderHandle"));
}
// Head
else if (renderPass == 1)
{
// Head
else if (renderPass == 1) {
return getCorrectIcon(headIcons, tags.getInteger("RenderHead"));
}
// Accessory
else if (renderPass == 2)
return getCorrectIcon(accessoryIcons, tags.getInteger("RenderAccessory"));
// Extra
else if (renderPass == 3)
return getCorrectIcon(extraIcons, tags.getInteger("RenderExtra"));
else if (renderPass == 2) return getCorrectIcon(accessoryIcons, tags.getInteger("RenderAccessory"));
// Extra
else if (renderPass == 3) return getCorrectIcon(extraIcons, tags.getInteger("RenderExtra"));
}
// Effects
else if (renderPass <= 10)
{
else if (renderPass <= 10) {
String effect = "Effect" + (1 + renderPass - getPartAmount());
if(tags.hasKey(effect))
return effectIcons.get(tags.getInteger(effect));
if (tags.hasKey(effect)) return effectIcons.get(tags.getInteger(effect));
}
return blankSprite;
}
@@ -363,73 +330,63 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
// animated effects...
// find out the longest animation
int count = 0;
if(animationHeadIcons.get(-1) != null)
count = Math.max(count, animationHeadIcons.get(-1).length);
if(animationHandleIcons.get(-1) != null)
count = Math.max(count, animationHandleIcons.get(-1).length);
if(animationAccessoryIcons.get(-1) != null)
count = Math.max(count, animationAccessoryIcons.get(-1).length);
if(animationExtraIcons.get(-1) != null)
count = Math.max(count, animationExtraIcons.get(-1).length);
if (animationHeadIcons.get(-1) != null) count = Math.max(count, animationHeadIcons.get(-1).length);
if (animationHandleIcons.get(-1) != null) count = Math.max(count, animationHandleIcons.get(-1).length);
if (animationAccessoryIcons.get(-1) != null) count = Math.max(count, animationAccessoryIcons.get(-1).length);
if (animationExtraIcons.get(-1) != null) count = Math.max(count, animationExtraIcons.get(-1).length);
for(Map.Entry<Integer, String> entry : effectStrings.entrySet())
{
for (Map.Entry<Integer, String> entry : effectStrings.entrySet()) {
IIcon[] anims = new IIcon[count];
boolean empty = true;
for(int i = 0; i < count; i++) {
String tex = entry.getValue() + "_" + (i+1);
for (int i = 0; i < count; i++) {
String tex = entry.getValue() + "_" + (i + 1);
if (TextureHelper.itemTextureExists(tex)) {
anims[i] = iconRegister.registerIcon(tex);
empty = false;
}
}
if(!empty)
animationEffectIcons.put(entry.getKey(), anims);
if (!empty) animationEffectIcons.put(entry.getKey(), anims);
}
// default for effects is blank
IIcon[] anims = new IIcon[count];
for(int i = 0; i < count; i++)
anims[i] = blankSprite;
for (int i = 0; i < count; i++) anims[i] = blankSprite;
animationEffectIcons.put(-1, anims);
}
private void addAnimationIcons(HashMap<Integer, String> textures, HashMap<Integer, IIcon[]> icons, IIconRegister iconRegister, String standard)
{
private void addAnimationIcons(
HashMap<Integer, String> textures,
HashMap<Integer, IIcon[]> icons,
IIconRegister iconRegister,
String standard) {
icons.clear();
// we use the standard to determine how many animations there are
if(standard == null || standard.isEmpty())
return;
if (standard == null || standard.isEmpty()) return;
int count = 1;
standard = getDefaultTexturePath() + "/" + standard;
while(TextureHelper.itemTextureExists(standard + "_" + count))
count++;
standard = getDefaultTexturePath() + "/" + standard;
while (TextureHelper.itemTextureExists(standard + "_" + count)) count++;
count--;
// add the standard icons
IIcon[] anims = new IIcon[count];
for(int i = 0; i < count; i++)
anims[i] = iconRegister.registerIcon(standard + "_" + (i+1));
for (int i = 0; i < count; i++) anims[i] = iconRegister.registerIcon(standard + "_" + (i + 1));
icons.put(-1, anims);
// now do the same for each entry
for(Map.Entry<Integer, String> entry : textures.entrySet())
{
for (Map.Entry<Integer, String> entry : textures.entrySet()) {
anims = new IIcon[count];
boolean empty = true;
for(int i = 0; i < count; i++) {
String tex = entry.getValue() + "_" + (i+1);
for (int i = 0; i < count; i++) {
String tex = entry.getValue() + "_" + (i + 1);
if (TextureHelper.itemTextureExists(tex)) {
anims[i] = iconRegister.registerIcon(tex);
empty = false;
}
}
if(!empty)
icons.put(entry.getKey(), anims);
if (!empty) icons.put(entry.getKey(), anims);
}
}
@@ -438,29 +395,25 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
super.addInformation(stack, player, list, par4);
if(!stack.hasTagCompound())
return;
if (!stack.hasTagCompound()) return;
// also display max damage with current ammo
ItemStack currentAmmo = searchForAmmo(player, stack);
if(currentAmmo == null)
return;
if (currentAmmo == null) return;
float damage;
if(currentAmmo.getItem() == Items.arrow) {
if (currentAmmo.getItem() == Items.arrow) {
damage = 2 * getProjectileSpeed(stack);
}
else if(currentAmmo.getItem() instanceof AmmoItem && currentAmmo.hasTagCompound()) {
} else if (currentAmmo.getItem() instanceof AmmoItem && currentAmmo.hasTagCompound()) {
NBTTagCompound tags = currentAmmo.getTagCompound().getCompoundTag("InfiTool");
if(!tags.hasKey("BaseAttack"))
{
if (!tags.hasKey("BaseAttack")) {
// quickly calculate the base attack damage from the actual attack damage and quartz modifiers
// yes, this relies on quartz being the only modifier that modifiers damage, but at the point of writing this
// yes, this relies on quartz being the only modifier that modifiers damage, but at the point of writing
// this
// that is the case, and later tools should have the tag
int atk = tags.getInteger("Attack");
if(tags.hasKey("ModAttack"))
{
int bonusDmg = tags.getIntArray("ModAttack")[0]/24 + 1;
if (tags.hasKey("ModAttack")) {
int bonusDmg = tags.getIntArray("ModAttack")[0] / 24 + 1;
atk -= bonusDmg;
}
tags.setInteger("BaseAttack", atk);
@@ -472,32 +425,37 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
damage = baseAttack * getProjectileSpeed(stack);
damage += (totalAttack - baseAttack);
if(currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
damage = Math.max(0, damage - currentAmmo.getTagCompound().getCompoundTag("InfiTool").getInteger("Attack")/2f);
if (currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
damage = Math.max(
0,
damage
- currentAmmo
.getTagCompound()
.getCompoundTag("InfiTool")
.getInteger("Attack")
/ 2f);
damage *= ((AmmoItem) currentAmmo.getItem()).getDamageModifier();
// since most arrows will be criticals, we factor in an average crit
if(currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
damage += (0.5f/4f + Math.min(0.75f, getProjectileSpeed(stack)/25f)) * (damage / 2f + 2f);
}
else
return;
if (currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
damage += (0.5f / 4f + Math.min(0.75f, getProjectileSpeed(stack) / 25f)) * (damage / 2f + 2f);
} else return;
// convert to hearts
damage /= 2;
list.remove(list.size()-1); // remove last item (the damage of the bow itself)
list.remove(list.size() - 1); // remove last item (the damage of the bow itself)
list.add(currentAmmo.getDisplayName());
list.add(StatCollector.translateToLocal("attribute.name.ammo.maxAttackDamage") + ": " + TProxyClient.df.format(damage));
list.add(StatCollector.translateToLocal("attribute.name.ammo.maxAttackDamage") + ": "
+ TProxyClient.df.format(damage));
}
/*---- Battlegear Support START ----*/
@Override
@Optional.Method(modid = "battlegear2")
public boolean sheatheOnBack(ItemStack item)
{
public boolean sheatheOnBack(ItemStack item) {
return true;
}
@@ -509,7 +467,8 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
@Override
@Optional.Method(modid = "battlegear2")
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
public boolean offhandAttackEntity(
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
return false;
}
@@ -534,9 +493,10 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
@Override
@Optional.Method(modid = "battlegear2")
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
if(offhand == null)
return true;
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
if (offhand == null) return true;
return (mainhand != null
&& mainhand.getItem() != TinkerTools.cleaver
&& mainhand.getItem() != TinkerTools.battleaxe)
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
}