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

@@ -1,10 +1,8 @@
package tconstruct.gadgets.item;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -24,85 +22,85 @@ import tconstruct.util.network.MovementUpdatePacket;
public class ItemSlimeSling extends Item {
public ItemSlimeSling() {
this.setMaxStackSize(1);
this.setCreativeTab(TConstructRegistry.gadgetsTab);
}
public ItemSlimeSling() {
this.setMaxStackSize(1);
this.setCreativeTab(TConstructRegistry.gadgetsTab);
}
/**
* Called whenever this item is equipped and the right mouse button is pressed.
* Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed.
* Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return this.itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return this.itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
this.itemIcon = iconRegister.registerIcon("tinker:gadgets/slimesling");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
this.itemIcon = iconRegister.registerIcon("tinker:gadgets/slimesling");
}
@Override
public EnumAction getItemUseAction(ItemStack stack) {
return EnumAction.bow;
}
@Override
public EnumAction getItemUseAction(ItemStack stack) {
return EnumAction.bow;
}
@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 72000;
}
@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 72000;
}
// sling logic
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int timeLeft) {
// has to be on ground to do something
if (!player.onGround) {
return;
}
// sling logic
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int timeLeft) {
// has to be on ground to do something
if (!player.onGround) {
return;
}
// copy chargeup code from bow \o/
int i = this.getMaxItemUseDuration(stack) - timeLeft;
float f = i / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
f *= 4f;
// copy chargeup code from bow \o/
int i = this.getMaxItemUseDuration(stack) - timeLeft;
float f = i / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
f *= 4f;
if (f > 6f) {
f = 6f;
}
if (f > 6f) {
f = 6f;
}
// check if player was targeting a block
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
// check if player was targeting a block
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
// we fling the inverted player look vector
Vec3 vec = player.getLookVec().normalize();
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
// we fling the inverted player look vector
Vec3 vec = player.getLookVec().normalize();
player.addVelocity(vec.xCoord * -f, vec.yCoord * -f / 3f, vec.zCoord * -f);
player.addVelocity(vec.xCoord * -f, vec.yCoord * -f / 3f, vec.zCoord * -f);
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
TConstruct.packetPipeline.sendTo(new MovementUpdatePacket(player), playerMP);
playerMP.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(player));
}
player.playSound(TinkerGadgets.resource("slimesling"), 1f, 1f);
SlimeBounceHandler.addBounceHandler(player);
// TinkerCommons.potionSlimeBounce.apply(player);
}
}
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
TConstruct.packetPipeline.sendTo(new MovementUpdatePacket(player), playerMP);
playerMP.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(player));
}
player.playSound(TinkerGadgets.resource("slimesling"), 1f, 1f);
SlimeBounceHandler.addBounceHandler(player);
// TinkerCommons.potionSlimeBounce.apply(player);
}
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
list.add("Aim at a block behind you to get thrown into the air.");
list.add(player.onGround ? "Shoot for the moon!" : "Must be on the ground to use.");
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
list.add("Aim at a block behind you to get thrown into the air.");
list.add(player.onGround ? "Shoot for the moon!" : "Must be on the ground to use.");
}
}