Skip to content

Commit

Permalink
renames
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke100000 committed Oct 29, 2023
1 parent 557d04a commit b034b8c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/net/mca/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,15 @@ 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;

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
Expand Down
27 changes: 10 additions & 17 deletions common/src/main/java/net/mca/entity/VillagerEntityMCA.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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");
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit b034b8c

Please sign in to comment.