Skip to content

Commit

Permalink
Merge branch '1.19.4' into 1.20.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/main/java/net/mca/entity/ai/brain/tasks/chore/HarvestingTask.java
#	common/src/main/java/net/mca/entity/ai/brain/tasks/chore/HuntingTask.java
  • Loading branch information
Luke100000 committed Oct 31, 2023
2 parents b034b8c + 4b96cfc commit 4c6e819
Show file tree
Hide file tree
Showing 90 changed files with 1,019 additions and 448 deletions.
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# 7.5.10

* Fixed data loading issues on systems with locales having non-western digits.
* Villagers no longer harvest blocks in claimed regions
* Added support for Let's Do Bakery
* Fixed root advancement to appear on world load
* Fixed villager marriage limit math
* You can no longer restrict bells or gravestones, causing them to get stuck
* Vanilla player models no longer modify your eye height
* Player eye height now automatically refreshes on world join and editor changes
* The editor now tells you if an incompatible mod disabled custom models
* Removed vanilla mechanics for turning villagers into zombie villagers as this causes undefined behavior
* Added HSV hair color option to editor
* Added loot tables in case mods rely on them and let zombie villagers drop some flesh

# 7.5.9

* Wrong procreation cooldown on new worlds

# 7.5.8

* AI performance improvements
Expand Down
33 changes: 4 additions & 29 deletions common/src/main/java/net/mca/MCA.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public final class MCA {
public static final String MOD_ID = "mca";
public static final Logger LOGGER = LogManager.getLogger();
private static final Map<String, Boolean> modCacheMap = new HashMap<>();
private static final Map<String, Boolean> MOD_CACHE = new HashMap<>();

public static final ExecutorService executorService = Executors.newSingleThreadExecutor();

Expand All @@ -30,42 +30,17 @@ public static boolean isBlankString(String string) {
return string == null || string.trim().isEmpty();
}

public static boolean isPlayerRendererAllowed() {
return Config.getInstance().enableVillagerPlayerModel &&
Config.getInstance().playerRendererBlacklist.entrySet().stream()
.filter(entry -> entry.getValue().equals("all") || entry.getValue().equals("block_player"))
.noneMatch(entry -> doesModExist(entry.getKey()));
}

public static boolean isVillagerRendererAllowed() {
return !Config.getInstance().forceVillagerPlayerModel &&
Config.getInstance().playerRendererBlacklist.entrySet().stream()
.filter(entry -> entry.getValue().equals("all") || entry.getValue().equals("block_villager"))
.noneMatch(entry -> doesModExist(entry.getKey()));
}

public static boolean areShadersAllowed(String key) {
return Config.getInstance().enablePlayerShaders &&
Config.getInstance().playerRendererBlacklist.entrySet().stream()
.filter(entry -> entry.getValue().equals("shaders") || entry.getValue().equals(key))
.noneMatch(entry -> doesModExist(entry.getKey()));
}

public static boolean areShadersAllowed() {
return areShadersAllowed("shaders");
}

public static boolean doesModExist(String modId) {
if (!modCacheMap.containsKey(modId)) {
if (!MOD_CACHE.containsKey(modId)) {
Optional<Mod> modData;
try {
modData = Optional.of(Platform.getMod(modId));
} catch (Exception ignored) {
modData = Optional.empty();
}
modCacheMap.put(modId, modData.isPresent());
MOD_CACHE.put(modId, modData.isPresent());
}
return modCacheMap.get(modId);
return MOD_CACHE.get(modId);
}

public static void setServer(MinecraftServer server) {
Expand Down
37 changes: 36 additions & 1 deletion common/src/main/java/net/mca/MCAClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void onLogin() {
}

public static Optional<VillagerLike<?>> getPlayerData(UUID uuid) {
if (MCA.isPlayerRendererAllowed()) {
if (isPlayerRendererAllowed()) {
if (!MCAClient.playerDataRequests.contains(uuid) && MinecraftClient.getInstance().getNetworkHandler() != null) {
MCAClient.playerDataRequests.add(uuid);
NetworkHandler.sendToServer(new PlayerDataRequest(uuid));
Expand Down Expand Up @@ -61,4 +61,39 @@ public static void tickClient(MinecraftClient client) {
MinecraftClient.getInstance().setScreen(new SkinLibraryScreen());
}
}

public static void addPlayerData(UUID uuid, VillagerEntityMCA villager) {
playerData.put(uuid, villager);

// Refresh eye height
MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null) {
client.player.calculateDimensions();
}
}

public static boolean isPlayerRendererAllowed() {
return Config.getInstance().enableVillagerPlayerModel &&
Config.getInstance().playerRendererBlacklist.entrySet().stream()
.filter(entry -> entry.getValue().equals("all") || entry.getValue().equals("block_player"))
.noneMatch(entry -> MCA.doesModExist(entry.getKey()));
}

public static boolean isVillagerRendererAllowed() {
return !Config.getInstance().forceVillagerPlayerModel &&
Config.getInstance().playerRendererBlacklist.entrySet().stream()
.filter(entry -> entry.getValue().equals("all") || entry.getValue().equals("block_villager"))
.noneMatch(entry -> MCA.doesModExist(entry.getKey()));
}

public static boolean areShadersAllowed(String key) {
return Config.getInstance().enablePlayerShaders &&
Config.getInstance().playerRendererBlacklist.entrySet().stream()
.filter(entry -> entry.getValue().equals("shaders") || entry.getValue().equals(key))
.noneMatch(entry -> MCA.doesModExist(entry.getKey()));
}

public static boolean areShadersAllowed() {
return areShadersAllowed("shaders");
}
}
10 changes: 0 additions & 10 deletions common/src/main/java/net/mca/block/JewelerWorkbench.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos
return SHAPE;
}

public VoxelShape getRayTraceShape(BlockState state, BlockView reader, BlockPos pos, ShapeContext context) {
return SHAPE;
}

public void addInformation(ItemStack item, @Nullable BlockView iBlock, List<Text> tooltip, TooltipContext iTooltipFlag) {
tooltip.add(Text.literal("Workbench allows you to buy rings from Jeweler").formatted(Formatting.GRAY));
tooltip.add(Text.translatable(String.format("tooltip.%s.block.statue.line1", MCA.MOD_ID)).formatted(Formatting.GRAY));
tooltip.add(Text.translatable(String.format("tooltip.%s.block.statue.line2", MCA.MOD_ID)).formatted(Formatting.GRAY));
}

@Nullable
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
Expand Down
5 changes: 3 additions & 2 deletions common/src/main/java/net/mca/client/SpeechManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ private void speak(String phrase, UUID sender) {

float pitch = villager.getSoundPitch();
float gene = villager.getGenetics().getGene(Genetics.VOICE_TONE);
int tone = Math.min(9, (int)Math.floor(gene * 10.0f));
int tone = Math.min(9, (int) Math.floor(gene * 10.0f));

Identifier sound = new Identifier("mca_voices", "%s/%s_%d".formatted(phrase, villager.getGenetics().getGender().binary().getDataName(), tone).toLowerCase(Locale.ROOT));
String gender = villager.getGenetics().getGender().binary().getDataName();
Identifier sound = new Identifier("mca_voices", phrase.toLowerCase(Locale.ROOT) + "/" + gender + "_" + tone);

if (client.world != null && client.player != null) {
Collection<Identifier> keys = client.getSoundManager().getKeys();
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/net/mca/client/book/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Book {
private boolean textShadow;

public Book(String bookName) {
this(bookName, Text.translatable(String.format("mca.books.%s.author", bookName)).formatted(Formatting.GRAY));
this(bookName, Text.translatable("mca.books." + bookName + ".author").formatted(Formatting.GRAY));
}

public Book(String bookName, Text bookAuthor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TextPage extends Page {
private List<OrderedText> cachedPage;

public TextPage(String name, int page) {
content = String.format("{ \"translate\": \"mca.books.%s.%d\" }", name, page);
content = "{ \"translate\": \"mca.books." + name + "." + page + "\" }";
}

public TextPage(String content) {
Expand Down
77 changes: 77 additions & 0 deletions common/src/main/java/net/mca/client/gui/ColorSelector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package net.mca.client.gui;

import net.mca.client.gui.widget.HorizontalColorPickerWidget;
import net.mca.client.resources.ClientUtils;

class ColorSelector {
double red, green, blue;
double hue, saturation, brightness;

public HorizontalColorPickerWidget hueWidget;
public HorizontalColorPickerWidget saturationWidget;
public HorizontalColorPickerWidget brightnessWidget;

public ColorSelector() {
setHSV(0.5, 0.5, 0.5);
}

public void setRGB(double red, double green, double blue) {
this.red = red;
this.green = green;
this.blue = blue;
updateHSV();
}

public void setHSV(double hue, double saturation, double brightness) {
this.hue = hue;
this.saturation = saturation;
this.brightness = brightness;
updateRGB();

if (hueWidget != null) {
hueWidget.setValueX(hue / 360.0);
saturationWidget.setValueX(saturation);
}
if (brightnessWidget != null) {
brightnessWidget.setValueX(brightness);
}
}

private void updateRGB() {
double[] doubles = ClientUtils.HSV2RGB(hue, saturation, brightness);
this.red = doubles[0];
this.green = doubles[1];
this.blue = doubles[2];
}

private void updateHSV() {
double[] doubles = ClientUtils.RGB2HSV(red, green, blue);
this.hue = doubles[0];
this.saturation = doubles[1];
this.brightness = doubles[2];

if (hueWidget != null) {
hueWidget.setValueX(hue / 360.0);
saturationWidget.setValueX(saturation);
}
if (brightnessWidget != null) {
brightnessWidget.setValueX(brightness);
}
}

public int getRed() {
return (int) (red * 255);
}

public int getGreen() {
return (int) (green * 255);
}

public int getBlue() {
return (int) (blue * 255);
}

public int getColor() {
return 0xFF000000 | getBlue() << 16 | getGreen() << 8 | getRed();
}
}
2 changes: 1 addition & 1 deletion common/src/main/java/net/mca/client/gui/DestinyScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected void setPage(String page) {
});
drawGender(width / 2 - DATA_WIDTH / 2, height / 2 + 24);

drawModel(width / 2 - DATA_WIDTH / 2, height / 2 + 24 + 22);
addModelSelectionWidgets(width / 2 - DATA_WIDTH / 2, height / 2 + 24 + 22);

acceptWidget = addDrawableChild(new ButtonWidget(width / 2 - 32, height / 2 + 60 + 22, 64, 20, Text.translatable("gui.button.accept"), sender -> {
if (Config.getInstance().allowBodyCustomizationInDestiny) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void setPage(String page) {

//which model to use
if (villagerUUID.equals(playerUUID)) {
drawModel(width / 2, y);
addModelSelectionWidgets(width / 2, y);
}
}
}
Expand Down
Loading

0 comments on commit 4c6e819

Please sign in to comment.