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

@@ -4,8 +4,6 @@ import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.dispenser.IPosition;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -17,29 +15,29 @@ public abstract class BehaviorProjectileBaseDispense extends BehaviorDefaultDisp
* Dispense the specified stack, play the dispense sound and spawn particles.
*/
@Override
public ItemStack dispenseStack(IBlockSource blockSource, ItemStack stack)
{
public ItemStack dispenseStack(IBlockSource blockSource, ItemStack stack) {
World world = blockSource.getWorld();
IPosition iposition = BlockDispenser.func_149939_a(blockSource);
EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());
ItemStack reference;
if(stack.getItem() instanceof IAmmo)
{
if (stack.getItem() instanceof IAmmo) {
IAmmo ammo = (IAmmo) stack.getItem();
// needs ammo to shoot
if(ammo.getAmmoCount(stack) <= 0)
return stack;
if (ammo.getAmmoCount(stack) <= 0) return stack;
ammo.consumeAmmo(1, stack);
reference = stack.copy();
((IAmmo)reference.getItem()).setAmmo(1, reference);
}
else
reference = stack.splitStack(1);
((IAmmo) reference.getItem()).setAmmo(1, reference);
} else reference = stack.splitStack(1);
ProjectileBase projectile = this.getProjectileEntity(world, iposition, reference);
projectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + ballistic()), (double)enumfacing.getFrontOffsetZ(), this.accuraccy(), this.speed());
projectile.setThrowableHeading(
(double) enumfacing.getFrontOffsetX(),
(double) ((float) enumfacing.getFrontOffsetY() + ballistic()),
(double) enumfacing.getFrontOffsetZ(),
this.accuraccy(),
this.speed());
projectile.returnStack = reference;
projectile.canBePickedUp = 1;
world.spawnEntityInWorld(projectile);
@@ -50,8 +48,7 @@ public abstract class BehaviorProjectileBaseDispense extends BehaviorDefaultDisp
/**
* Play the dispense sound from the specified block.
*/
protected void playDispenseSound(IBlockSource p_82485_1_)
{
protected void playDispenseSound(IBlockSource p_82485_1_) {
p_82485_1_.getWorld().playAuxSFX(1002, p_82485_1_.getXInt(), p_82485_1_.getYInt(), p_82485_1_.getZInt(), 0);
}
@@ -60,15 +57,15 @@ public abstract class BehaviorProjectileBaseDispense extends BehaviorDefaultDisp
*/
protected abstract ProjectileBase getProjectileEntity(World world, IPosition position, ItemStack stack);
protected float speed()
{
protected float speed() {
return 6.0F;
}
protected float accuraccy()
{
protected float accuraccy() {
return 1.1F;
}
protected float ballistic() { return 0.1f; }
protected float ballistic() {
return 0.1f;
}
}