Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
Soph :3 | 2d19c77199 |
|
@ -8,11 +8,9 @@ import ovh.sad.animalrp.animals.Cat;
|
||||||
import ovh.sad.animalrp.animals.Dog;
|
import ovh.sad.animalrp.animals.Dog;
|
||||||
import ovh.sad.animalrp.animals.Fox;
|
import ovh.sad.animalrp.animals.Fox;
|
||||||
import ovh.sad.animalrp.animals.Bee;
|
import ovh.sad.animalrp.animals.Bee;
|
||||||
import ovh.sad.animalrp.commands.EmoteCommand;
|
|
||||||
import ovh.sad.animalrp.commands.InteractionCommand;
|
import ovh.sad.animalrp.commands.InteractionCommand;
|
||||||
import ovh.sad.animalrp.commands.NoChatCommand;
|
import ovh.sad.animalrp.commands.NoChatCommand;
|
||||||
import ovh.sad.animalrp.commands.TfCommand;
|
import ovh.sad.animalrp.commands.TfCommand;
|
||||||
import ovh.sad.animalrp.util.Emote;
|
|
||||||
import ovh.sad.animalrp.util.Mood;
|
import ovh.sad.animalrp.util.Mood;
|
||||||
import eu.pb4.placeholders.api.PlaceholderContext;
|
import eu.pb4.placeholders.api.PlaceholderContext;
|
||||||
import eu.pb4.placeholders.api.PlaceholderHandler;
|
import eu.pb4.placeholders.api.PlaceholderHandler;
|
||||||
|
@ -35,7 +33,6 @@ public class AnimalRP implements ModInitializer {
|
||||||
public static HashMap<UUID, Animal> users = new HashMap<>();
|
public static HashMap<UUID, Animal> users = new HashMap<>();
|
||||||
public static HashMap<UUID, Boolean> noChat = new HashMap<>();
|
public static HashMap<UUID, Boolean> noChat = new HashMap<>();
|
||||||
public static HashMap<String, Animal> animals = 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 String MOD_ID = "animal-rp";
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
@ -45,7 +42,6 @@ public class AnimalRP implements ModInitializer {
|
||||||
animals.put("dog", new Dog());
|
animals.put("dog", new Dog());
|
||||||
animals.put("fox", new Fox());
|
animals.put("fox", new Fox());
|
||||||
animals.put("bee", new Bee());
|
animals.put("bee", new Bee());
|
||||||
emotes = new Emote();
|
|
||||||
|
|
||||||
Placeholders.register(Identifier.of("animalrp", "animalcolor"), new PlaceholderHandler() {
|
Placeholders.register(Identifier.of("animalrp", "animalcolor"), new PlaceholderHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +58,6 @@ public class AnimalRP implements ModInitializer {
|
||||||
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 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")).Command(dispatcher, registryAccess, environment);
|
||||||
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s")).Command(dispatcher, registryAccess, environment);
|
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s")).Command(dispatcher, registryAccess, environment);
|
||||||
|
|
|
@ -1,65 +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("<red>Stopped emoting.").withColor(8421504), false);
|
|
||||||
AnimalRP.emotes.stopEmote(player.getUuid());
|
|
||||||
} else {
|
|
||||||
context.getSource().sendFeedback(() -> Text.literal("<green>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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,162 +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) {
|
|
||||||
for(int i =0; i < 15; i ++) {
|
|
||||||
player.getWorld().addParticle(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f), loc.x,
|
|
||||||
loc.y, loc.z, 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.y);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue