Skip to content

Commit ecc0d3b

Browse files
committed
Version 1.3.1
1 parent 0e74b6f commit ecc0d3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+893
-819
lines changed

CHANGELOG.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
===Version 1.3.1===
2+
-Added settings "fluentMovements" controlling distance to played entity for player to receive additional packets for more fluent movements (32 by default).
3+
-Fixed entity data synchronization issues.
4+
-Fixed packets being sent to players far away from played entities.
5+
-Fixed issue with horse armor not being set properly (reported by M7MEDpro).
6+
-Fixed issues with players position being offset during playback on versions 1.19.4 and 1.20.1.
7+
-Fixed horse variant resetting to default or chest disappearing on horse-like entities when their mouth "is open" on versions 1.19.2 and lower.
8+
-Fixed llama variants not being recorded on versions 1.19.2 and lower, on Fabric.
9+
-Fixed setting "preventSavingEntities" not preventing saving entities on version 1.16.5.
10+
-Fixes for loading skin from a file.
11+
112
===Version 1.3===
213
-Changes to command structure - split "/mocap recording" into "recording" and "recordings".
314
-Added commands to rename, copy and get information about recordings and scenes.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G
22
org.gradle.daemon=false
33

44
minecraft_version=1.20.1
5-
forge_version=47.0.45
5+
forge_version=47.1.0
66

77
minecraft_version_range=[1.20,1.20.2)
88
forge_version_range=[46,)
@@ -14,7 +14,7 @@ mapping_version=1.20.1
1414

1515
## Mod Properties
1616
mod_id=mocap
17-
mod_version=1.3
17+
mod_version=1.3.1
1818

1919
mod_group_id=com.mt1006.mocap
2020
mod_jar_name=Mocap

settings.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
pluginManagement
22
{
3-
repositories
4-
{
5-
gradlePluginPortal()
6-
maven
7-
{
8-
name = 'MinecraftForge'
9-
url = 'https://maven.minecraftforge.net/'
10-
}
11-
}
3+
repositories
4+
{
5+
gradlePluginPortal()
6+
maven
7+
{
8+
name = 'MinecraftForge'
9+
url = 'https://maven.minecraftforge.net/'
10+
}
11+
}
1212
}
1313

1414
plugins
1515
{
16-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
16+
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
1717
}

src/main/java/com/mt1006/mocap/MocapMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class MocapMod
1717
{
1818
public static final String MOD_ID = "mocap";
19-
public static final String VERSION = "1.3";
19+
public static final String VERSION = "1.3.1";
2020
public static final String FOR_VERSION = "1.20.1";
2121
public static final String FOR_LOADER = "Forge";
2222
public static final Logger LOGGER = LogManager.getLogger();
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.mt1006.mocap.command;
2+
3+
import com.mojang.authlib.GameProfile;
4+
import com.mojang.brigadier.arguments.BoolArgumentType;
5+
import com.mojang.brigadier.arguments.DoubleArgumentType;
6+
import com.mojang.brigadier.arguments.IntegerArgumentType;
7+
import com.mojang.brigadier.arguments.StringArgumentType;
8+
import com.mojang.brigadier.context.CommandContext;
9+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
10+
import com.mt1006.mocap.mocap.playing.PlayerData;
11+
import com.mt1006.mocap.utils.Utils;
12+
import net.minecraft.commands.CommandSourceStack;
13+
import net.minecraft.commands.arguments.GameProfileArgument;
14+
import net.minecraft.network.chat.Component;
15+
import org.jetbrains.annotations.Nullable;
16+
17+
import java.util.Collection;
18+
19+
public class CommandInfo extends CommandOutput
20+
{
21+
public final CommandContext<CommandSourceStack> ctx;
22+
public final CommandSourceStack source;
23+
24+
public CommandInfo(CommandContext<CommandSourceStack> ctx)
25+
{
26+
this.ctx = ctx;
27+
this.source = ctx.getSource();
28+
}
29+
30+
@Override public void sendSuccess(String component, Object... args)
31+
{
32+
source.sendSuccess(() -> Utils.getTranslatableComponent(source.getEntity(), component, args), false);
33+
}
34+
35+
@Override public void sendSuccessLiteral(String format, Object... args)
36+
{
37+
source.sendSuccess(() -> Component.literal(String.format(format, args)), false);
38+
}
39+
40+
@Override public void sendSuccessComponent(Component component)
41+
{
42+
source.sendSuccess(() -> component, false);
43+
}
44+
45+
@Override public void sendFailure(String component, Object... args)
46+
{
47+
source.sendFailure(Utils.getTranslatableComponent(source.getEntity(), component, args));
48+
}
49+
50+
@Override public void sendException(Exception exception, String component, Object... args)
51+
{
52+
sendFailure(component, args);
53+
Utils.exception(exception, Utils.stringFromComponent(component, args));
54+
}
55+
56+
public @Nullable CommandInfo getFinalCommandInfo()
57+
{
58+
CommandContext<CommandSourceStack> tempCtx = ctx;
59+
while (true)
60+
{
61+
String command = CommandUtils.getNode(tempCtx.getNodes(), 0);
62+
if (command != null && (command.equals("mocap") || command.equals("mocap:mocap"))) { return new CommandInfo(tempCtx); }
63+
64+
tempCtx = ctx.getChild();
65+
if (tempCtx == null) { return null; }
66+
}
67+
}
68+
69+
public @Nullable String getNode(int pos)
70+
{
71+
return CommandUtils.getNode(ctx.getNodes(), pos);
72+
}
73+
74+
public int getInteger(String name)
75+
{
76+
return IntegerArgumentType.getInteger(ctx, name);
77+
}
78+
79+
public double getDouble(String name)
80+
{
81+
return DoubleArgumentType.getDouble(ctx, name);
82+
}
83+
84+
public boolean getBool(String name)
85+
{
86+
return BoolArgumentType.getBool(ctx, name);
87+
}
88+
89+
public String getString(String name)
90+
{
91+
return StringArgumentType.getString(ctx, name);
92+
}
93+
94+
public Collection<GameProfile> getGameProfiles(String name) throws CommandSyntaxException
95+
{
96+
return GameProfileArgument.getGameProfiles(ctx, name);
97+
}
98+
99+
public @Nullable String getNullableString(String name)
100+
{
101+
try { return StringArgumentType.getString(ctx, name); }
102+
catch (Exception exception) { return null; }
103+
}
104+
105+
public PlayerData getPlayerData()
106+
{
107+
String playerName = getNullableString("playerName");
108+
if (playerName == null) { return new PlayerData((String)null); }
109+
110+
String fromPlayer = getNullableString("skinPlayerName");
111+
if (fromPlayer != null) { return new PlayerData(playerName, PlayerData.SkinSource.FROM_PLAYER, fromPlayer); }
112+
113+
String fromFile = getNullableString("skinFilename");
114+
if (fromFile != null) { return new PlayerData(playerName, PlayerData.SkinSource.FROM_FILE, fromFile); }
115+
116+
String fromMineskin = getNullableString("mineskinURL");
117+
if (fromMineskin != null) { return new PlayerData(playerName, PlayerData.SkinSource.FROM_MINESKIN, fromMineskin); }
118+
119+
return new PlayerData(playerName);
120+
}
121+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.mt1006.mocap.command;
2+
3+
import net.minecraft.network.chat.Component;
4+
5+
public class CommandOutput
6+
{
7+
public static final CommandOutput DUMMY = new CommandOutput();
8+
9+
public void sendSuccess(String component, Object... args) {}
10+
11+
public void sendSuccessLiteral(String format, Object... args) {}
12+
13+
public void sendSuccessComponent(Component component) {}
14+
15+
public void sendFailure(String component, Object... args) {}
16+
17+
public void sendException(Exception exception, String component, Object... args) {}
18+
}

src/main/java/com/mt1006/mocap/command/CommandUtils.java

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
import com.mojang.brigadier.context.CommandContext;
77
import com.mojang.brigadier.context.CommandContextBuilder;
88
import com.mojang.brigadier.context.ParsedCommandNode;
9-
import com.mt1006.mocap.mocap.playing.PlayerData;
10-
import com.mt1006.mocap.utils.Utils;
119
import net.minecraft.commands.CommandSourceStack;
1210
import net.minecraft.commands.Commands;
13-
import org.apache.commons.lang3.function.TriFunction;
1411
import org.jetbrains.annotations.Nullable;
1512

1613
import java.util.List;
@@ -27,114 +24,81 @@ public static RequiredArgumentBuilder<CommandSourceStack, String> withPlayerArgu
2724
.then(Commands.literal("from_mineskin").then(Commands.argument("mineskinURL", StringArgumentType.greedyString()).executes(command)));
2825
}
2926

30-
public static @Nullable String getString(CommandContext<?> ctx, String name)
27+
public static Command<CommandSourceStack> command(Function<CommandInfo, Boolean> function)
3128
{
32-
try { return StringArgumentType.getString(ctx, name); }
33-
catch (Exception exception) { return null; }
29+
return (ctx) -> (function.apply(new CommandInfo(ctx)) ? 1 : 0);
3430
}
3531

36-
public static PlayerData getPlayerData(CommandContext<?> ctx)
37-
{
38-
String playerName = getString(ctx, "playerName");
39-
if (playerName == null) { return new PlayerData((String)null); }
40-
41-
String fromPlayer = getString(ctx, "skinPlayerName");
42-
if (fromPlayer != null) { return new PlayerData(playerName, PlayerData.SkinSource.FROM_PLAYER, fromPlayer); }
43-
44-
String fromFile = getString(ctx, "skinFilename");
45-
if (fromFile != null) { return new PlayerData(playerName, PlayerData.SkinSource.FROM_FILE, fromFile); }
46-
47-
String fromMineskin = getString(ctx, "mineskinURL");
48-
if (fromMineskin != null) { return new PlayerData(playerName, PlayerData.SkinSource.FROM_MINESKIN, fromMineskin); }
49-
50-
return new PlayerData(playerName);
51-
}
52-
53-
public static Command<CommandSourceStack> simpleCommand(Function<CommandSourceStack, Boolean> function)
54-
{
55-
return (ctx) -> (function.apply(ctx.getSource()) ? 1 : 0);
56-
}
57-
58-
public static RequiredArgumentBuilder<CommandSourceStack, String> withStringArgument(BiFunction<CommandSourceStack, String, Boolean> function, String arg)
32+
public static RequiredArgumentBuilder<CommandSourceStack, String> withStringArgument(BiFunction<CommandInfo, String, Boolean> function, String arg)
5933
{
6034
return Commands.argument(arg, StringArgumentType.string()).executes((ctx) -> stringCommand(function, ctx, arg));
6135
}
6236

63-
public static RequiredArgumentBuilder<CommandSourceStack, String> withTwoStringArguments(TriFunction<CommandSourceStack, String, String, Boolean> function, String arg1, String arg2)
37+
public static RequiredArgumentBuilder<CommandSourceStack, String> withTwoStringArguments(TriFunction<CommandInfo, String, String, Boolean> function, String arg1, String arg2)
6438
{
6539
return Commands.argument(arg1, StringArgumentType.string())
6640
.then(Commands.argument(arg2, StringArgumentType.string())
6741
.executes((ctx) -> twoStringCommand(function, ctx, arg1, arg2)));
6842
}
6943

70-
private static int stringCommand(BiFunction<CommandSourceStack, String, Boolean> function, CommandContext<CommandSourceStack> ctx, String arg)
44+
private static int stringCommand(BiFunction<CommandInfo, String, Boolean> function, CommandContext<CommandSourceStack> ctx, String arg)
7145
{
46+
CommandInfo commandInfo = new CommandInfo(ctx);
7247
try
7348
{
7449
String name = StringArgumentType.getString(ctx, arg);
75-
return function.apply(ctx.getSource(), name) ? 1 : 0;
50+
return function.apply(commandInfo, name) ? 1 : 0;
7651
}
7752
catch (Exception exception)
7853
{
79-
Utils.sendException(exception, ctx.getSource(), "mocap.error.unable_to_get_argument");
54+
commandInfo.sendException(exception, "mocap.error.unable_to_get_argument");
8055
return 0;
8156
}
8257
}
8358

84-
private static int twoStringCommand(TriFunction<CommandSourceStack, String, String, Boolean> function, CommandContext<CommandSourceStack> ctx, String arg1, String arg2)
59+
private static int twoStringCommand(TriFunction<CommandInfo, String, String, Boolean> function, CommandContext<CommandSourceStack> ctx, String arg1, String arg2)
8560
{
61+
CommandInfo commandInfo = new CommandInfo(ctx);
8662
try
8763
{
8864
String name1 = StringArgumentType.getString(ctx, arg1);
8965
String name2 = StringArgumentType.getString(ctx, arg2);
90-
return function.apply(ctx.getSource(), name1, name2) ? 1 : 0;
66+
return function.apply(commandInfo, name1, name2) ? 1 : 0;
9167
}
9268
catch (Exception exception)
9369
{
94-
Utils.sendException(exception, ctx.getSource(), "mocap.error.unable_to_get_argument");
70+
commandInfo.sendException(exception, "mocap.error.unable_to_get_argument");
9571
return 0;
9672
}
9773
}
9874

99-
public static <T> @Nullable CommandContext<T> getFinalCommandContext(CommandContext<T> ctx)
100-
{
101-
while (true)
102-
{
103-
String command = getCommandNode(ctx, 0);
104-
if (command != null && (command.equals("mocap") || command.equals("mocap:mocap"))) { return ctx; }
105-
106-
ctx = ctx.getChild();
107-
if (ctx == null) { return null; }
108-
}
109-
}
110-
11175
public static <T> @Nullable CommandContextBuilder<T> getFinalCommandContext(CommandContextBuilder<T> ctx)
11276
{
11377
while (true)
11478
{
115-
String command = getCommandNode(ctx, 0);
79+
String command = getNode(ctx, 0);
11680
if (command != null && (command.equals("mocap") || command.equals("mocap:mocap"))) { return ctx; }
11781

11882
ctx = ctx.getChild();
11983
if (ctx == null) { return null; }
12084
}
12185
}
12286

123-
public static @Nullable String getCommandNode(CommandContext<?> ctx, int pos)
87+
public static @Nullable String getNode(CommandContextBuilder<?> ctx, int pos)
12488
{
125-
return getCommandNode(ctx.getNodes(), pos);
89+
return getNode(ctx.getNodes(), pos);
12690
}
12791

128-
public static @Nullable String getCommandNode(CommandContextBuilder<?> ctx, int pos)
129-
{
130-
return getCommandNode(ctx.getNodes(), pos);
131-
}
132-
133-
private static @Nullable String getCommandNode(List<? extends ParsedCommandNode<?>> nodes, int pos)
92+
public static @Nullable String getNode(List<? extends ParsedCommandNode<?>> nodes, int pos)
13493
{
13594
int size = nodes.size();
13695
if (pos < 0) { pos += size; }
13796
if (pos >= size || pos < 0) { return null; }
13897
return nodes.get(pos).getNode().getName();
13998
}
99+
100+
public interface TriFunction<T, U, V, R>
101+
{
102+
R apply(T t, U u, V v);
103+
}
140104
}

0 commit comments

Comments
 (0)