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

+120 -115
View File
@@ -23,10 +23,8 @@ import tconstruct.library.*;
import tconstruct.library.tools.*;
import tconstruct.tools.TinkerTools;
public class Scythe extends Weapon
{
public Scythe()
{
public class Scythe extends Weapon {
public Scythe() {
super(4);
this.setUnlocalizedName("InfiTool.Scythe");
}
@@ -36,210 +34,214 @@ public class Scythe extends Weapon
*/
@Override
protected Material[] getEffectiveMaterials ()
{
protected Material[] getEffectiveMaterials() {
return materials;
}
static Material[] materials = new Material[] { Material.web, Material.cactus, Material.plants, Material.leaves, Material.vine, Material.gourd };
static Material[] materials = new Material[] {
Material.web, Material.cactus, Material.plants, Material.leaves, Material.vine, Material.gourd
};
@Override
public Item getHeadItem ()
{
public Item getHeadItem() {
return TinkerTools.scytheBlade;
}
@Override
public Item getHandleItem ()
{
public Item getHandleItem() {
return TinkerTools.toughRod;
}
@Override
public Item getAccessoryItem ()
{
public Item getAccessoryItem() {
return TinkerTools.toughBinding;
}
@Override
public Item getExtraItem ()
{
public Item getExtraItem() {
return TinkerTools.toughRod;
}
@Override
public int getPartAmount ()
{
public int getPartAmount() {
return 4;
}
@Override
public String getIconSuffix (int partType)
{
switch (partType)
{
case 0:
return "_scythe_head";
case 1:
return "_scythe_head_broken";
case 2:
return "_scythe_handle";
case 3:
return "_scythe_binding";
case 4:
return "_scythe_accessory";
default:
return "";
public String getIconSuffix(int partType) {
switch (partType) {
case 0:
return "_scythe_head";
case 1:
return "_scythe_head_broken";
case 2:
return "_scythe_handle";
case 3:
return "_scythe_binding";
case 4:
return "_scythe_accessory";
default:
return "";
}
}
@Override
public float getDurabilityModifier ()
{
public float getDurabilityModifier() {
return 3.0f;
}
@Override
public float getRepairCost ()
{
public float getRepairCost() {
return 4.0f;
}
@Override
public String getEffectSuffix ()
{
public String getEffectSuffix() {
return "_scythe_effect";
}
@Override
public String getDefaultFolder ()
{
public String getDefaultFolder() {
return "scythe";
}
@Override
public int durabilityTypeAccessory ()
{
public int durabilityTypeAccessory() {
return 1;
}
@Override
public int durabilityTypeExtra ()
{
public int durabilityTypeExtra() {
return 1;
}
@Override
public float getDamageModifier ()
{
public float getDamageModifier() {
return 0.75f;
}
@Override
public String[] getTraits ()
{
return new String[] { "weapon", "melee", "harvest" };
public String[] getTraits() {
return new String[] {"weapon", "melee", "harvest"};
}
/* Scythe Specific */
@Override
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
{
if (!stack.hasTagCompound())
return false;
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
if (!stack.hasTagCompound()) return false;
World world = player.worldObj;
final Block blockB = world.getBlock(x, y, z);
final int meta = world.getBlockMetadata(x, y, z);
if (!stack.hasTagCompound())
return false;
if (!stack.hasTagCompound()) return false;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
boolean butter = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, stack) > 0;
int fortune = EnchantmentHelper.getFortuneModifier(player);
for (int xPos = x - 1; xPos <= x + 1; xPos++)
{
for (int yPos = y - 1; yPos <= y + 1; yPos++)
{
for (int zPos = z - 1; zPos <= z + 1; zPos++)
{
if (!(tags.getBoolean("Broken")))
{
for (int xPos = x - 1; xPos <= x + 1; xPos++) {
for (int yPos = y - 1; yPos <= y + 1; yPos++) {
for (int zPos = z - 1; zPos <= z + 1; zPos++) {
if (!(tags.getBoolean("Broken"))) {
boolean cancelHarvest = false;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
{
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
cancelHarvest = true;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player)) cancelHarvest = true;
}
if (!cancelHarvest)
{
if (!cancelHarvest) {
Block localBlock = world.getBlock(xPos, yPos, zPos);
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);
if (localBlock != null)// && (block.blockMaterial == Material.leaves || block.isLeaves(world, xPos, yPos, zPos)))
float localHardness = localBlock == null
? Float.MAX_VALUE
: localBlock.getBlockHardness(world, xPos, yPos, zPos);
if (localBlock
!= null) // && (block.blockMaterial == Material.leaves || block.isLeaves(world,
// xPos, yPos, zPos)))
{
for (int iter = 0; iter < materials.length; iter++)
{
if (materials[iter] == localBlock.getMaterial())
{
if (!player.capabilities.isCreativeMode)
{
if (butter && localBlock instanceof IShearable && ((IShearable) localBlock).isShearable(stack, player.worldObj, xPos, yPos, zPos))
{
ArrayList<ItemStack> drops = ((IShearable) localBlock).onSheared(stack, player.worldObj, xPos, yPos, zPos, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack));
for (int iter = 0; iter < materials.length; iter++) {
if (materials[iter] == localBlock.getMaterial()) {
if (!player.capabilities.isCreativeMode) {
if (butter
&& localBlock instanceof IShearable
&& ((IShearable) localBlock)
.isShearable(stack, player.worldObj, xPos, yPos, zPos)) {
ArrayList<ItemStack> drops = ((IShearable) localBlock)
.onSheared(
stack,
player.worldObj,
xPos,
yPos,
zPos,
EnchantmentHelper.getEnchantmentLevel(
Enchantment.fortune.effectId, stack));
Random rand = new Random();
if (!world.isRemote)
for (ItemStack dropStack : drops)
{
for (ItemStack dropStack : drops) {
float f = 0.7F;
double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(player.worldObj, (double) xPos + d, (double) yPos + d1, (double) zPos + d2, dropStack);
double d = (double) (rand.nextFloat() * f)
+ (double) (1.0F - f) * 0.5D;
double d1 = (double) (rand.nextFloat() * f)
+ (double) (1.0F - f) * 0.5D;
double d2 = (double) (rand.nextFloat() * f)
+ (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(
player.worldObj,
(double) xPos + d,
(double) yPos + d1,
(double) zPos + d2,
dropStack);
entityitem.delayBeforeCanPickup = 10;
player.worldObj.spawnEntityInWorld(entityitem);
}
if (localHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(localBlock)], 1);
onBlockDestroyed(
stack, world, localBlock, xPos, yPos, zPos, player);
player.addStat(
StatList.mineBlockStatArray[Block.getIdFromBlock(localBlock)],
1);
world.setBlockToAir(xPos, yPos, zPos);
}
else
{
} else {
// Workaround for dropping experience
int exp = localBlock.getExpDrop(world, localMeta, fortune);
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos, true))
{
localBlock.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos, true)) {
localBlock.onBlockDestroyedByPlayer(
world, xPos, yPos, zPos, localMeta);
localBlock.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
// Workaround for dropping experience
if (!butter)
localBlock.dropXpOnBlockBreak(world, xPos, yPos, zPos, exp);
}
if (world.isRemote)
{
INetHandler handler = FMLClientHandler.instance().getClientPlayHandler();
if (handler != null && handler instanceof NetHandlerPlayClient)
{
NetHandlerPlayClient handlerClient = (NetHandlerPlayClient) handler;
handlerClient.addToSendQueue(new C07PacketPlayerDigging(0, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
handlerClient.addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
if (world.isRemote) {
INetHandler handler = FMLClientHandler.instance()
.getClientPlayHandler();
if (handler != null && handler instanceof NetHandlerPlayClient) {
NetHandlerPlayClient handlerClient =
(NetHandlerPlayClient) handler;
handlerClient.addToSendQueue(new C07PacketPlayerDigging(
0,
x,
y,
z,
Minecraft.getMinecraft().objectMouseOver.sideHit));
handlerClient.addToSendQueue(new C07PacketPlayerDigging(
2,
x,
y,
z,
Minecraft.getMinecraft().objectMouseOver.sideHit));
}
}
if (localHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
onBlockDestroyed(
stack, world, localBlock, xPos, yPos, zPos, player);
}
}
else
{
} else {
world.setBlockToAir(xPos, yPos, zPos);
}
}
@@ -250,21 +252,24 @@ public class Scythe extends Weapon
}
}
}
if (!world.isRemote)
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockB) + (meta << 12));
if (!world.isRemote) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockB) + (meta << 12));
return super.onBlockStartBreak(stack, x, y, z, player);
}
@Override
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
{
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX + 1.0D, entity.posY + 1.0D, entity.posZ + 1.0D).expand(1.0D, 1.0D, 1.0D);
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(
entity.posX,
entity.posY,
entity.posZ,
entity.posX + 1.0D,
entity.posY + 1.0D,
entity.posZ + 1.0D)
.expand(1.0D, 1.0D, 1.0D);
List list = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, box);
for (Object o : list)
{
for (Object o : list) {
AbilityHelper.onLeftClickEntity(stack, player, (Entity) o, this);
}
return true;
}
}