From e8e6afe01f6c1d5e8ee2c7e2e94e4b79e27e638a Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 28 Apr 2020 00:32:42 +0200 Subject: [PATCH] Minor cleanup --- .../unicopia/block/SlimeDropBlock.java | 55 ++++++++----------- .../unicopia/client/gui/HudHooks.java | 1 - .../entity/player/GravityDelegate.java | 8 +-- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java b/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java index 9de60ddd..76b84627 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java @@ -91,10 +91,8 @@ public class SlimeDropBlock extends Block implements Climbable { world.playSound(null, pos, USounds.SLIME_ADVANCE, SoundCategory.BLOCKS, 1, 1); } } else { - if (age < getMaximumAge(world, pos, state, spaceBelow)) { - if (rand.nextInt(5 * (age + 1)) == 0) { - world.setBlockState(pos, state.cycle(AGE)); - } + if (age < getMaximumAge(world, pos, state, spaceBelow) && rand.nextInt(5 * (age + 1)) == 0) { + world.setBlockState(pos, state.cycle(AGE)); } } } @@ -143,9 +141,9 @@ public class SlimeDropBlock extends Block implements Climbable { } @Override - public void onBlockRemoved(BlockState state, World world, BlockPos pos, BlockState replacement, boolean boolean_1) { + public void onBlockRemoved(BlockState state, World world, BlockPos pos, BlockState replacement, boolean moved) { world.updateNeighborsAlways(pos, this); - super.onBlockRemoved(state, world, pos, replacement, boolean_1); + super.onBlockRemoved(state, world, pos, replacement, moved); } @Override @@ -157,21 +155,19 @@ public class SlimeDropBlock extends Block implements Climbable { living.damage(MagicalDamageSource.ACID, 1); living.slowMovement(state, new Vec3d(0.25D, 0.05000000074505806D, 0.25D)); - if (!world.isClient) { - if (living.getHealth() <= 0) { - living.dropItem(Items.BONE, 3); + if (!world.isClient && living.getHealth() <= 0) { + living.dropItem(Items.BONE, 3); - if (living instanceof PlayerEntity) { - if (world.random.nextInt(13000) == 0) { - ItemStack skull = new ItemStack(Items.PLAYER_HEAD); - PlayerEntity player = (PlayerEntity)living; + if (living instanceof PlayerEntity) { + if (world.random.nextInt(13000) == 0) { + ItemStack skull = new ItemStack(Items.PLAYER_HEAD); + PlayerEntity player = (PlayerEntity)living; - skull.setTag(new CompoundTag()); - skull.getTag().put("SkullOwner", NbtHelper.fromGameProfile(new CompoundTag(), player.getGameProfile())); - player.dropItem(skull, true); - } else { - living.dropItem(Items.SKELETON_SKULL, 1); - } + skull.setTag(new CompoundTag()); + skull.getTag().put("SkullOwner", NbtHelper.fromGameProfile(new CompoundTag(), player.getGameProfile())); + player.dropItem(skull, true); + } else { + living.dropItem(Items.SKELETON_SKULL, 1); } } } @@ -216,20 +212,17 @@ public class SlimeDropBlock extends Block implements Climbable { @Override public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) { - if (state.get(SHAPE) == Shape.BULB) { - if (rand.nextInt(8) == 0) { + if (state.get(SHAPE) == Shape.BULB && rand.nextInt(8) == 0) { + Vec3d offset = state.getOffsetPos(world, pos).add(pos.getX(), pos.getY(), pos.getZ()); + Box bounds = BULBS[state.get(AGE) / 2] + .offset(offset.x, offset.y, offset.z) + .getBoundingBox(); - Vec3d offset = state.getOffsetPos(world, pos).add(pos.getX(), pos.getY(), pos.getZ()); - Box bounds = BULBS[state.get(AGE) / 2] - .offset(offset.x, offset.y, offset.z) - .getBoundingBox(); + double x = bounds.x1 + (bounds.x2 - bounds.x1) * rand.nextFloat(); + double y = bounds.y1; + double z = bounds.z1 + (bounds.z2 - bounds.z1) * rand.nextFloat(); - double x = bounds.x1 + (bounds.x2 - bounds.x1) * rand.nextFloat(); - double y = bounds.y1; - double z = bounds.z1 + (bounds.z2 - bounds.z1) * rand.nextFloat(); - - world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0); - } + world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/HudHooks.java b/src/main/java/com/minelittlepony/unicopia/client/gui/HudHooks.java index e144c9e6..6f1f8848 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/HudHooks.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/HudHooks.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.client.gui; -import com.minelittlepony.unicopia.client.gui.UHud; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.client.MinecraftClient; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java b/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java index 76f5374b..2adc5020 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java @@ -155,7 +155,7 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl ticksNextLevel = 0; entity.addExperience(1); - addFlightExperience(entity, 1); + addFlightExperience(1); entity.playSound(SoundEvents.ENTITY_GUARDIAN_FLOP, 1, 1); } @@ -198,9 +198,9 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl ticksNextLevel = 0; if (isExperienceCritical()) { - addFlightExperience(entity, -0.39991342F); + addFlightExperience(-0.39991342F); } else { - addFlightExperience(entity, -0.019991342F); + addFlightExperience(-0.019991342F); } if (flightExperience < 0.02) { @@ -282,7 +282,7 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl return distance > 4 ? SoundEvents.ENTITY_PLAYER_BIG_FALL : SoundEvents.ENTITY_PLAYER_SMALL_FALL; } - private void addFlightExperience(PlayerEntity entity, float factor) { + private void addFlightExperience(float factor) { float maximumGain = MAXIMUM_FLIGHT_EXPERIENCE - flightExperience; float gainSteps = 20;