fixed some field creator issues

Closes #148
This commit is contained in:
Ell 2020-10-18 15:27:25 +02:00
parent 8ee2e6d31a
commit b355ec5ccd
2 changed files with 33 additions and 8 deletions

View file

@ -136,9 +136,13 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
private ItemStack getToolUsed(TileEntityFieldCreator other) {
ItemStack myTool = this.getMyTool();
ItemStack otherTool = other.getMyTool();
if (myTool != null && otherTool != null)
return this.world.rand.nextBoolean() ? myTool : otherTool;
return myTool;
if (!myTool.isEmpty()) {
// if both have tools, choose randomly
if (!otherTool.isEmpty())
return this.world.rand.nextBoolean() ? myTool : otherTool;
return myTool;
}
return otherTool;
}
private ItemStack getMyTool() {
@ -148,7 +152,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
if (!stack.isEmpty())
return stack;
}
return null;
return ItemStack.EMPTY;
}
private void sendParticles() {

View file

@ -6,8 +6,11 @@ import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.ReuseableStream;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
@ -15,6 +18,8 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.stream.Stream;
@OnlyIn(Dist.CLIENT)
public class ParticleMagic extends Particle {
@ -57,10 +62,6 @@ public class ParticleMagic extends Particle {
} else {
this.motionY -= 0.04D * (double) this.particleGravity;
this.move(this.motionX, this.motionY, this.motionZ);
if (Math.abs(this.posY - this.prevPosY) <= 0.01F) {
this.motionX *= 0.7F;
this.motionZ *= 0.7F;
}
float lifeRatio = (float) this.age / (float) this.maxAge;
if (this.fade && lifeRatio > 0.75F)
@ -72,6 +73,26 @@ public class ParticleMagic extends Particle {
}
}
@Override
public void move(double x, double y, double z) {
double lastY = y;
if (this.canCollide && (x != 0 || y != 0 || z != 0)) {
Vector3d motion = Entity.collideBoundingBoxHeuristically(null, new Vector3d(x, y, z), this.getBoundingBox(), this.world, ISelectionContext.dummy(), new ReuseableStream<>(Stream.empty()));
x = motion.x;
y = motion.y;
z = motion.z;
}
if (x != 0 || y != 0 || z != 0) {
this.setBoundingBox(this.getBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
this.onGround = lastY != y && lastY < 0;
if (this.onGround) {
this.motionX = 0;
this.motionZ = 0;
}
}
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
Vector3d vec3d = renderInfo.getProjectedView();