Skip to content

Commit

Permalink
Merge pull request #72 from sweetrpg/fix/domestic-mode
Browse files Browse the repository at this point in the history
Domestic mode
  • Loading branch information
paulyhedral authored Jan 1, 2024
2 parents b8f9999 + f6cec19 commit 7183e21
Show file tree
Hide file tree
Showing 36 changed files with 571 additions and 377 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/1.18/current.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `[FIX]` Fixed a crash when removing a bowl with cats in wander mode
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Comparator;
import java.util.Random;

public enum EnumGender {
public enum Gender {

MALE(1, "male"),
FEMALE(2, "female"),
Expand All @@ -18,11 +18,11 @@ public enum EnumGender {
private String unlocalisedSubject;
private String unlocalisedTitle;

public static final EnumGender[] VALUES = Arrays.stream(EnumGender.values()).sorted(Comparator.comparingInt(EnumGender::getIndex)).toArray(size -> {
return new EnumGender[size];
public static final Gender[] VALUES = Arrays.stream(Gender.values()).sorted(Comparator.comparingInt(Gender::getIndex)).toArray(size -> {
return new Gender[size];
});

private EnumGender(int index, String name) {
private Gender(int index, String name) {
this.index = index;
this.saveName = name;
this.unlocalisedName = "cat.gender." + name;
Expand Down Expand Up @@ -60,20 +60,20 @@ public String getUnlocalizedTitle() {
return this.unlocalisedTitle;
}

public boolean canMateWith(EnumGender gender) {
public boolean canMateWith(Gender gender) {
boolean equalGenders = this == gender;
return (equalGenders && this == EnumGender.UNISEX) || !equalGenders;
return (equalGenders && this == Gender.UNISEX) || !equalGenders;
}

public static EnumGender byIndex(int i) {
public static Gender byIndex(int i) {
if (i < 0 | i >= VALUES.length) {
i = EnumGender.UNISEX.getIndex();
i = Gender.UNISEX.getIndex();
}
return VALUES[i];
}

public static EnumGender bySaveName(String saveName) {
for (EnumGender gender : EnumGender.values()) {
public static Gender bySaveName(String saveName) {
for (Gender gender : Gender.values()) {
if (gender.getSaveName().equals(saveName)) {
return gender;
}
Expand All @@ -82,7 +82,7 @@ public static EnumGender bySaveName(String saveName) {
return UNISEX;
}

public static EnumGender random(Random rng) {
public static Gender random(Random rng) {
return rng.nextBoolean() ? MALE : FEMALE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/java/com/sweetrpg/catherder/api/feature/ICat.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface ICat {

public boolean canInteract(LivingEntity playerIn);

public EnumMode getMode();
public Mode getMode();

public CatLevel getCatLevel();
public void increaseLevel(CatLevel.Type typeIn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import java.util.Arrays;
import java.util.Comparator;

public enum EnumMode {
public enum Mode {

DOCILE(0, "docile"),
WANDERING(1, "wandering"),
ATTACK(2, "attack"),
TACTICAL(3, "tactical"),
PATROL(4, "patrol"),
DOMESTIC(4, "domestic"),
GUARD(5, "guard"),
SKITTISH(6, "skittish");

Expand All @@ -21,15 +21,15 @@ public enum EnumMode {
private String unlocalizedName;
private String unlocalizedInfo;

public static final EnumMode[] VALUES = Arrays.stream(EnumMode.values()).sorted(Comparator.comparingInt(EnumMode::getIndex)).toArray(size -> {
return new EnumMode[size];
public static final Mode[] VALUES = Arrays.stream(Mode.values()).sorted(Comparator.comparingInt(Mode::getIndex)).toArray(size -> {
return new Mode[size];
});

private EnumMode(int index, String name) {
private Mode(int index, String name) {
this(index, name, "cat.mode." + name, "cat.mode." + name + ".indicator", "cat.mode." + name + ".description");
}

private EnumMode(int index, String mode, String unlocalizedName, String tip, String info) {
private Mode(int index, String mode, String unlocalizedName, String tip, String info) {
this.index = index;
this.saveName = mode;
this.unlocalizedName = unlocalizedName;
Expand Down Expand Up @@ -57,43 +57,45 @@ public String getUnlocalizedInfo() {
return this.unlocalizedInfo;
}

public void onModeSet(AbstractCatEntity cat, EnumMode prev) {
public void onModeSet(AbstractCatEntity cat, Mode prev) {
switch(prev) {
default:
cat.getNavigation().stop();
cat.setTarget(null);
cat.setLastHurtByMob(null);
break;
default:
cat.getNavigation().stop();
cat.setTarget(null);
cat.setLastHurtByMob(null);
break;
}
}

public EnumMode previousMode() {
public Mode previousMode() {
int i = this.getIndex() - 1;
if (i < 0) {
if(i < 0) {
i = VALUES.length - 1;
}
return VALUES[i];
}

public EnumMode nextMode() {
public Mode nextMode() {
int i = this.getIndex() + 1;
if (i >= VALUES.length) {
if(i >= VALUES.length) {
i = 0;
}

return VALUES[i];
}

public static EnumMode byIndex(int i) {
if (i < 0 || i >= VALUES.length) {
i = EnumMode.DOCILE.getIndex();
public static Mode byIndex(int i) {
if(i < 0 || i >= VALUES.length) {
i = Mode.DOCILE.getIndex();
}

return VALUES[i];
}

public static EnumMode bySaveName(String saveName) {
for (EnumMode gender : EnumMode.values()) {
if (gender.saveName.equals(saveName)) {
return gender;
public static Mode bySaveName(String saveName) {
for(Mode value : Mode.values()) {
if(value.saveName.equals(saveName)) {
return value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.google.common.base.Function;

import com.sweetrpg.catherder.api.feature.EnumGender;
import com.sweetrpg.catherder.api.feature.Gender;
import com.sweetrpg.catherder.api.feature.ICat;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -76,25 +76,25 @@ public void consumeItemFromStack(@Nullable Entity entity, ItemStack stack) {
}
}

public abstract TranslatableComponent getTranslationKey(Function<EnumGender, String> function);
public abstract TranslatableComponent getTranslationKey(Function<Gender, String> function);

public TranslatableComponent getGenderPronoun() {
return this.getTranslationKey(EnumGender::getUnlocalisedPronoun);
return this.getTranslationKey(Gender::getUnlocalisedPronoun);
}

public TranslatableComponent getGenderSubject() {
return this.getTranslationKey(EnumGender::getUnlocalisedSubject);
return this.getTranslationKey(Gender::getUnlocalisedSubject);
}

public TranslatableComponent getGenderTitle() {
return this.getTranslationKey(EnumGender::getUnlocalizedTitle);
return this.getTranslationKey(Gender::getUnlocalizedTitle);
}

public TranslatableComponent getGenderTip() {
return this.getTranslationKey(EnumGender::getUnlocalizedTip);
return this.getTranslationKey(Gender::getUnlocalizedTip);
}

public TranslatableComponent getGenderName() {
return this.getTranslationKey(EnumGender::getUnlocalizedName);
return this.getTranslationKey(Gender::getUnlocalizedName);
}
}
22 changes: 14 additions & 8 deletions src/generated/resources/assets/catherder/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,33 @@
"cat.mode.attack.description": "In this mode your cat will follow you and attack anything that attacks you or that you attack.",
"cat.mode.attack.indicator": "(A)",
"cat.mode.docile": "Docile",
"cat.mode.docile.bowl": "Bowl distance: %d",
"cat.mode.docile.description": "In this mode your cat will follow you but not attack anything. They are ready for you to throw the toy.",
"cat.mode.docile.distance": "Bowl to far away: %d",
"cat.mode.docile.indicator": "(D)",
"cat.mode.docile.nobowl": "No food bowl currently set.",
"cat.mode.domestic": "Domestic",
"cat.mode.domestic.bowl_distance": "Bowl distance: %d",
"cat.mode.domestic.bowl_too_far": "Bowl too far away: %d",
"cat.mode.domestic.box_distance": "Box distance: %d",
"cat.mode.domestic.box_too_far": "Litterbox too far away: %d",
"cat.mode.domestic.description": "In this mode, your cat will stay near its bowl, litterbox, and cat tree. To set your cat's bowl and litterbox, bring your cat within a few blocks of it.",
"cat.mode.domestic.indicator": "(M)",
"cat.mode.domestic.no_bowl": "No food bowl currently set.",
"cat.mode.domestic.no_box": "No litterbox currently set.",
"cat.mode.domestic.no_tree": "No cat tree currently set.",
"cat.mode.domestic.tree.too_far": "Cat tree too far away: %d",
"cat.mode.domestic.tree_distance": "Cat tree distance: %d",
"cat.mode.guard": "Guard",
"cat.mode.guard.description": "Cats follow closely and attack any monsters that come close.",
"cat.mode.guard.indicator": "(G)",
"cat.mode.incapacitated.help": "%s is incapacitated and requires a cake to revive %s.",
"cat.mode.incapacitated.indicator": "(I)",
"cat.mode.patrol": "Patrol",
"cat.mode.patrol.description": "In this mode your cat will patrol between 2-4 points (set using a command emblem) and attack monsters that try come into view.",
"cat.mode.patrol.indicator": "(P)",
"cat.mode.skittish": "Skittish",
"cat.mode.skittish.description": "The cat will avoid all other creatures, and sometimes its owner.",
"cat.mode.skittish.indicator": "(S)",
"cat.mode.tactical": "Tactical",
"cat.mode.tactical.description": "In this mode your cat will follow you but will not attack anything unless you use the command beam",
"cat.mode.tactical.indicator": "(T)",
"cat.mode.wandering": "Wandering",
"cat.mode.wandering.description": "In this mode your cat so stay near it's bowl and wait for your next command. To set you cat's bowl bring your cat within a few blocks of it.",
"cat.mode.wandering.description": "In this mode your cat will wander freely in the world.",
"cat.mode.wandering.indicator": "(W)",
"catcommand.come": "Come!",
"catcommand.ok": "Okay!",
Expand Down Expand Up @@ -120,7 +126,7 @@
"cattree.color.null": "Colour material not set",
"cattree.explain.missing": "This item has likely been spawned in directly!",
"color.minecraft.black_wool": "Black",
"color.minecraft.blue_wool": "Bue",
"color.minecraft.blue_wool": "Blue",
"color.minecraft.brown_wool": "Brown",
"color.minecraft.cyan_wool": "Cyan",
"color.minecraft.gray_wool": "Grey",
Expand Down
22 changes: 14 additions & 8 deletions src/generated/resources/assets/catherder/lang/en_gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,33 @@
"cat.mode.attack.description": "In this mode your cat will follow you and attack anything that attacks you or that you attack.",
"cat.mode.attack.indicator": "(A)",
"cat.mode.docile": "Docile",
"cat.mode.docile.bowl": "Bowl distance: %d",
"cat.mode.docile.description": "In this mode your cat will follow you but not attack anything. They are ready for you to throw the toy.",
"cat.mode.docile.distance": "Bowl to far away: %d",
"cat.mode.docile.indicator": "(D)",
"cat.mode.docile.nobowl": "No food bowl currently set.",
"cat.mode.domestic": "Domestic",
"cat.mode.domestic.bowl_distance": "Bowl distance: %d",
"cat.mode.domestic.bowl_too_far": "Bowl too far away: %d",
"cat.mode.domestic.box_distance": "Box distance: %d",
"cat.mode.domestic.box_too_far": "Litterbox too far away: %d",
"cat.mode.domestic.description": "In this mode, your cat will stay near its bowl, litterbox, and cat tree. To set your cat's bowl and litterbox, bring your cat within a few blocks of it.",
"cat.mode.domestic.indicator": "(M)",
"cat.mode.domestic.no_bowl": "No food bowl currently set.",
"cat.mode.domestic.no_box": "No litterbox currently set.",
"cat.mode.domestic.no_tree": "No cat tree currently set.",
"cat.mode.domestic.tree.too_far": "Cat tree too far away: %d",
"cat.mode.domestic.tree_distance": "Cat tree distance: %d",
"cat.mode.guard": "Guard",
"cat.mode.guard.description": "Cats follow closely and attack any monsters that come close.",
"cat.mode.guard.indicator": "(G)",
"cat.mode.incapacitated.help": "%s is incapacitated and requires a cake to revive %s.",
"cat.mode.incapacitated.indicator": "(I)",
"cat.mode.patrol": "Patrol",
"cat.mode.patrol.description": "In this mode your cat will patrol between 2-4 points (set using a command emblem) and attack monsters that try come into view.",
"cat.mode.patrol.indicator": "(P)",
"cat.mode.skittish": "Skittish",
"cat.mode.skittish.description": "The cat will avoid all other creatures, and sometimes its owner.",
"cat.mode.skittish.indicator": "(S)",
"cat.mode.tactical": "Tactical",
"cat.mode.tactical.description": "In this mode your cat will follow you but will not attack anything unless you use the command beam",
"cat.mode.tactical.indicator": "(T)",
"cat.mode.wandering": "Wandering",
"cat.mode.wandering.description": "In this mode your cat so stay near it's bowl and wait for your next command. To set you cat's bowl bring your cat within a few blocks of it.",
"cat.mode.wandering.description": "In this mode your cat will wander freely in the world.",
"cat.mode.wandering.indicator": "(W)",
"catcommand.come": "Come!",
"catcommand.ok": "Okay!",
Expand Down Expand Up @@ -120,7 +126,7 @@
"cattree.color.null": "Colour material not set",
"cattree.explain.missing": "This item has likely been spawned in directly!",
"color.minecraft.black_wool": "Black",
"color.minecraft.blue_wool": "Bue",
"color.minecraft.blue_wool": "Blue",
"color.minecraft.brown_wool": "Brown",
"color.minecraft.cyan_wool": "Cyan",
"color.minecraft.gray_wool": "Grey",
Expand Down
22 changes: 14 additions & 8 deletions src/generated/resources/assets/catherder/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,33 @@
"cat.mode.attack.description": "In this mode your cat will follow you and attack anything that attacks you or that you attack.",
"cat.mode.attack.indicator": "(A)",
"cat.mode.docile": "Docile",
"cat.mode.docile.bowl": "Bowl distance: %d",
"cat.mode.docile.description": "In this mode your cat will follow you but not attack anything. They are ready for you to throw the toy.",
"cat.mode.docile.distance": "Bowl to far away: %d",
"cat.mode.docile.indicator": "(D)",
"cat.mode.docile.nobowl": "No food bowl currently set.",
"cat.mode.domestic": "Domestic",
"cat.mode.domestic.bowl_distance": "Bowl distance: %d",
"cat.mode.domestic.bowl_too_far": "Bowl too far away: %d",
"cat.mode.domestic.box_distance": "Box distance: %d",
"cat.mode.domestic.box_too_far": "Litterbox too far away: %d",
"cat.mode.domestic.description": "In this mode, your cat will stay near its bowl, litterbox, and cat tree. To set your cat's bowl and litterbox, bring your cat within a few blocks of it.",
"cat.mode.domestic.indicator": "(M)",
"cat.mode.domestic.no_bowl": "No food bowl currently set.",
"cat.mode.domestic.no_box": "No litterbox currently set.",
"cat.mode.domestic.no_tree": "No cat tree currently set.",
"cat.mode.domestic.tree.too_far": "Cat tree too far away: %d",
"cat.mode.domestic.tree_distance": "Cat tree distance: %d",
"cat.mode.guard": "Guard",
"cat.mode.guard.description": "Cats follow closely and attack any monsters that come close.",
"cat.mode.guard.indicator": "(G)",
"cat.mode.incapacitated.help": "%s is incapacitated and requires a cake to revive %s.",
"cat.mode.incapacitated.indicator": "(I)",
"cat.mode.patrol": "Patrol",
"cat.mode.patrol.description": "In this mode your cat will patrol between 2-4 points (set using a command emblem) and attack monsters that try come into view.",
"cat.mode.patrol.indicator": "(P)",
"cat.mode.skittish": "Skittish",
"cat.mode.skittish.description": "The cat will avoid all other creatures, and sometimes its owner.",
"cat.mode.skittish.indicator": "(S)",
"cat.mode.tactical": "Tactical",
"cat.mode.tactical.description": "In this mode your cat will follow you but will not attack anything unless you use the command beam",
"cat.mode.tactical.indicator": "(T)",
"cat.mode.wandering": "Wandering",
"cat.mode.wandering.description": "In this mode your cat so stay near it's bowl and wait for your next command. To set you cat's bowl bring your cat within a few blocks of it.",
"cat.mode.wandering.description": "In this mode your cat will wander freely in the world.",
"cat.mode.wandering.indicator": "(W)",
"catInfo.enterName": "Enter name:",
"catcommand.come": "Come!",
Expand Down Expand Up @@ -123,7 +129,7 @@
"cattree.color.null": "Color material not set",
"cattree.explain.missing": "This item has likely been spawned in directly!",
"color.minecraft.black_wool": "Black",
"color.minecraft.blue_wool": "Bue",
"color.minecraft.blue_wool": "Blue",
"color.minecraft.brown_wool": "Brown",
"color.minecraft.cyan_wool": "Cyan",
"color.minecraft.gray_wool": "Grey",
Expand Down
Loading

0 comments on commit 7183e21

Please sign in to comment.