From 3733a8bee9a5ad536104ac2efc4186d15a22157e Mon Sep 17 00:00:00 2001 From: abel1502 Date: Tue, 3 Jun 2025 15:52:29 +0300 Subject: [PATCH] Fan force falloff Previously, with two fans facing into each other, either one of them would completely overpower the other, or they'd cancel each other out. Now the force is inversely proportional to the distance, so the items end up in the middle --- src/main/java/com/hbm/blocks/machine/MachineFan.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachineFan.java b/src/main/java/com/hbm/blocks/machine/MachineFan.java index 37a96e5f8..121044d44 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineFan.java +++ b/src/main/java/com/hbm/blocks/machine/MachineFan.java @@ -18,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -103,10 +104,13 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro List affected = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5 + Math.min(x, 0), yCoord + 0.5 + Math.min(y, 0), zCoord + 0.5 + Math.min(z, 0), xCoord + 0.5 + Math.max(x, 0), yCoord + 0.5 + Math.max(y, 0), zCoord + 0.5 + Math.max(z, 0)).expand(0.5, 0.5, 0.5)); for(Entity e : affected) { + + double dist = e.getDistance(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + double coeff = push * (1 - dist / range / 2); - e.motionX += dir.offsetX * push; - e.motionY += dir.offsetY * push; - e.motionZ += dir.offsetZ * push; + e.motionX += dir.offsetX * coeff; + e.motionY += dir.offsetY * coeff; + e.motionZ += dir.offsetZ * coeff; } if(worldObj.isRemote && worldObj.rand.nextInt(30) == 0) {