mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-26 23:13:07 +00:00
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:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user