This commit is contained in:
parent
2f5084010a
commit
aa200b17c0
|
@ -29,7 +29,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
public class AnimalRP implements ModInitializer {
|
public class AnimalRP implements ModInitializer {
|
||||||
public static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
public static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
|
||||||
|
@ -40,6 +39,7 @@ public class AnimalRP implements ModInitializer {
|
||||||
|
|
||||||
public static final String MOD_ID = "animal-rp";
|
public static final String MOD_ID = "animal-rp";
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
animals.put("cat", new Cat());
|
animals.put("cat", new Cat());
|
||||||
|
@ -47,10 +47,10 @@ public class AnimalRP implements ModInitializer {
|
||||||
animals.put("fox", new Fox());
|
animals.put("fox", new Fox());
|
||||||
animals.put("bee", new Bee());
|
animals.put("bee", new Bee());
|
||||||
|
|
||||||
HashmapStore.get("users.json").forEach((k,v) -> {
|
HashmapStore.get("users.json").forEach((k, v) -> {
|
||||||
users.put(UUID.fromString(k), animals.get(v));
|
users.put(UUID.fromString(k), animals.get(v));
|
||||||
});
|
});
|
||||||
HashmapStore.get("nochat.json").forEach((k,v) -> {
|
HashmapStore.get("nochat.json").forEach((k, v) -> {
|
||||||
noChat.put(UUID.fromString(k), Boolean.valueOf(v));
|
noChat.put(UUID.fromString(k), Boolean.valueOf(v));
|
||||||
});
|
});
|
||||||
emotes = new Emote();
|
emotes = new Emote();
|
||||||
|
@ -61,23 +61,32 @@ public class AnimalRP implements ModInitializer {
|
||||||
if (!ctx.hasPlayer())
|
if (!ctx.hasPlayer())
|
||||||
return PlaceholderResult.invalid("No player!");
|
return PlaceholderResult.invalid("No player!");
|
||||||
Animal animal = users.get(ctx.player().getUuid());
|
Animal animal = users.get(ctx.player().getUuid());
|
||||||
if(animal == null)
|
if (animal == null)
|
||||||
return PlaceholderResult.value("");
|
return PlaceholderResult.value("");
|
||||||
return PlaceholderResult.value("<color "+animal.color+">");
|
if (noChat.get(ctx.player().getUuid()) != null)
|
||||||
|
return PlaceholderResult.value("");
|
||||||
|
return PlaceholderResult.value("<color " + animal.color + ">");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||||
(new TfCommand()).Command(dispatcher, registryAccess, environment);
|
(new TfCommand()).Command(dispatcher, registryAccess, environment);
|
||||||
(new NoChatCommand()).Command(dispatcher, registryAccess, environment);
|
(new NoChatCommand()).Command(dispatcher, registryAccess, environment);
|
||||||
(new EmoteCommand()).Command(dispatcher, registryAccess, environment);
|
(new EmoteCommand()).Command(dispatcher, registryAccess, environment);
|
||||||
|
|
||||||
(new InteractionCommand("headpats", Mood.HAPPY, "%s petted you! %s", "You petted %s! %s")).Command(dispatcher, registryAccess, environment);
|
(new InteractionCommand("headpats", Mood.HAPPY, "%s petted you! %s", "You petted %s! %s"))
|
||||||
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s")).Command(dispatcher, registryAccess, environment);
|
.Command(dispatcher, registryAccess, environment);
|
||||||
(new InteractionCommand("bite", Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s")).Command(dispatcher, registryAccess, environment);
|
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s"))
|
||||||
(new InteractionCommand("scratch", Mood.ANGRY, "%s SCRATCHES YOU! Ow! %s", "You channel your inner evil, and scratch %s! %s")).Command(dispatcher, registryAccess, environment);
|
.Command(dispatcher, registryAccess, environment);
|
||||||
(new InteractionCommand("hug", Mood.HAPPY, "%s hugs you! How heartwarming. %s", "You hug %s! How heartwarming. %s")).Command(dispatcher, registryAccess, environment);
|
(new InteractionCommand("bite", Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s"))
|
||||||
(new InteractionCommand("cuddle", Mood.CUTE, "%s cuddles with you. %s", "You and %s start cuddling. How cute! %s")).Command(dispatcher, registryAccess, environment);
|
.Command(dispatcher, registryAccess, environment);
|
||||||
|
(new InteractionCommand("scratch", Mood.ANGRY, "%s SCRATCHES YOU! Ow! %s",
|
||||||
|
"You channel your inner evil, and scratch %s! %s"))
|
||||||
|
.Command(dispatcher, registryAccess, environment);
|
||||||
|
(new InteractionCommand("hug", Mood.HAPPY, "%s hugs you! How heartwarming. %s",
|
||||||
|
"You hug %s! How heartwarming. %s")).Command(dispatcher, registryAccess, environment);
|
||||||
|
(new InteractionCommand("cuddle", Mood.CUTE, "%s cuddles with you. %s",
|
||||||
|
"You and %s start cuddling. How cute! %s")).Command(dispatcher, registryAccess, environment);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,25 +32,27 @@ public class EmoteCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
|
|
||||||
Emote.Emotes emote;
|
Emote.Emotes emote;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
emote = Emotes.valueOf(arg.toUpperCase());
|
emote = Emotes.valueOf(arg.toUpperCase());
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
emote = null;
|
emote = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(emote == null) {
|
if (emote == null) {
|
||||||
this.options(context.getSource());
|
this.options(context.getSource());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AnimalRP.emotes.isPlayerEmoting(player.getUuid())) {
|
if (AnimalRP.emotes.isPlayerEmoting(player.getUuid())) {
|
||||||
context.getSource().sendFeedback(() -> Text.literal("<red>Stopped emoting.").withColor(8421504), false);
|
context.getSource().sendFeedback(
|
||||||
|
() -> Text.literal("Stopped emoting.").withColor(8421504), false);
|
||||||
AnimalRP.emotes.stopEmote(player.getUuid());
|
AnimalRP.emotes.stopEmote(player.getUuid());
|
||||||
} else {
|
} else {
|
||||||
context.getSource().sendFeedback(() -> Text.literal("<green>Emoting!").withColor(65280), false);
|
context.getSource().sendFeedback(() -> Text.literal("Emoting!").withColor(65280),
|
||||||
|
false);
|
||||||
AnimalRP.emotes.playEmote(player.getUuid(), context.getSource().getPlayer(), emote);
|
AnimalRP.emotes.playEmote(player.getUuid(), context.getSource().getPlayer(), emote);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -59,7 +61,15 @@ public class EmoteCommand {
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void options(ServerCommandSource player) {
|
private void options(ServerCommandSource player) {
|
||||||
player.sendFeedback(() -> TextParserUtils.formatText("<red>You have <green>" + String.join(", ", Emote.emotes.keySet().stream().map(Emote.Emotes::name).map(String::toLowerCase).collect(Collectors.toSet())) + "</green> as options."), false);
|
player.sendFeedback(
|
||||||
|
() -> TextParserUtils
|
||||||
|
.formatText(
|
||||||
|
"<red>You have <green>"
|
||||||
|
+ String.join(", ",
|
||||||
|
Emote.emotes.keySet().stream().map(Emote.Emotes::name)
|
||||||
|
.map(String::toLowerCase).collect(Collectors.toSet()))
|
||||||
|
+ "</green> as options."),
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -48,7 +48,9 @@ public class InteractionCommand {
|
||||||
|
|
||||||
if (aplayer == null) {
|
if (aplayer == null) {
|
||||||
context.getSource().sendFeedback(
|
context.getSource().sendFeedback(
|
||||||
() -> Text.literal("Only animals can interact with other animals :(").withColor(8421504), false);
|
() -> Text.literal("Only animals can interact with other animals :(")
|
||||||
|
.withColor(8421504),
|
||||||
|
false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +58,18 @@ public class InteractionCommand {
|
||||||
|
|
||||||
if (splayer.getName() == player.getName()) {
|
if (splayer.getName() == player.getName()) {
|
||||||
context.getSource().sendFeedback(
|
context.getSource().sendFeedback(
|
||||||
() -> Text.literal("You can't " + this.command + " yourself.").withColor(8421504), false);
|
() -> Text.literal("You can't " + this.command + " yourself.")
|
||||||
|
.withColor(8421504),
|
||||||
|
false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Animal asplayer = AnimalRP.users.get(splayer.getUuid());
|
Animal asplayer = AnimalRP.users.get(splayer.getUuid());
|
||||||
|
|
||||||
if (asplayer == null) {
|
if (asplayer == null) {
|
||||||
context.getSource().sendFeedback(
|
context.getSource().sendFeedback(
|
||||||
() -> Text.literal(splayer.getName() + " is not an animal! :(").withColor(8421504), false);
|
() -> Text.literal(splayer.getName() + " is not an animal! :(")
|
||||||
|
.withColor(8421504),
|
||||||
|
false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +81,8 @@ public class InteractionCommand {
|
||||||
String.format(this.toYou,
|
String.format(this.toYou,
|
||||||
"<light_purple>" + splayer.getName().getString() + "</light_purple>",
|
"<light_purple>" + splayer.getName().getString() + "</light_purple>",
|
||||||
"<italic><gray>" + asplayer.catchphrase)));
|
"<italic><gray>" + asplayer.catchphrase)));
|
||||||
player.getWorld().playSound(splayer, splayer.getBlockPos(), asplayer.moodSounds.get(this.mood), SoundCategory.PLAYERS, 1F,
|
player.getWorld().playSound(splayer, splayer.getBlockPos(),
|
||||||
|
asplayer.moodSounds.get(this.mood), SoundCategory.PLAYERS, 1F,
|
||||||
1);
|
1);
|
||||||
return 1;
|
return 1;
|
||||||
})));
|
})));
|
||||||
|
|
|
@ -18,15 +18,19 @@ public class NoChatCommand {
|
||||||
UUID userUuid = context.getSource().getEntity().getUuid();
|
UUID userUuid = context.getSource().getEntity().getUuid();
|
||||||
|
|
||||||
Boolean isDisabled = AnimalRP.noChat.get(context.getSource().getEntity().getUuid());
|
Boolean isDisabled = AnimalRP.noChat.get(context.getSource().getEntity().getUuid());
|
||||||
if(isDisabled == null) isDisabled = false;
|
if (isDisabled == null)
|
||||||
if(isDisabled) { //
|
isDisabled = false;
|
||||||
context.getSource().sendFeedback(() -> Text.literal("AnimalRP's chat modifications are now enabled for you.").withColor(65280), false);
|
if (isDisabled) { //
|
||||||
|
context.getSource().sendFeedback(
|
||||||
|
() -> Text.literal("AnimalRP's chat modifications are now enabled for you.").withColor(65280),
|
||||||
|
false);
|
||||||
AnimalRP.noChat.remove(userUuid);
|
AnimalRP.noChat.remove(userUuid);
|
||||||
} else {
|
} else {
|
||||||
context.getSource().sendFeedback(() -> Text.literal("AnimalRP's chat modifications are now disabled for you.").withColor(16711680), false);
|
context.getSource().sendFeedback(() -> Text
|
||||||
|
.literal("AnimalRP's chat modifications are now disabled for you.").withColor(16711680), false);
|
||||||
AnimalRP.noChat.put(userUuid, true);
|
AnimalRP.noChat.put(userUuid, true);
|
||||||
}
|
}
|
||||||
HashmapStore.save("nochat.json", AnimalRP.noChat);
|
HashmapStore.save("nochat.json", AnimalRP.noChat);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -27,8 +27,9 @@ public abstract class DecoratedMessage {
|
||||||
|
|
||||||
@ModifyVariable(method = "handleDecoratedMessage", at = @At(value = "HEAD"), argsOnly = true)
|
@ModifyVariable(method = "handleDecoratedMessage", at = @At(value = "HEAD"), argsOnly = true)
|
||||||
public @NotNull SignedMessage modifyChatMessageSentByPlayers(@NotNull SignedMessage original) {
|
public @NotNull SignedMessage modifyChatMessageSentByPlayers(@NotNull SignedMessage original) {
|
||||||
if(AnimalRP.noChat.get(player.getUuid()) != null) return original;
|
if (AnimalRP.noChat.get(player.getUuid()) != null)
|
||||||
|
return original;
|
||||||
|
|
||||||
Animal animal = AnimalRP.users.get(player.getUuid());
|
Animal animal = AnimalRP.users.get(player.getUuid());
|
||||||
if (animal == null)
|
if (animal == null)
|
||||||
return original;
|
return original;
|
||||||
|
@ -36,7 +37,7 @@ public abstract class DecoratedMessage {
|
||||||
player.getWorld().playSound(player, player.getBlockPos(),
|
player.getWorld().playSound(player, player.getBlockPos(),
|
||||||
animal.moodSounds.get(Mood.HAPPY), SoundCategory.PLAYERS, 10F, 1);
|
animal.moodSounds.get(Mood.HAPPY), SoundCategory.PLAYERS, 10F, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return original
|
return original
|
||||||
.withUnsignedContent(Text.literal(animal.chatTransformations(original.getContent().getString())));
|
.withUnsignedContent(Text.literal(animal.chatTransformations(original.getContent().getString())));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,18 +18,18 @@ import ovh.sad.animalrp.animals.Animal;
|
||||||
import ovh.sad.animalrp.animals.Bee;
|
import ovh.sad.animalrp.animals.Bee;
|
||||||
|
|
||||||
@Mixin(value = LivingEntity.class)
|
@Mixin(value = LivingEntity.class)
|
||||||
public class FoodEating {
|
public class FoodEating {
|
||||||
@Inject(method = "eatFood", at = @At("HEAD"))
|
@Inject(method = "eatFood", at = @At("HEAD"))
|
||||||
public void eatFood(World world, ItemStack stack, FoodComponent foodComponent, CallbackInfoReturnable<?> cfr) {
|
public void eatFood(World world, ItemStack stack, FoodComponent foodComponent, CallbackInfoReturnable<?> cfr) {
|
||||||
LivingEntity entity = (LivingEntity) (Object) this;
|
LivingEntity entity = (LivingEntity) (Object) this;
|
||||||
if(entity.getType().equals(EntityType.PLAYER)) {
|
if (entity.getType().equals(EntityType.PLAYER)) {
|
||||||
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
||||||
|
|
||||||
Animal animal = AnimalRP.users.get(player.getUuid());
|
Animal animal = AnimalRP.users.get(player.getUuid());
|
||||||
|
|
||||||
if (animal != null) {
|
if (animal != null) {
|
||||||
if(animal.name == "bee") {
|
if (animal.name == "bee") {
|
||||||
((Bee)animal).onEat(player, stack);
|
((Bee) animal).onEat(player, stack);
|
||||||
}
|
}
|
||||||
if (animal.superfoods.contains(stack.getItem())) {
|
if (animal.superfoods.contains(stack.getItem())) {
|
||||||
player.getHungerManager().add(4, 9.4f);
|
player.getHungerManager().add(4, 9.4f);
|
||||||
|
|
|
@ -16,9 +16,9 @@ public class Sneaking {
|
||||||
@Inject(method = "setSneaking", at = @At("HEAD"))
|
@Inject(method = "setSneaking", at = @At("HEAD"))
|
||||||
public void setSneaking(boolean sneaking, CallbackInfo info) {
|
public void setSneaking(boolean sneaking, CallbackInfo info) {
|
||||||
Entity entity = (Entity) (Object) this;
|
Entity entity = (Entity) (Object) this;
|
||||||
if(entity.getType() == EntityType.PLAYER) {
|
if (entity.getType() == EntityType.PLAYER) {
|
||||||
Bee bee = (Bee)AnimalRP.animals.get("bee");
|
Bee bee = (Bee) AnimalRP.animals.get("bee");
|
||||||
bee.onSneak((ServerPlayerEntity)entity, sneaking);
|
bee.onSneak((ServerPlayerEntity) entity, sneaking);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class Cooldown {
|
||||||
public long getTime() {
|
public long getTime() {
|
||||||
return this.timeCreated - (System.currentTimeMillis() - this.length);
|
return this.timeCreated - (System.currentTimeMillis() - this.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExpired() {
|
public boolean isExpired() {
|
||||||
return this.getTime() <= 0;
|
return this.getTime() <= 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ public class Emote {
|
||||||
ServerPlayerEntity entity;
|
ServerPlayerEntity entity;
|
||||||
Emotes emote;
|
Emotes emote;
|
||||||
|
|
||||||
PlayerEmote( ServerPlayerEntity entity,
|
PlayerEmote(ServerPlayerEntity entity,
|
||||||
Emotes emote) {
|
Emotes emote) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.emote = emote;
|
this.emote = emote;
|
||||||
}
|
}
|
||||||
|
@ -97,9 +97,10 @@ public class Emote {
|
||||||
List<Vec3d> locs = getEmoteLocs(player.getPos().subtract(0, player.isSneaking() ? .5 : 0, 0),
|
List<Vec3d> locs = getEmoteLocs(player.getPos().subtract(0, player.isSneaking() ? .5 : 0, 0),
|
||||||
emotes.get(emote), player.getRotationVector());
|
emotes.get(emote), player.getRotationVector());
|
||||||
for (Vec3d loc : locs) {
|
for (Vec3d loc : locs) {
|
||||||
for(int i =0; i < 15; i ++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
player.getWorld().addParticle(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f), loc.x,
|
player.getWorld().addParticle(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f),
|
||||||
loc.y, loc.z, 0, 0, 0);
|
loc.x,
|
||||||
|
loc.y, loc.z, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package ovh.sad.animalrp.util;
|
package ovh.sad.animalrp.util;
|
||||||
|
|
||||||
public enum Mood {
|
public enum Mood {
|
||||||
HAPPY,SAD,STRESSED,ANGRY,CUTE
|
HAPPY, SAD, STRESSED, ANGRY, CUTE
|
||||||
}
|
}
|
|
@ -20,23 +20,25 @@ public class TextDestroyer {
|
||||||
Random y = new Random();
|
Random y = new Random();
|
||||||
|
|
||||||
for (String word : words) {
|
for (String word : words) {
|
||||||
if((word.startsWith("[") && word.endsWith("]")) || word.startsWith("@")) {
|
if ((word.startsWith("[") && word.endsWith("]")) || word.startsWith("@")) {
|
||||||
out.add(word);
|
out.add(word);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y.nextBoolean()){
|
if (y.nextBoolean()) {
|
||||||
out.add(word);
|
out.add(word);
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
for(String[] replacing: this.replaces) {
|
for (String[] replacing : this.replaces) {
|
||||||
word = word.replace(replacing[0], replacing[1]);
|
word = word.replace(replacing[0], replacing[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.add(word);
|
out.add(word);
|
||||||
|
|
||||||
if(y.nextDouble() < 0.12) out.add(this.expressions[y.nextInt(this.expressions.length)]);
|
if (y.nextDouble() < 0.12)
|
||||||
|
out.add(this.expressions[y.nextInt(this.expressions.length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.join(" ", out);
|
return String.join(" ", out);
|
||||||
|
|
Loading…
Reference in a new issue