(unfinished) feat: remove emote crap, add commands, update to 1.21.4, fix /tf off bug
All checks were successful
build / build (21) (push) Successful in 1m37s
All checks were successful
build / build (21) (push) Successful in 1m37s
This commit is contained in:
parent
42daa7c8cd
commit
4d0b5434ee
9 changed files with 37 additions and 262 deletions
|
@ -39,7 +39,7 @@ dependencies {
|
|||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation include("eu.pb4:placeholder-api:2.4.1+1.21")
|
||||
modImplementation include("eu.pb4:placeholder-api:2.5.1+1.21.3")
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
|
|
@ -4,14 +4,14 @@ org.gradle.parallel=true
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.1
|
||||
yarn_mappings=1.21.1+build.3
|
||||
loader_version=0.16.4
|
||||
minecraft_version=1.21.4
|
||||
yarn_mappings=1.21.4+build.7
|
||||
loader_version=0.16.9
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.0.0
|
||||
mod_version=2.0.0
|
||||
maven_group=ovh.sad.animalrp
|
||||
archives_base_name=animal-rp
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.103.0+1.21.1
|
||||
fabric_version=0.114.0+1.21.4
|
||||
|
|
|
@ -9,11 +9,9 @@ import ovh.sad.animalrp.animals.Cat;
|
|||
import ovh.sad.animalrp.animals.Dog;
|
||||
import ovh.sad.animalrp.animals.Fox;
|
||||
import ovh.sad.animalrp.animals.Bee;
|
||||
import ovh.sad.animalrp.commands.EmoteCommand;
|
||||
import ovh.sad.animalrp.commands.InteractionCommand;
|
||||
import ovh.sad.animalrp.commands.NoChatCommand;
|
||||
import ovh.sad.animalrp.commands.TfCommand;
|
||||
import ovh.sad.animalrp.util.Emote;
|
||||
import ovh.sad.animalrp.util.HashmapStore;
|
||||
import ovh.sad.animalrp.util.Mood;
|
||||
import eu.pb4.placeholders.api.PlaceholderContext;
|
||||
|
@ -36,7 +34,6 @@ public class AnimalRP implements ModInitializer {
|
|||
public static HashMap<UUID, Animal> users = new HashMap<>();
|
||||
public static HashMap<UUID, Boolean> noChat = new HashMap<>();
|
||||
public static HashMap<String, Animal> animals = new HashMap<>();
|
||||
public static Emote emotes;
|
||||
|
||||
public static final String MOD_ID = "animal-rp";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
@ -64,7 +61,6 @@ ZZZzz /,`.-'`' -. ;-;;,_
|
|||
HashmapStore.get("nochat.json").forEach((k, v) -> {
|
||||
noChat.put(UUID.fromString(k), Boolean.valueOf(v));
|
||||
});
|
||||
emotes = new Emote();
|
||||
|
||||
Placeholders.register(Identifier.of("animalrp", "animalcolor"), new PlaceholderHandler() {
|
||||
@Override
|
||||
|
@ -83,7 +79,6 @@ ZZZzz /,`.-'`' -. ;-;;,_
|
|||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
(new TfCommand()).Command(dispatcher, registryAccess, environment);
|
||||
(new NoChatCommand()).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);
|
||||
|
@ -98,8 +93,11 @@ ZZZzz /,`.-'`' -. ;-;;,_
|
|||
"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);
|
||||
(new InteractionCommand("boop", Mood.CUTE, "%s boops your nose! %s", "You boop %s's nose! %s"))
|
||||
.Command(dispatcher, registryAccess, environment);
|
||||
(new InteractionCommand("nuzzle", Mood.CUTE, "%s nuzzles you! %s", "You nuzzle %s! %s"))
|
||||
.Command(dispatcher, registryAccess, environment);
|
||||
});
|
||||
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register((server) -> {
|
||||
executor.shutdownNow();
|
||||
});
|
||||
|
|
|
@ -11,17 +11,21 @@ import net.fabricmc.fabric.api.event.player.UseItemCallback;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.ConsumableComponent;
|
||||
import net.minecraft.component.type.ConsumableComponents;
|
||||
import net.minecraft.component.type.FoodComponent;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.consume.ApplyEffectsConsumeEffect;
|
||||
import net.minecraft.item.consume.ConsumeEffect;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.util.Mood;
|
||||
import ovh.sad.animalrp.util.TextDestroyer;
|
||||
|
@ -76,10 +80,10 @@ public class Bee extends Animal {
|
|||
ItemStack item = player.getStackInHand(hand);
|
||||
|
||||
if (item == null) // air interact
|
||||
return TypedActionResult.pass(item);
|
||||
return ActionResult.PASS;
|
||||
|
||||
if (!allFlowers.contains(item.getItem())) { // not a flower
|
||||
return TypedActionResult.pass(item);
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
Boolean incorrect = false;
|
||||
|
@ -96,25 +100,30 @@ public class Bee extends Animal {
|
|||
if (Bee.isItemARP(item)) {
|
||||
item.remove(DataComponentTypes.FOOD);
|
||||
|
||||
return TypedActionResult.pass(item);
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
return TypedActionResult.pass(item);
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (Bee.isItemARP(item)) { // correct animal, but foodkey already set
|
||||
return TypedActionResult.pass(item);
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
|
||||
FoodComponent food = new FoodComponent.Builder()
|
||||
.statusEffect(new StatusEffectInstance(StatusEffects.SPEED, 20 * 4, 1, true, true, true), 1)
|
||||
.alwaysEdible()
|
||||
.nutrition(4)
|
||||
.saturationModifier(9.4f)
|
||||
.build();
|
||||
|
||||
item.set(DataComponentTypes.FOOD, food);
|
||||
ConsumableComponent consumable = ConsumableComponents.food()
|
||||
.consumeEffect(new ApplyEffectsConsumeEffect(new StatusEffectInstance(StatusEffects.SPEED, 20 * 4, 1, true, true, true)))
|
||||
.build();
|
||||
|
||||
return TypedActionResult.pass(item);
|
||||
item.set(DataComponentTypes.FOOD, food);
|
||||
item.set(DataComponentTypes.CONSUMABLE, consumable);
|
||||
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ package ovh.sad.animalrp.animals;
|
|||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.util.Mood;
|
||||
|
@ -44,7 +45,7 @@ public class Fox extends Animal {
|
|||
if(!(source.getSource() instanceof ServerPlayerEntity)) return;
|
||||
if(entity instanceof PlayerEntity) return;
|
||||
|
||||
Entity victim = entity;
|
||||
LivingEntity victim = entity;
|
||||
ServerPlayerEntity damager = (ServerPlayerEntity) source.getSource();
|
||||
|
||||
Animal animal = AnimalRP.users.get(damager.getUuid());
|
||||
|
@ -53,7 +54,7 @@ public class Fox extends Animal {
|
|||
return;
|
||||
}
|
||||
|
||||
victim.damage(victim.getDamageSources().playerAttack(damager), dmg * 0.25F);
|
||||
victim.damage((ServerWorld)victim.getWorld(), victim.getDamageSources().playerAttack(damager), dmg * 0.25F);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
package ovh.sad.animalrp.commands;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import eu.pb4.placeholders.api.TextParserUtils;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.util.Emote;
|
||||
import ovh.sad.animalrp.util.Emote.Emotes;
|
||||
|
||||
public class EmoteCommand {
|
||||
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
||||
CommandManager.RegistrationEnvironment environment) {
|
||||
dispatcher.register(CommandManager.literal("emote")
|
||||
.then(CommandManager.argument("emote", StringArgumentType.string())
|
||||
.executes((context) -> {
|
||||
Entity sender = context.getSource().getEntity();
|
||||
final String arg = StringArgumentType.getString(context, "emote");
|
||||
|
||||
if (!(sender instanceof ServerPlayerEntity)) {
|
||||
context.getSource().sendFeedback(
|
||||
() -> Text.literal("I'm sorry console.").withColor(8421504), false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
|
||||
Emote.Emotes emote;
|
||||
|
||||
try {
|
||||
emote = Emotes.valueOf(arg.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
emote = null;
|
||||
}
|
||||
|
||||
if (emote == null) {
|
||||
this.options(context.getSource());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (AnimalRP.emotes.isPlayerEmoting(player.getUuid())) {
|
||||
context.getSource().sendFeedback(
|
||||
() -> Text.literal("Stopped emoting.").withColor(8421504), false);
|
||||
AnimalRP.emotes.stopEmote(player.getUuid());
|
||||
} else {
|
||||
context.getSource().sendFeedback(() -> Text.literal("Emoting!").withColor(65280),
|
||||
false);
|
||||
AnimalRP.emotes.playEmote(player.getUuid(), context.getSource().getPlayer(), emote);
|
||||
}
|
||||
return 1;
|
||||
})));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -36,6 +36,7 @@ public class TfCommand {
|
|||
AnimalRP.users.remove(entity.getUuid());
|
||||
context.getSource().sendFeedback(
|
||||
() -> Text.literal("You no longer have a animal set."), false);
|
||||
HashmapStore.save("users.json", AnimalRP.users);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,159 +0,0 @@
|
|||
package ovh.sad.animalrp.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.particle.DustParticleEffect;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
|
||||
public class Emote {
|
||||
class PlayerEmote {
|
||||
ServerPlayerEntity entity;
|
||||
Emotes emote;
|
||||
|
||||
PlayerEmote(ServerPlayerEntity entity,
|
||||
Emotes emote) {
|
||||
this.entity = entity;
|
||||
this.emote = emote;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Emotes {
|
||||
HAPPY, UWU, RAWR, LOVE, RAWR2, HAPPY2
|
||||
}
|
||||
|
||||
public static HashMap<Emotes, String[]> emotes = new HashMap<Emotes, String[]>();
|
||||
private HashMap<UUID, PlayerEmote> players = new HashMap<UUID, PlayerEmote>();
|
||||
{
|
||||
emotes.put(Emotes.HAPPY, new String[] { // Emote by PotionOfHarming!
|
||||
"0010000000100",
|
||||
"0101000001010",
|
||||
"0000000000000",
|
||||
"0000011100000"
|
||||
});
|
||||
emotes.put(Emotes.UWU, new String[] {
|
||||
"0101000001010",
|
||||
"0010000000100",
|
||||
"0000000000000",
|
||||
"0000011100000"
|
||||
});
|
||||
|
||||
emotes.put(Emotes.RAWR, new String[] {
|
||||
"0000100",
|
||||
"0100010",
|
||||
"0000100",
|
||||
"0100010",
|
||||
"0000100",
|
||||
});
|
||||
emotes.put(Emotes.RAWR2, new String[] {
|
||||
"001000000010",
|
||||
"010100000101",
|
||||
"001000000010",
|
||||
"000010101000",
|
||||
"000001010000",
|
||||
});
|
||||
emotes.put(Emotes.LOVE, new String[] {
|
||||
"0001001000",
|
||||
"0010000100",
|
||||
"0100001000",
|
||||
"0010000100",
|
||||
"0001001000",
|
||||
});
|
||||
emotes.put(Emotes.HAPPY2, new String[] {
|
||||
"010011100",
|
||||
"000010010",
|
||||
"000010010",
|
||||
"010011100"
|
||||
});
|
||||
}
|
||||
|
||||
public Emote() {
|
||||
AnimalRP.executor.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Set<Entry<UUID, PlayerEmote>> playerset = players.entrySet();
|
||||
|
||||
for (Iterator<Entry<UUID, PlayerEmote>> iterator = playerset.iterator(); iterator.hasNext();) {
|
||||
Entry<UUID, PlayerEmote> value = iterator.next();
|
||||
if (value.getValue().entity.isDisconnected()) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
drawEmote(value.getValue().entity, value.getValue().emote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 250, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void drawEmote(ServerPlayerEntity player, Emotes emote) {
|
||||
List<Vec3d> locs = getEmoteLocs(player.getPos().subtract(0, player.isSneaking() ? .5 : 0, 0),
|
||||
emotes.get(emote), player.getRotationVector());
|
||||
for (Vec3d loc : locs) {
|
||||
player.getServerWorld().spawnParticles(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f),
|
||||
loc.x, loc.y, loc.z, 15, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Vec3d> getEmoteLocs(Vec3d loc, String[] ttEmote, Vec3d rotationLoc) {
|
||||
List<List<Vec3d>> locations = new ArrayList<>();
|
||||
int y = 0;
|
||||
int distance = 10;
|
||||
for (String s : ttEmote) {
|
||||
List<Integer> emoteTextLine = textToEmote(s);
|
||||
List<Vec3d> addLocs = new ArrayList<>();
|
||||
for (int x = 0; x < emoteTextLine.size(); x++) {
|
||||
float y2 = (float) y / ((float) distance / 2);
|
||||
float side = (((float) emoteTextLine.get(x) / distance) - ((float) ttEmote[0].length()) / 2 / distance);
|
||||
Vec3d idfk = rotationLoc.normalize();
|
||||
Vec3d rotation = new Vec3d(idfk.x, 0, idfk.z);
|
||||
Vec3d rot = rotation.crossProduct(new Vec3d(0, side, 0));
|
||||
Vec3d addLoc = loc.add(rot);
|
||||
Vec3d newAloc = new Vec3d(addLoc.x, loc.getY() + ((float) ttEmote.length / distance - y2 + 2.25),
|
||||
addLoc.y);
|
||||
addLocs.add(newAloc);
|
||||
}
|
||||
locations.add(addLocs);
|
||||
y++;
|
||||
}
|
||||
|
||||
List<Vec3d> locs = new ArrayList<>();
|
||||
|
||||
for (List<Vec3d> listLocs : locations) {
|
||||
locs.addAll(listLocs);
|
||||
}
|
||||
|
||||
return locs;
|
||||
}
|
||||
|
||||
private static List<Integer> textToEmote(String textToEmote) {
|
||||
List<Integer> locs = new ArrayList<>();
|
||||
for (int i = 0; i < textToEmote.length(); i++) {
|
||||
char l = textToEmote.charAt(i);
|
||||
String letter = String.valueOf(l);
|
||||
if (letter.equals("1")) {
|
||||
locs.add(i);
|
||||
}
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
public void playEmote(UUID uuid, ServerPlayerEntity entity, Emotes emote) {
|
||||
this.players.put(uuid, new PlayerEmote(entity, emote));
|
||||
}
|
||||
|
||||
public void stopEmote(UUID uuid) {
|
||||
this.players.remove(uuid);
|
||||
}
|
||||
|
||||
public boolean isPlayerEmoting(UUID uuid) {
|
||||
return this.players.containsKey(uuid);
|
||||
}
|
||||
}
|
|
@ -3,13 +3,13 @@
|
|||
"id": "animal-rp",
|
||||
"version": "${version}",
|
||||
"name": "Animal RP",
|
||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
||||
"description": "furry minecraft mod",
|
||||
"authors": [
|
||||
"Me!"
|
||||
"sophie"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
"homepage": "https://sad.ovh",
|
||||
"sources": "https://git.sad.ovh/sophie/animalrpfabric"
|
||||
},
|
||||
"license": "CC0-1.0",
|
||||
"icon": "assets/animal-rp/icon.png",
|
||||
|
@ -24,7 +24,7 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.16.4",
|
||||
"minecraft": "~1.21.1",
|
||||
"minecraft": "~1.21.4",
|
||||
"java": ">=21",
|
||||
"fabric-api": "*"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue