Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions common/src/main/java/net/chococraft/ChococraftExpectPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,16 @@ public static EntityDataSerializer<MovementType> getMovementSerializer() {
// Just throw an error, the content should get replaced at runtime.
throw new AssertionError();
}

@ExpectPlatform
public static boolean requireEmptyHand() {
// Just throw an error, the content should get replaced at runtime.
throw new AssertionError();
}

@ExpectPlatform
public static boolean genderless() {
// Just throw an error, the content should get replaced at runtime.
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import net.chococraft.Chococraft;
import net.chococraft.ChococraftExpectPlatform;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
Expand All @@ -10,8 +11,11 @@
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

import java.util.ArrayList;


public class ChocoboBookScreen extends Screen {
private final static ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(Chococraft.MOD_ID, "textures/gui/chocobo_book.png");
Expand All @@ -25,13 +29,22 @@ public class ChocoboBookScreen extends Screen {
private int guiLeft;
private int guiTop;
private Component pageMsg = CommonComponents.EMPTY;
private ArrayList<Integer> genderlessPages;

public ChocoboBookScreen() {
super(Component.empty());

int maxPages = 1;
genderlessPages = new ArrayList<>();
for (int i = 1; i < 128; i++) {
String unlocalized = "gui.chocobook.page" + i;
if(ChococraftExpectPlatform.genderless()){
String genderless = unlocalized + ".genderless";
if(I18n.exists(genderless)){
System.out.println(i);
genderlessPages.add(i);
}
}
if (I18n.get(unlocalized).equals(unlocalized)) {
maxPages = i - 1;
break;
Expand Down Expand Up @@ -83,7 +96,9 @@ public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, fl

private void renderPage(GuiGraphics guiGraphics) {
int i = (this.width - this.xSize) / 2;
guiGraphics.drawWordWrap(font, Component.translatable("gui.chocobook.page" + (currentPage)), i + 34, this.guiTop + 26, 120, 0);
boolean genderless = ChococraftExpectPlatform.genderless() && genderlessPages.contains(currentPage);
MutableComponent component = Component.translatable("gui.chocobook.page" + (currentPage) + (genderless ? ".genderless" : ""));
guiGraphics.drawWordWrap(font, component, i + 34, this.guiTop + 26, 120, 0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ public void spawnChildFromBreeding(ServerLevel level, Animal partner) {
public boolean canMate(Animal parent) {
if (parent == this || !(parent instanceof AbstractChocobo otherChocobo)) return false;
if (!this.isInLove() || !parent.isInLove()) return false;
return otherChocobo.isMale() != this.isMale();
if (ChococraftExpectPlatform.genderless()) return otherChocobo.isMale() != this.isMale();
else return true;
}

public void dropFeather() {
Expand Down Expand Up @@ -465,6 +466,10 @@ public boolean isFood(ItemStack stack) {
return stack.is(ModRegistry.LOVERLY_GYSAHL_GREEN.get()) || stack.is(ModRegistry.GOLD_GYSAHL.get()) || stack.is(ModRegistry.GYSAHL_CAKE.get());
}

public boolean isInteractionItem(ItemStack stack) {
return isFood(stack) || stack.getItem() instanceof ChocoboSaddleItem || stack.is(ModRegistry.CHOCOBO_WHISTLE.get());
}

@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
ItemStack heldItemStack = player.getItemInHand(hand);
Expand Down Expand Up @@ -499,12 +504,15 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) {
return InteractionResult.PASS;
} else {
if (this.isTame()) {
if (this.isSaddled() && !this.isVehicle() && player.getMainHandItem().isEmpty() && !player.isShiftKeyDown() && !this.isBaby()) {
//Mount the chocobo
boolean emptyHand = !ChococraftExpectPlatform.requireEmptyHand() && !isInteractionItem(player.getMainHandItem()) || player.getMainHandItem().isEmpty();
if (this.isSaddled() && !this.isVehicle() && emptyHand && !player.isShiftKeyDown() && !this.isBaby()) {
player.startRiding(this);
return InteractionResult.SUCCESS;
}

if (player.isShiftKeyDown() && !this.isBaby() && player.getMainHandItem().isEmpty()) {
//Open chocobo's inventory
if (player.isShiftKeyDown() && !this.isBaby() && emptyHand) {
this.openCustomInventoryScreen((ServerPlayer) player);
return InteractionResult.SUCCESS;
}
Expand Down
10 changes: 7 additions & 3 deletions common/src/main/resources/assets/chococraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"gui.chocobook.page10": "III.2 Gysahl Pickles\n\nGysahl Greens and sugar can be crafted into raw Gysahl pickles, which can be cooked in a furnace to receive Gysahl pickles. These treats are not only tasty, but also very nourishing.",
"gui.chocobook.page11": "IV. Domestication\n\nChocobos can be tamed by feeding them Gysahl Greens, the birds are very fond of the root vegetable and will sometimes form a bond to whomever is feeding them their fa- vorite food item. If tamed, the owner can fit either a chocobo",
"gui.chocobook.page12": "saddle or pack bags on a Chocobo. Fitted with a saddle the Chocobo can be additionally equipped with saddle bags. (§oPack bags and saddle bags can be accessed by shift-right click§r).",
"gui.chocobook.page13": "IV.1 Chocobo Breeding\n\nIf feed with Loverly or Golden Gysahls, Chocobos of different gender can be breed to produce an off- spring. These infant Chocobos are called Chicobos and even- tually grow into a Chocobo. Besides in- creasing the number",
"gui.chocobook.page13": "IV.1 Chocobo Breeding\n\nIf fed with Loverly or Golden Gysahls, Chocobos of different gender can be bred to produce an off- spring. These infant Chocobos are called Chicobos and even- tually grow into a Chocobo. Besides in- creasing the number",
"gui.chocobook.page13.genderless": "IV.1 Chocobo Breeding\n\nIf fed with Loverly or Golden Gysahls, two Chocobos can be bred to produce an off- spring. These infant Chocobos are called Chicobos and even- tually grow into a Chocobo. Besides in- creasing the number",
"gui.chocobook.page14": "of Chocobos in a domesticated flock, breeding is the only way to obtain the different varieties of Chocobos available. There is a slight chance of mutation, which can be in- creased with the use of Golden Gysahls. The following combinations of parents can cause",
"gui.chocobook.page15": "their offspring to mutate into these subspecies:\n\n 1. §6Yellow§0 + §6Yellow§0\n = §aGreen§0 or §9Blue§0\n\n 2. §aGreen§0 + §9Blue§0\n = §7White§0\n\n 3. §6Yellow§0 + §7White§0\n = Black",
"gui.chocobook.page16": "4. Black + §7White§0\n = §6Gold§0\n\nTo enable the off- spring to mutate into a golden Chocobo, the use of Golden Gysahls is mandatory.",
Expand All @@ -37,7 +38,8 @@
"gui.chocobook.page6": "wide areas to find a flock.",
"gui.chocobook.page7": "III. Gysahl Greens\n\nThe Chocobo's fa- vorite food are Gysahl Greens, these thick red root vegetables can be found growing widespread in all fertile areas. These plants can be crafted into seeds. The seeds then can be used to domestically grow",
"gui.chocobook.page8": "Gysahl Greens on tilted and moisturised land.",
"gui.chocobook.page9": "III.1 Gysahl Mutations\n\nWhen domestically growing Gysahl Greens, there is a chance of the root mutating into a Loverly or even Golden Gysahl. These special roots can be feed to two Chocobos of opposite gender, to initialise the mating process.",
"gui.chocobook.page9": "III.1 Gysahl Mutations\n\nWhen domestically growing Gysahl Greens, there is a chance of the root mutating into a Loverly or even Golden Gysahl. These special roots can be fed to two Chocobos of opposite gender, to initialise the mating process.",
"gui.chocobook.page9.genderless": "III.1 Gysahl Mutations\n\nWhen domestically growing Gysahl Greens, there is a chance of the root mutating into a Loverly or even Golden Gysahl. These special roots can be fed to two Chocobos to initialise the mating process.",
"info.chococraft.book.chicobo.entry.name": "Chicobo",
"info.chococraft.book.chicobo.text1": "Chicobos are the baby versions of $(l:chococraft:chocobos/chocobo)Chocobos$() that you get from breeding them.$(br)Can be instantly grown by feeding it $(l:chococraft:gysahls/gysahl_cake)Gysahl Cake$() after being tamed.",
"info.chococraft.book.chocobo.black.description": "Obtainable by breeding White and Yellow Chocobos.",
Expand Down Expand Up @@ -165,8 +167,10 @@
"item.chococraft.yellow_chocobo_spawn_egg": "Yellow Chocobo Spawn Egg",
"itemGroup.chococraft.tab": "ChocoCraft 4",
"text.autoconfig.chococraft.option.chocobo": "Chocobo",
"text.autoconfig.chococraft.option.chocobo.canChocobosFly": "Can Chocobo's Fly",
"text.autoconfig.chococraft.option.chocobo.canChocobosFly": "Can Chocobos Fly",
"text.autoconfig.chococraft.option.chocobo.kwehIntervalLimit": "Kweh Interval Limit",
"text.autoconfig.chococraft.option.chocobo.requireEmptyHand": "Mounting Requires Empty Hand",
"text.autoconfig.chococraft.option.chocobo.genderless": "Gender Is Purely Cosmetic",
"text.autoconfig.chococraft.option.chocobo.tameChance": "Tame Chance",
"text.autoconfig.chococraft.option.naming": "Naming",
"text.autoconfig.chococraft.option.naming.femaleNames": "Female Chocobo Names",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public static int kwehIntervalLimit() {
return ChococraftFabric.config.get().chocobo.kwehIntervalLimit;
}

public static boolean requireEmptyHand() {
return ChococraftFabric.config.get().chocobo.requireEmptyHand;
}

public static boolean genderless() {
return ChococraftFabric.config.get().chocobo.genderless;
}

public static boolean nameTamedChocobos() {
return ChococraftFabric.config.get().naming.nameTamedChocobos;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public static class Chocobo {
@Comment("Determines the maximum interval duration for the Chocobo's ambient sound [Default: 100]")
@ConfigEntry.BoundedDiscrete(min = 1, max = Integer.MAX_VALUE)
public int kwehIntervalLimit = 100;

@Comment("If mounting a tamed chocobo requires an empty hand [Default: true]")
public boolean requireEmptyHand = true;

@Comment("If chocobo gender is purely cosmetic [Default: false]")
public boolean genderless = false;
}

public static class Naming {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public static int kwehIntervalLimit() {
return NeoForgeChocoConfig.COMMON.kwehIntervalLimit.get();
}

public static boolean requireEmptyHand() {
return NeoForgeChocoConfig.COMMON.requireEmptyHand.get();
}

public static boolean genderless() {
return NeoForgeChocoConfig.COMMON.genderless.get();
}

public static boolean nameTamedChocobos() {
return NeoForgeChocoConfig.COMMON.nameTamedChocobos.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static class Common {
public final ModConfigSpec.BooleanValue nameTamedChocobos;
public final ModConfigSpec.BooleanValue canChocobosFly;
public final IntValue kwehIntervalLimit;
public final ModConfigSpec.BooleanValue requireEmptyHand;
public final ModConfigSpec.BooleanValue genderless;
public final ModConfigSpec.ConfigValue<List<? extends String>> maleNames;
public final ModConfigSpec.ConfigValue<List<? extends String>> femaleNames;

Expand Down Expand Up @@ -59,6 +61,14 @@ public static class Common {
.comment("Determines the maximum interval duration for the Chocobo's ambient sound [Default: 100]")
.defineInRange("kwehIntervalLimit", 100, 1, Integer.MAX_VALUE);

requireEmptyHand = builder
.comment("If mounting a tamed chocobo requires an empty hand [Default: true]")
.define("requireEmptyHand", true);

genderless = builder
.comment("If chocobo gender is purely cosmetic [Default: false]")
.define("genderless", false);

builder.pop();
builder.comment("Naming configuration")
.push("Naming");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ protected void addTranslations() {
addChocopediaEntry(pages++, "III. Gysahl Greens\n\nThe Chocobo's fa- vorite food are Gysahl Greens, these thick red root vegetables can be found growing widespread in all fertile areas. These plants can be crafted into seeds. The seeds then can be used to domestically grow");
addChocopediaEntry(pages++, "Gysahl Greens on tilted and moisturised land.");
addChocopediaEntry(pages++, "III.1 Gysahl Mutations\n\nWhen domestically growing Gysahl Greens, there is a chance of the root mutating into a Loverly or even Golden Gysahl. These special roots can be feed to two Chocobos of opposite gender, to initialise the mating process.");
addChocopediaEntry(pages++, true, "III.1 Gysahl Mutations\n\nWhen domestically growing Gysahl Greens, there is a chance of the root mutating into a Loverly or even Golden Gysahl. These special roots can be fed to two Chocobos to initialise the mating process.");
addChocopediaEntry(pages++, "III.2 Gysahl Pickles\n\nGysahl Greens and sugar can be crafted into raw Gysahl pickles, which can be cooked in a furnace to receive Gysahl pickles. These treats are not only tasty, but also very nourishing.");
addChocopediaEntry(pages++, "IV. Domestication\n\nChocobos can be tamed by feeding them Gysahl Greens, the birds are very fond of the root vegetable and will sometimes form a bond to whomever is feeding them their fa- vorite food item. If tamed, the owner can fit either a chocobo");
addChocopediaEntry(pages++, "saddle or pack bags on a Chocobo. Fitted with a saddle the Chocobo can be additionally equipped with saddle bags. (" + ChatFormatting.ITALIC + "Pack bags and saddle bags can be accessed by shift-right click" + ChatFormatting.RESET + ").");
addChocopediaEntry(pages++, "IV.1 Chocobo Breeding\n\nIf feed with Loverly or Golden Gysahls, Chocobos of different gender can be breed to produce an off- spring. These infant Chocobos are called Chicobos and even- tually grow into a Chocobo. Besides in- creasing the number");
addChocopediaEntry(pages++, true, "IV.1 Chocobo Breeding\n\nIf feed with Loverly or Golden Gysahls, two Chocobos can be bred to produce an off- spring. These infant Chocobos are called Chicobos and even- tually grow into a Chocobo. Besides in- creasing the number");
addChocopediaEntry(pages++, "of Chocobos in a domesticated flock, breeding is the only way to obtain the different varieties of Chocobos available. There is a slight chance of mutation, which can be in- creased with the use of Golden Gysahls. The following combinations of parents can cause");
addChocopediaEntry(pages++, "their offspring to mutate into these subspecies:\n\n 1. " + ChatFormatting.GOLD + "Yellow" + ChatFormatting.BLACK + " + " + ChatFormatting.GOLD + "Yellow" + ChatFormatting.BLACK + "\n = " + ChatFormatting.GREEN + "Green" + ChatFormatting.BLACK + " or " + ChatFormatting.BLUE + "Blue" + ChatFormatting.BLACK + "\n\n 2. " + ChatFormatting.GREEN + "Green" + ChatFormatting.BLACK + " + " + ChatFormatting.BLUE + "Blue" + ChatFormatting.BLACK + "\n = " + ChatFormatting.GRAY + "White" + ChatFormatting.BLACK + "\n\n 3. " + ChatFormatting.GOLD + "Yellow" + ChatFormatting.BLACK + " + " + ChatFormatting.GRAY + "White" + ChatFormatting.BLACK + "\n = " + "Black");
addChocopediaEntry(pages++, "4. Black + " + ChatFormatting.GRAY + "White" + ChatFormatting.BLACK + "\n = " + ChatFormatting.GOLD + "Gold" + ChatFormatting.BLACK + "\n\nTo enable the off- spring to mutate into a golden " + "Chocobo, the use of Golden Gysahls is mandatory.");
Expand Down Expand Up @@ -210,14 +212,16 @@ protected void addTranslations() {
add("text.autoconfig.chococraft.option.chocobo.tameChance", "Tame Chance");
add("text.autoconfig.chococraft.option.chocobo.canChocobosFly", "Can Chocobo's Fly");
add("text.autoconfig.chococraft.option.chocobo.kwehIntervalLimit", "Kweh Interval Limit");
add("text.autoconfig.chococraft.option.chocobo.requireEmptyHand", "Mounting Requires Empty Hand");
add("text.autoconfig.chococraft.option.chocobo.genderless", "Gender Is Purely Cosmetic");
add("text.autoconfig.chococraft.option.naming", "Naming");
add("text.autoconfig.chococraft.option.naming.nameTamedChocobos", "Name Tamed Chocobos");
add("text.autoconfig.chococraft.option.naming.maleNames", "Male Chocobo Names");
add("text.autoconfig.chococraft.option.naming.femaleNames", "Female Chocobo Names");
}

public void addChocopediaEntry(int id, String translation) {
add("gui.chocobook.page" + id, translation);
public void addChocopediaEntry(int id, boolean genderless, String translation) {
add("gui.chocobook.page" + id + (genderless ? ".genderless" : ""), translation);

String patchouliVersion = translation.replaceAll("[\\n]{2,}", "\\$(br2)").replaceAll("\\n", "\\$(br)");
patchouliVersion = patchouliVersion.replaceAll("(§o)", "\\$(o)"); //Italics
Expand All @@ -241,6 +245,10 @@ public void addChocopediaEntry(int id, String translation) {
add("info.chococraft.book.legacy.page" + id, patchouliVersion);
}

public void addChocopediaEntry(int id, String translation){
addChocopediaEntry(id, false, translation);
}

public void addSubtitle(SoundEvent sound, String name) {
String path = Chococraft.MOD_ID + ".subtitle." + sound.getLocation().getPath();
this.add(path, name);
Expand Down