Skip to content

Commit

Permalink
Fix warden tater particles being positioned incorrectly (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 authored Sep 8, 2023
1 parent 8dcd27b commit 920f0a5
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.event.BlockPositionSource;
import net.minecraft.world.event.EntityPositionSource;
import net.minecraft.world.event.PositionSource;

public class WardenTaterBlock extends CubicPotatoBlock {
private static final int BOX_SIZE = 16;
Expand All @@ -28,21 +26,39 @@ public WardenTaterBlock(Settings settings, String texture) {

@Override
public ParticleEffect getBlockParticleEffect(BlockState state, ServerWorld world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return getTaterVibrationParticleEffect(pos, new BlockPositionSource(pos), world);
return getTaterVibrationParticleEffect(pos, world);
}

public void spawnBlockParticles(ServerWorld world, BlockPos pos, ParticleEffect particleEffect) {
if (particleEffect != null && world.getRandom().nextInt(getBlockParticleChance()) == 0) {
world.spawnParticles(particleEffect, pos.getX() + 0.5, pos.getY() + 0.25, pos.getZ() + 0.5, 1, 0, 0, 0, 0);
}
}

@Override
public ParticleEffect getPlayerParticleEffect(ServerPlayerEntity player) {
BlockPos pos = BlockPos.ofFloored(player.getX(), player.getEyeY(), player.getZ());
return getTaterVibrationParticleEffect(pos, new EntityPositionSource(player, 0), player.getServerWorld());
BlockPos pos = BlockPos.ofFloored(player.getX(), player.getEyeY() - 0.2, player.getZ());
return getTaterVibrationParticleEffect(pos, player.getServerWorld());
}

@Override
public int getPlayerParticleRate(ServerPlayerEntity player) {
return ARRIVAL_TICKS;
}

private static ParticleEffect getTaterVibrationParticleEffect(BlockPos pos, PositionSource source, ServerWorld world) {
@Override
public void spawnPlayerParticles(ServerPlayerEntity player) {;
double x = player.getX();
double y = player.getEyeY() - 0.2;
double z = player.getZ();

ParticleEffect particleEffect = this.getPlayerParticleEffect(player);
if (particleEffect != null) {
player.getServerWorld().spawnParticles(particleEffect, x, y, z, 1, 0, 0, 0, 0);
}
}

private static ParticleEffect getTaterVibrationParticleEffect(BlockPos pos, ServerWorld world) {
LongList taters = new LongArrayList();

int range = (int) (BOX_SIZE / 2d);
Expand Down

0 comments on commit 920f0a5

Please sign in to comment.