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

@@ -13,13 +13,11 @@ import net.minecraft.world.*;
import tconstruct.library.TConstructRegistry;
import tconstruct.world.model.BarricadeRender;
public class BarricadeBlock extends MantleBlock
{
public class BarricadeBlock extends MantleBlock {
Block modelBlock;
int modelMeta;
public BarricadeBlock(Block model, int meta)
{
public BarricadeBlock(Block model, int meta) {
super(Material.wood);
this.modelBlock = model;
this.modelMeta = meta;
@@ -29,79 +27,69 @@ public class BarricadeBlock extends MantleBlock
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
public IIcon getIcon(int side, int meta) {
return modelBlock.getIcon(2, modelMeta);
}
@Override
public void registerBlockIcons (IIconRegister par1IconRegister)
{
}
public void registerBlockIcons(IIconRegister par1IconRegister) {}
@Override
public boolean renderAsNormalBlock ()
{
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType ()
{
public int getRenderType() {
return BarricadeRender.model;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int x, int y, int z)
{
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int x, int y, int z) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
@Override
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int x, int y, int z)
{
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int x, int y, int z) {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta)
{
if (meta % 4 > 0)
{
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
if (meta % 4 > 0) {
world.setBlock(x, y, z, this, meta - 1, 3);
dropBlockAsItem(world, x, y, z, new ItemStack(this));
}
else
{
} else {
dropBlockAsItem(world, x, y, z, new ItemStack(this));
}
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack stack = player.getCurrentEquippedItem();
if ((stack != null) && (stack.getItem() == Item.getItemFromBlock(this)) && (!player.isSneaking()))
{
if ((stack != null) && (stack.getItem() == Item.getItemFromBlock(this)) && (!player.isSneaking())) {
int meta = world.getBlockMetadata(x, y, z);
if (meta % 4 != 3)
{
if (meta % 4 != 3) {
world.setBlock(x, y, z, this, meta + 1, 3);
this.onBlockPlacedBy(world, x, y, z, player, stack);
this.onPostBlockPlaced(world, x, y, z, meta);
Block var9 = this;
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, var9.stepSound.soundName, (var9.stepSound.getVolume() + 1.0F) / 2.0F, var9.stepSound.getPitch() * 0.8F);
world.playSoundEffect(
x + 0.5F,
y + 0.5F,
z + 0.5F,
var9.stepSound.soundName,
(var9.stepSound.getVolume() + 1.0F) / 2.0F,
var9.stepSound.getPitch() * 0.8F);
player.swingItem();
if (!player.capabilities.isCreativeMode)
stack.stackSize -= 1;
if (!player.capabilities.isCreativeMode) stack.stackSize -= 1;
return true;
}
@@ -110,25 +98,21 @@ public class BarricadeBlock extends MantleBlock
}
@Override
public void onBlockExploded (World world, int x, int y, int z, Explosion explosion)
{
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
double distance = (x - explosion.explosionX) + (y - explosion.explosionY) + (z - explosion.explosionZ);
distance = Math.abs(distance);
double power = (explosion.explosionSize * 2) / distance;
int meta = world.getBlockMetadata(x, y, z);
int trueMeta = meta % 4;
trueMeta -= power;
if (trueMeta < 0)
world.setBlock(x, y, z, Blocks.air, 0, 0);
else
world.setBlockMetadataWithNotify(x, y, z, (int) (meta - power), 3);
if (trueMeta < 0) world.setBlock(x, y, z, Blocks.air, 0, 0);
else world.setBlockMetadataWithNotify(x, y, z, (int) (meta - power), 3);
onBlockDestroyedByExplosion(world, x, y, z, explosion);
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
{
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
}
@@ -13,13 +13,11 @@ import net.minecraft.util.*;
import net.minecraft.world.*;
import tconstruct.library.TConstructRegistry;
public class Landmine extends MantleBlock
{
public class Landmine extends MantleBlock {
/** The mob type that can trigger this pressure plate. */
private EnumCreatureType triggerMobType;
public Landmine(EnumCreatureType par3EnumCreatureType, Material par4Material)
{
public Landmine(EnumCreatureType par3EnumCreatureType, Material par4Material) {
super(par4Material);
this.triggerMobType = EnumCreatureType.monster;
this.setCreativeTab(TConstructRegistry.blockTab);
@@ -30,11 +28,9 @@ public class Landmine extends MantleBlock
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (IBlockAccess world, int x, int y, int z, int side)
{
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y - 1, z);
if (block != null)
{
if (block != null) {
return block.getIcon(world, x, y - 1, z, side);
}
return Blocks.sponge.getIcon(side, world.getBlockMetadata(x, y, z));
@@ -42,22 +38,17 @@ public class Landmine extends MantleBlock
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
public IIcon getIcon(int side, int meta) {
return Blocks.sponge.getIcon(1, meta);
}
@Override
public void registerBlockIcons (IIconRegister par1IconRegister)
{
}
public void registerBlockIcons(IIconRegister par1IconRegister) {}
/**
* How many world ticks before ticking
*/
public int tickRate ()
{
public int tickRate() {
return 20;
}
@@ -66,8 +57,7 @@ public class Landmine extends MantleBlock
* box can change after the pool has been cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
{
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
return null;
}
@@ -77,8 +67,7 @@ public class Landmine extends MantleBlock
* the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
@@ -87,14 +76,12 @@ public class Landmine extends MantleBlock
* (examples: signs, buttons, stairs, etc)
*/
@Override
public boolean renderAsNormalBlock ()
{
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean getBlocksMovement (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
return true;
}
@@ -103,9 +90,9 @@ public class Landmine extends MantleBlock
* coordinates. Args: world, x, y, z
*/
@Override
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
{
return par1World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4) || BlockFence.func_149825_a(par1World.getBlock(par2, par3 - 1, par4));
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
return par1World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)
|| BlockFence.func_149825_a(par1World.getBlock(par2, par3 - 1, par4));
}
/**
@@ -113,17 +100,15 @@ public class Landmine extends MantleBlock
* neighbor changed (coordinates passed are their own) Args: x, y, z,
* neighbor blockID
*/
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, Block par5)
{
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
boolean var6 = false;
if (!par1World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4) && !BlockFence.func_149825_a(par1World.getBlock(par2, par3 - 1, par4)))
{
if (!par1World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)
&& !BlockFence.func_149825_a(par1World.getBlock(par2, par3 - 1, par4))) {
var6 = true;
}
if (var6)
{
if (var6) {
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
// par1World.setBlock(par2, par3, par4, 0);
}
@@ -133,12 +118,9 @@ public class Landmine extends MantleBlock
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!par1World.isRemote)
{
if (par1World.getBlockMetadata(par2, par3, par4) != 0)
{
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
if (!par1World.isRemote) {
if (par1World.getBlockMetadata(par2, par3, par4) != 0) {
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4);
}
}
@@ -149,12 +131,9 @@ public class Landmine extends MantleBlock
* block). Args: world, x, y, z, entity
*/
@Override
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
{
if (!par1World.isRemote)
{
if (par1World.getBlockMetadata(par2, par3, par4) != 1)
{
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
if (!par1World.isRemote) {
if (par1World.getBlockMetadata(par2, par3, par4) != 1) {
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4);
}
}
@@ -164,21 +143,34 @@ public class Landmine extends MantleBlock
* Checks if there are mobs on the plate. If a mob is on the plate and it is
* off, it turns it on, and vice versa.
*/
private void setStateIfMobInteractsWithPlate (World world, int posX, int posY, int posZ)
{
private void setStateIfMobInteractsWithPlate(World world, int posX, int posY, int posZ) {
boolean var5 = world.getBlockMetadata(posX, posY, posZ) == 1;
boolean var6 = false;
float var7 = 0.125F;
List var8 = null;
if (this.triggerMobType == EnumCreatureType.creature)
{
var8 = world.getEntitiesWithinAABBExcludingEntity((Entity) null, AxisAlignedBB.getBoundingBox((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D, (double) ((float) (posZ + 1) - var7)));
if (this.triggerMobType == EnumCreatureType.creature) {
var8 = world.getEntitiesWithinAABBExcludingEntity(
(Entity) null,
AxisAlignedBB.getBoundingBox(
(double) ((float) posX + var7),
(double) posY,
(double) ((float) posZ + var7),
(double) ((float) (posX + 1) - var7),
(double) posY + 0.25D,
(double) ((float) (posZ + 1) - var7)));
}
if (this.triggerMobType == EnumCreatureType.monster)
{
var8 = world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D, (double) ((float) (posZ + 1) - var7)));
if (this.triggerMobType == EnumCreatureType.monster) {
var8 = world.getEntitiesWithinAABB(
EntityLiving.class,
AxisAlignedBB.getBoundingBox(
(double) ((float) posX + var7),
(double) posY,
(double) ((float) posZ + var7),
(double) ((float) (posX + 1) - var7),
(double) posY + 0.25D,
(double) ((float) (posZ + 1) - var7)));
}
/*
@@ -190,24 +182,20 @@ public class Landmine extends MantleBlock
* 1) - var7))); }
*/
if (!var8.isEmpty())
{
if (!var8.isEmpty()) {
Iterator var9 = var8.iterator();
while (var9.hasNext())
{
while (var9.hasNext()) {
Entity var10 = (Entity) var9.next();
if (!var10.doesEntityNotTriggerPressurePlate())
{
if (!var10.doesEntityNotTriggerPressurePlate()) {
var6 = true;
break;
}
}
}
if (var6 && !var5)
{
if (var6 && !var5) {
WorldHelper.setBlockToAir(world, posX, posY, posZ);
world.createExplosion((Entity) null, posX, posY, posZ, 2.0F, true);
/*
@@ -230,7 +218,7 @@ public class Landmine extends MantleBlock
* posY, posZ, posX, posY, posZ); par1World.playSoundEffect((double)posX
* + 0.5D, (double)posY + 0.1D, (double)posZ + 0.5D, "random.click",
* 0.3F, 0.5F); }
*
*
* if (var6) { par1World.scheduleBlockUpdate(posX, posY, posZ,
* this.blockID, this.tickRate()); }
*/
@@ -241,10 +229,8 @@ public class Landmine extends MantleBlock
* update, as appropriate
*/
@Override
public void breakBlock (World par1World, int par2, int par3, int par4, Block par5, int par6)
{
if (par6 > 0)
{
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
if (par6 > 0) {
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this);
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this);
}
@@ -257,17 +243,13 @@ public class Landmine extends MantleBlock
* z
*/
@Override
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
boolean var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1;
float var6 = 0.0625F;
if (var5)
{
if (var5) {
this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.03125F, 1.0F - var6);
}
else
{
} else {
this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.0625F, 1.0F - var6);
}
}
@@ -276,8 +258,7 @@ public class Landmine extends MantleBlock
* Sets the block's bounds for rendering it as an item
*/
@Override
public void setBlockBoundsForItemRender ()
{
public void setBlockBoundsForItemRender() {
float var1 = 0.5F;
float var2 = 0.125F;
float var3 = 0.5F;
@@ -289,8 +270,7 @@ public class Landmine extends MantleBlock
* but can move over, 2 = total immobility and stop pistons
*/
@Override
public int getMobilityFlag ()
{
public int getMobilityFlag() {
return 1;
}
}
@@ -16,11 +16,9 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.world.TinkerWorld;
import tconstruct.world.model.PunjiRender;
public class Punji extends MantleBlock
{
public class Punji extends MantleBlock {
public Punji()
{
public Punji() {
super(Material.plants);
this.setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.375f, 0.875f);
this.stepSound = Block.soundTypeGrass;
@@ -29,13 +27,10 @@ public class Punji extends MantleBlock
}
@Override
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
{
if (entity instanceof EntityLivingBase)
{
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (entity instanceof EntityLivingBase) {
int damage = world.getBlockMetadata(x, y, z) / 2 + 1;
if (entity.fallDistance > 0)
damage += ((entity.fallDistance) * 1.5 + 2);
if (entity.fallDistance > 0) damage += ((entity.fallDistance) * 1.5 + 2);
entity.attackEntityFrom(DamageSource.cactus, damage);
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 20, 1));
}
@@ -43,26 +38,28 @@ public class Punji extends MantleBlock
/* Right-click adds sticks */
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float hitX, float hitY, float hitZ)
{
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int par6, float hitX, float hitY, float hitZ) {
/*
* if (world.isRemote) return false;
*/
int meta = world.getBlockMetadata(x, y, z);
if (meta < 4)
{
if (meta < 4) {
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem() == Item.getItemFromBlock(TinkerWorld.punji))
{
if (stack != null && stack.getItem() == Item.getItemFromBlock(TinkerWorld.punji)) {
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), this.stepSound.soundName, (this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F);
world.playSoundEffect(
(double) ((float) x + 0.5F),
(double) ((float) y + 0.5F),
(double) ((float) z + 0.5F),
this.stepSound.soundName,
(this.stepSound.getVolume() + 1.0F) / 2.0F,
this.stepSound.getPitch() * 0.8F);
player.swingItem();
if (!player.capabilities.isCreativeMode)
{
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
if (stack.stackSize <= 0)
player.destroyCurrentEquippedItem();
if (stack.stackSize <= 0) player.destroyCurrentEquippedItem();
}
}
}
@@ -70,8 +67,7 @@ public class Punji extends MantleBlock
}
@Override
public int quantityDropped (int meta, int fortune, Random random)
{
public int quantityDropped(int meta, int fortune, Random random) {
return meta + 1;
}
@@ -81,8 +77,7 @@ public class Punji extends MantleBlock
* the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
@@ -91,29 +86,24 @@ public class Punji extends MantleBlock
* (examples: signs, buttons, stairs, etc)
*/
@Override
public boolean renderAsNormalBlock ()
{
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType ()
{
public int getRenderType() {
return PunjiRender.model;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister)
{
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon("tinker:punji");
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
{
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
}