From b034b8c5f374d75e967be14e0ddb88d6a60190a2 Mon Sep 17 00:00:00 2001 From: Luke100000 Date: Sun, 29 Oct 2023 21:53:10 +0100 Subject: [PATCH] renames --- common/src/main/java/net/mca/Config.java | 2 +- .../net/mca/client/gui/SkinLibraryScreen.java | 5 ++-- .../gui/immersive_library/Workspace.java | 9 +++---- .../net/mca/entity/VillagerEntityMCA.java | 27 +++++++------------ .../mca/server/world/data/VillageManager.java | 2 +- 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/common/src/main/java/net/mca/Config.java b/common/src/main/java/net/mca/Config.java index ca03c650ba..db6c357849 100644 --- a/common/src/main/java/net/mca/Config.java +++ b/common/src/main/java/net/mca/Config.java @@ -116,7 +116,7 @@ public static Config getInstance() { public int adventurerStayTime = 48000; public float villagerProcreationChancePerMinute = 0.05f; public int bountyHunterInterval = 48000; - public int bountyHunterHeartsInterval = -150; + public int bountyHunterHearts = -150; public boolean innSpawnsAdventurers = true; public boolean innSpawnsCultists = true; public boolean innSpawnsWanderingTraders = true; diff --git a/common/src/main/java/net/mca/client/gui/SkinLibraryScreen.java b/common/src/main/java/net/mca/client/gui/SkinLibraryScreen.java index 6e7ba1af0d..94fad95be6 100644 --- a/common/src/main/java/net/mca/client/gui/SkinLibraryScreen.java +++ b/common/src/main/java/net/mca/client/gui/SkinLibraryScreen.java @@ -533,7 +533,7 @@ private float getPixelY() { @Override public void mouseMoved(double mouseX, double mouseY) { - mouseMoved(mouseX, mouseY, lastMouseX - mouseX, lastMouseY - mouseY); + mouseDeltaMoved(lastMouseX - mouseX, lastMouseY - mouseY); lastMouseX = mouseX; lastMouseY = mouseY; @@ -541,8 +541,7 @@ public void mouseMoved(double mouseX, double mouseY) { super.mouseMoved(mouseX, mouseY); } - @SuppressWarnings("unused") - protected void mouseMoved(double x, double y, double deltaX, double deltaY) { + protected void mouseDeltaMoved(double deltaX, double deltaY) { if (isPanning) { float ox = (float) (deltaX / 64 / CANVAS_SCALE); x0 -= ox; diff --git a/common/src/main/java/net/mca/client/gui/immersive_library/Workspace.java b/common/src/main/java/net/mca/client/gui/immersive_library/Workspace.java index 55aef47350..4889791ff8 100644 --- a/common/src/main/java/net/mca/client/gui/immersive_library/Workspace.java +++ b/common/src/main/java/net/mca/client/gui/immersive_library/Workspace.java @@ -36,7 +36,6 @@ public final class Workspace { private boolean dirty; private boolean dirtySinceSnapshot; - public Workspace(NativeImage image) { this.currentImage = image; this.backendTexture = new NativeImageBackedTexture(currentImage); @@ -91,7 +90,7 @@ public void removeSaturation() { int g = currentImage.getGreen(x, y) & 0xFF; int b = currentImage.getBlue(x, y) & 0xFF; int a = currentImage.getOpacity(x, y) & 0xFF; - int l = MathHelper.clamp((int)(0.2126 * r + 0.7152 * g + 0.0722 * b), 0, 255); + int l = MathHelper.clamp((int) (0.2126 * r + 0.7152 * g + 0.0722 * b), 0, 255); currentImage.setColor(x, y, a << 24 | l << 16 | l << 8 | l); } } @@ -135,9 +134,9 @@ public void addContrast(float c) { for (int x = 0; x < 64; x++) { for (int y = 0; y < 64; y++) { - int r = MathHelper.clamp((int)(((currentImage.getRed(x, y) & 0xFF) - average) * (1.0f + c) + average), 0, 255); - int g = MathHelper.clamp((int)(((currentImage.getGreen(x, y) & 0xFF) - average) * (1.0f + c) + average), 0, 255); - int b = MathHelper.clamp((int)(((currentImage.getBlue(x, y) & 0xFF) - average) * (1.0f + c) + average), 0, 255); + int r = MathHelper.clamp((int) (((currentImage.getRed(x, y) & 0xFF) - average) * (1.0f + c) + average), 0, 255); + int g = MathHelper.clamp((int) (((currentImage.getGreen(x, y) & 0xFF) - average) * (1.0f + c) + average), 0, 255); + int b = MathHelper.clamp((int) (((currentImage.getBlue(x, y) & 0xFF) - average) * (1.0f + c) + average), 0, 255); int a = currentImage.getOpacity(x, y) & 0xFF; currentImage.setColor(x, y, a << 24 | r << 16 | g << 8 | b); } diff --git a/common/src/main/java/net/mca/entity/VillagerEntityMCA.java b/common/src/main/java/net/mca/entity/VillagerEntityMCA.java index 92e62ef0db..29365d0c6b 100644 --- a/common/src/main/java/net/mca/entity/VillagerEntityMCA.java +++ b/common/src/main/java/net/mca/entity/VillagerEntityMCA.java @@ -97,10 +97,7 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import java.util.function.Predicate; import static net.mca.client.model.CommonVillagerModel.getVillager; @@ -559,10 +556,8 @@ public final boolean damage(DamageSource source, float damageAmount) { // you can't hit babies! // TODO: Verify the `isUnblockable` replacement for 1.19.4, ensure same behavior if (!Config.getInstance().canHurtBabies && !source.isIn(DamageTypeTags.BYPASSES_SHIELD) && getAgeState() == AgeState.BABY) { - if (source.getAttacker() instanceof PlayerEntity) { - if (requestCooldown()) { - sendEventMessage(Text.translatable("villager.baby_hit")); - } + if (source.getAttacker() instanceof PlayerEntity && (requestCooldown())) { + sendEventMessage(Text.translatable("villager.baby_hit")); } return super.damage(source, 0.0f); } @@ -579,13 +574,11 @@ public final boolean damage(DamageSource source, float damageAmount) { if (source.getAttacker() instanceof PlayerEntity player) { if (getWorld().getTime() - lastHit > 40) { lastHit = getWorld().getTime(); - if (!isGuard() || getSmallBounty() == 0) { - if (requestCooldown()) { - if (getHealth() < getMaxHealth() / 2) { - sendChatMessage(player, "villager.badly_hurt"); - } else { - sendChatMessage(player, "villager.hurt"); - } + if ((!isGuard() || getSmallBounty() == 0) && requestCooldown()) { + if (getHealth() < getMaxHealth() / 2) { + sendChatMessage(player, "villager.badly_hurt"); + } else { + sendChatMessage(player, "villager.hurt"); } } } @@ -679,11 +672,11 @@ public boolean isGuard() { } public int getSmallBounty() { - return getBrain().getOptionalMemory(MemoryModuleTypeMCA.SMALL_BOUNTY.get()).orElse(0); + return Objects.requireNonNull(getBrain().getOptionalMemory(MemoryModuleTypeMCA.SMALL_BOUNTY.get())).orElse(0); } public boolean isHitBy(ServerPlayerEntity player) { - return getBrain().getOptionalMemory(MemoryModuleTypeMCA.HIT_BY_PLAYER.get()).filter(v -> v == player).isPresent(); + return Objects.requireNonNull(getBrain().getOptionalMemory(MemoryModuleTypeMCA.HIT_BY_PLAYER.get())).filter(v -> v == player).isPresent(); } private int getMaxWarnings(PlayerEntity attacker) { diff --git a/common/src/main/java/net/mca/server/world/data/VillageManager.java b/common/src/main/java/net/mca/server/world/data/VillageManager.java index 16670a44b5..1742dbb8fd 100644 --- a/common/src/main/java/net/mca/server/world/data/VillageManager.java +++ b/common/src/main/java/net/mca/server/world/data/VillageManager.java @@ -143,7 +143,7 @@ public void tick() { if (world.random.nextInt(10) == 0 && !isWithinHorizontalBoundaries(player.getBlockPos()) && !player.isCreative()) { villages.values().stream() .filter(v -> v.getPopulation() >= 3) - .filter(v -> v.getReputation(player) < Config.getInstance().bountyHunterHeartsInterval) + .filter(v -> v.getReputation(player) < Config.getInstance().bountyHunterHearts) .min(Comparator.comparingInt(v -> v.getReputation(player))) .ifPresent(buildings -> startBountyHunterWave(player, buildings)); }