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

@@ -8,8 +8,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import tconstruct.util.DamageSourceFireworkExplode;
public class EntityLandmineFirework extends Entity
{
public class EntityLandmineFirework extends Entity {
/** The age of the firework in ticks. */
private int fireworkAge;
@@ -23,20 +22,17 @@ public class EntityLandmineFirework extends Entity
private int moveDirection = 0;
public EntityLandmineFirework(World par1World)
{
public EntityLandmineFirework(World par1World) {
super(par1World);
this.setSize(0.25F, 0.25F);
}
@Override
protected void entityInit ()
{
protected void entityInit() {
this.dataWatcher.addObjectByDataType(8, 5);
}
public EntityLandmineFirework setRider (Entity entity)
{
public EntityLandmineFirework setRider(Entity entity) {
rider = entity;
return this;
}
@@ -47,13 +43,12 @@ public class EntityLandmineFirework extends Entity
* Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
* length * 64 * renderDistanceWeight Args: distance
*/
public boolean isInRangeToRenderDist (double par1)
{
public boolean isInRangeToRenderDist(double par1) {
return par1 < 4096.0D;
}
public EntityLandmineFirework(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack, int moveDirection)
{
public EntityLandmineFirework(
World par1World, double par2, double par4, double par6, ItemStack par8ItemStack, int moveDirection) {
super(par1World);
this.fireworkAge = 0;
this.setSize(0.25F, 0.25F);
@@ -61,14 +56,12 @@ public class EntityLandmineFirework extends Entity
this.yOffset = 0.0F;
int i = 1;
if (par8ItemStack != null && par8ItemStack.hasTagCompound())
{
if (par8ItemStack != null && par8ItemStack.hasTagCompound()) {
this.dataWatcher.updateObject(8, par8ItemStack);
NBTTagCompound nbttagcompound = par8ItemStack.getTagCompound();
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Fireworks");
if (nbttagcompound1 != null)
{
if (nbttagcompound1 != null) {
i += nbttagcompound1.getByte("Flight");
}
}
@@ -85,14 +78,12 @@ public class EntityLandmineFirework extends Entity
/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity (double par1, double par3, double par5)
{
public void setVelocity(double par1, double par3, double par5) {
this.motionX = par1;
this.motionY = par3;
this.motionZ = par5;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, (double) f) * 180.0D / Math.PI);
@@ -103,10 +94,8 @@ public class EntityLandmineFirework extends Entity
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate ()
{
if (this.riddenByEntity == null && this.rider != null)
{
public void onUpdate() {
if (this.riddenByEntity == null && this.rider != null) {
this.rider.mountEntity(this);
}
@@ -121,43 +110,45 @@ public class EntityLandmineFirework extends Entity
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
this.rotationPitch - this.prevRotationPitch < -180.0F;
this.prevRotationPitch -= 360.0F) {
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
if (this.fireworkAge == 0)
{
if (this.fireworkAge == 0) {
this.worldObj.playSoundAtEntity(this, "fireworks.launch", 3.0F, 1.0F);
}
++this.fireworkAge;
if (this.worldObj.isRemote && this.fireworkAge % 2 < 2)
{
this.worldObj.spawnParticle("fireworksSpark", this.posX, this.posY - 0.3D, this.posZ, this.rand.nextGaussian() * 0.05D, -this.motionY * 0.5D, this.rand.nextGaussian() * 0.05D);
if (this.worldObj.isRemote && this.fireworkAge % 2 < 2) {
this.worldObj.spawnParticle(
"fireworksSpark",
this.posX,
this.posY - 0.3D,
this.posZ,
this.rand.nextGaussian() * 0.05D,
-this.motionY * 0.5D,
this.rand.nextGaussian() * 0.05D);
}
if (!this.worldObj.isRemote && this.fireworkAge > this.lifetime)
{
if (!this.worldObj.isRemote && this.fireworkAge > this.lifetime) {
this.worldObj.setEntityState(this, (byte) 17);
this.rider.attackEntityFrom(new DamageSourceFireworkExplode("FireworkExplode"), 200F);
this.setDead();
@@ -166,19 +157,17 @@ public class EntityLandmineFirework extends Entity
@Override
@SideOnly(Side.CLIENT)
public void handleHealthUpdate (byte par1)
{
if (par1 == 17 && this.worldObj.isRemote)
{
public void handleHealthUpdate(byte par1) {
if (par1 == 17 && this.worldObj.isRemote) {
ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8);
NBTTagCompound nbttagcompound = null;
if (itemstack != null && itemstack.hasTagCompound())
{
if (itemstack != null && itemstack.hasTagCompound()) {
nbttagcompound = itemstack.getTagCompound().getCompoundTag("Fireworks");
}
this.worldObj.makeFireworks(this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
this.worldObj.makeFireworks(
this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
}
super.handleHealthUpdate(par1);
@@ -188,14 +177,12 @@ public class EntityLandmineFirework extends Entity
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
{
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
par1NBTTagCompound.setInteger("Life", this.fireworkAge);
par1NBTTagCompound.setInteger("LifeTime", this.lifetime);
ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8);
if (itemstack != null)
{
if (itemstack != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
itemstack.writeToNBT(nbttagcompound1);
par1NBTTagCompound.setTag("FireworksItem", nbttagcompound1);
@@ -206,18 +193,15 @@ public class EntityLandmineFirework extends Entity
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
{
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
this.fireworkAge = par1NBTTagCompound.getInteger("Life");
this.lifetime = par1NBTTagCompound.getInteger("LifeTime");
NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("FireworksItem");
if (nbttagcompound1 != null)
{
if (nbttagcompound1 != null) {
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound1);
if (itemstack != null)
{
if (itemstack != null) {
this.dataWatcher.updateObject(8, itemstack);
}
}
@@ -225,8 +209,7 @@ public class EntityLandmineFirework extends Entity
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize ()
{
public float getShadowSize() {
return 0.0F;
}
@@ -234,15 +217,13 @@ public class EntityLandmineFirework extends Entity
* Gets how bright this entity is.
*/
@Override
public float getBrightness (float par1)
{
public float getBrightness(float par1) {
return super.getBrightness(par1);
}
@Override
@SideOnly(Side.CLIENT)
public int getBrightnessForRender (float par1)
{
public int getBrightnessForRender(float par1) {
return super.getBrightnessForRender(par1);
}
@@ -250,8 +231,7 @@ public class EntityLandmineFirework extends Entity
* If returns false, the item will not inflict any damage against entities.
*/
@Override
public boolean canAttackWithItem ()
{
public boolean canAttackWithItem() {
return false;
}
}
@@ -7,24 +7,23 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.*;
import tconstruct.world.MiningExplosion;
public class ExplosivePrimed extends Entity
{
public class ExplosivePrimed extends Entity {
/** How long the fuse is */
public Block block;
public int metadata;
public int fuse;
private EntityLivingBase tntPlacedBy;
public ExplosivePrimed(World par1World)
{
public ExplosivePrimed(World par1World) {
super(par1World);
this.preventEntitySpawning = true;
this.setSize(0.98F, 0.98F);
this.yOffset = this.height / 2.0F;
}
public ExplosivePrimed(World par1World, double par2, double par4, double par6, EntityLivingBase par8EntityLivingBase)
{
public ExplosivePrimed(
World par1World, double par2, double par4, double par6, EntityLivingBase par8EntityLivingBase) {
this(par1World);
this.setPosition(par2, par4, par6);
float f = (float) (Math.random() * Math.PI * 2.0D);
@@ -39,17 +38,14 @@ public class ExplosivePrimed extends Entity
}
@Override
protected void entityInit ()
{
}
protected void entityInit() {}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they
* walk on. used for spiders and wolves to prevent them from trampling crops
*/
@Override
protected boolean canTriggerWalking ()
{
protected boolean canTriggerWalking() {
return false;
}
@@ -58,8 +54,7 @@ public class ExplosivePrimed extends Entity
* this Entity.
*/
@Override
public boolean canBeCollidedWith ()
{
public boolean canBeCollidedWith() {
return !this.isDead;
}
@@ -67,8 +62,7 @@ public class ExplosivePrimed extends Entity
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate ()
{
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
@@ -78,36 +72,29 @@ public class ExplosivePrimed extends Entity
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if (this.onGround)
{
if (this.onGround) {
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
this.motionY *= -0.5D;
}
if (this.fuse-- <= 0)
{
if (this.fuse-- <= 0) {
this.setDead();
if (!this.worldObj.isRemote)
{
if (!this.worldObj.isRemote) {
this.explode();
}
}
else
{
} else {
this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
}
}
private void explode ()
{
private void explode() {
float f = 5.0F;
this.createExplosion(worldObj, this, this.posX, this.posY, this.posZ, f);
}
public void createExplosion (World world, Entity par1Entity, double par2, double par4, double par6, float par8)
{
public void createExplosion(World world, Entity par1Entity, double par2, double par4, double par6, float par8) {
Explosion explosion = new MiningExplosion(world, par1Entity, par2, par4, par6, par8);
explosion.isFlaming = false;
explosion.isSmoking = true;
@@ -120,8 +107,7 @@ public class ExplosivePrimed extends Entity
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
protected void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
{
protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
par1NBTTagCompound.setByte("Fuse", (byte) this.fuse);
}
@@ -129,23 +115,20 @@ public class ExplosivePrimed extends Entity
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
protected void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
{
protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
this.fuse = par1NBTTagCompound.getByte("Fuse");
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize ()
{
public float getShadowSize() {
return 0.0F;
}
/**
* returns null or the entityliving it was placed or ignited by
*/
public EntityLivingBase getTntPlacedBy ()
{
public EntityLivingBase getTntPlacedBy() {
return this.tntPlacedBy;
}
}