Skip to content

Commit 0e74b6f

Browse files
committed
Version 1.3
1 parent 497d539 commit 0e74b6f

File tree

98 files changed

+5175
-2057
lines changed

Some content is hidden

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

98 files changed

+5175
-2057
lines changed

CHANGELOG.txt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
===Version 1.3===
2+
-Changes to command structure - split "/mocap recording" into "recording" and "recordings".
3+
-Added commands to rename, copy and get information about recordings and scenes.
4+
-Added commands to modify and get information about scene elements.
5+
-Skins can now be set from another player (without changing fake player name) or from a local file (proposed by Live_CK).
6+
-Player model can now be swapped with the other entity by editing scene element (proposed by cucurbito).
7+
-Entities other than player are now recorded.
8+
-Player riding other entity is now properly recorded (mentioned by Snownee, M7MEDpro, Afirmaran1010, erixon_07).
9+
-Hurting player or other entities is now recorded.
10+
-Player death is now recorded.
11+
-Placing double blocks (like beds or doors) is now properly recorded.
12+
-Block destroying progress is now recorded.
13+
-Arrow and bee stinger count are now recorded.
14+
-Potion effects are now recorded.
15+
-Sleeping is now properly recorded.
16+
-Added option to make fake player not collide with other entities (proposed by Snownee).
17+
-Added suggestions for recording and scene names in commands.
18+
-Added setting "trackVehicleEntities" which enables tracking vehicle entities (enabled by default).
19+
-Added setting "trackItemEntities" which enables tracking item (enabled by default).
20+
-Added setting "trackOtherEntities" which enables tracking entities other than vehicles and items (disabled by default).
21+
-Added setting "trackPlayedEntities" which enables tracking entities that are currently played (disabled by default).
22+
-Added settings "playVehicleEntities", "playItemEntities" and "playOtherEntities" which are counterparts of "track..." settings but for playback (all are enabled by default).
23+
-Added setting "entityTrackingDistance" which controls entity tracking distance (128 by default, the number represents the distance from the player in blocks, 0 disables tracking and -1 disables limit).
24+
-Added setting "entitiesAfterPlayback" which determines what will happen with entities after playback (1 by default, -1 - will be released as a normal entity, 0 - will be left untouched, 1 - will be removed, 2 - will be killed with animation).
25+
-Added setting "preventSavingEntities" which prevents game from saving played entities in case of for example leaving game (enabled by default).
26+
-Added setting "dropFromBlocks" which enables drop from blocks (disabled by default - recommended with "playItemEntities" disabled to prevent duplicates).
27+
-Added setting "useCreativeGameMode" which sets fake players game mode to creative therefore making monsters ignore then (disabled by default).
28+
-Added setting "recordPlayerDeath" (enabled by default).
29+
-Fixed message about recording start being sent to recorded player instead of player who started recording.
30+
-Updated help message.
31+
-Stack trace of some non-critical, unknown exceptions is now logged.
32+
133
===Version 1.2.1===
234
-Fixed a compatibility issue causing skin top layer not being visible (thanks KlashRaick, JLUsr and efi1212 for reporting).
335
-Fixed fake players not being removed from the server level causing memory leaks, performance issues, strange mob behaviour, problems with placing blocks, blocks staying activated and probably many other bad things (thanks KlashRaick for reporting).
@@ -11,7 +43,7 @@
1143
-Added setting "allowMineskinRequests" which by default is enabled and allows HTTPS requests to mineskin.org to load skins.
1244
-Added optional argument "mineskinURL" to "/mocap scenes addTo" that can be used to set skin from the mineskin.org URL.
1345
-Added optional arguments "playerName" and "mineskinURL" to "/mocap playing start".
14-
-Removed "startPos" optional argument from "/mocap playing start" (it didn't work anyway)
46+
-Removed "startPos" optional argument from "/mocap playing start" (it didn't work anyway).
1547
-Item enchantments are now recorded.
1648
-Using off-hand item or trident with riptide enchantment is now properly recorded.
1749
-Fake players can now interact with pressure plates and tripwires.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ CurseForge page: https://www.curseforge.com/minecraft/mc-mods/motion-capture-mod
1919
- Then, you can stop recording using ```/mocap recording stop``` and save it with ```/mocap recording save <name>```.
2020
- Use ```/mocap playing start <name>``` to play recording.
2121
- You can also create scenes to which you can add multiple recordings or other scenes, with parameters like player name, position offset, or start delay.
22-
- To create scene use ```/mocap scenes add <scene_name>```. Then, add your recording using ```/mocap scenes addTo <scene_name> <recording_name> [delay] [x_offset] [y_offset] [z_offset] [player_name]``` (you can skip arguments in square brackets if you want).
22+
- To create scene use ```/mocap scenes add <scene_name>```. Then, add your recording using ```/mocap scenes addTo <scene_name> <recording_name> [delay] [x_offset] [y_offset] [z_offset] [player_name] [skin_source_type] [skin_source]``` (you can skip arguments in square brackets if you want).
2323
- To play scene use ```/mocap playing start .<scene_name>``` - you need to put a dot before the scene name.
2424
- By putting a dot before name, when using ```/mocap scenes addTo (...)```, you can also add scenes to other scenes.
2525

2626
### Commands
2727
```
2828
/mocap recording [...] - Recording player movements
29+
/mocap recordings [...] - Managing recording files
2930
/mocap scenes [...] - Creating and modifying scenes
3031
/mocap playing [...] - Playing scenes and recordings
3132
/mocap settings [...] - Shows and modifies settings

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.1
5+
forge_version=47.0.45
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.2.1
17+
mod_version=1.3
1818

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

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

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.mt1006.mocap;
22

3+
import com.mt1006.mocap.mocap.actions.Action;
34
import com.mt1006.mocap.network.MocapPackets;
45
import com.mt1006.mocap.utils.Fields;
56
import net.minecraftforge.common.MinecraftForge;
67
import net.minecraftforge.eventbus.api.SubscribeEvent;
78
import net.minecraftforge.fml.common.Mod;
89
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
10+
import net.minecraftforge.fml.loading.FMLEnvironment;
911
import org.apache.logging.log4j.LogManager;
1012
import org.apache.logging.log4j.Logger;
1113

@@ -14,10 +16,11 @@
1416
public class MocapMod
1517
{
1618
public static final String MOD_ID = "mocap";
17-
public static final String VERSION = "1.2.1";
19+
public static final String VERSION = "1.3";
1820
public static final String FOR_VERSION = "1.20.1";
1921
public static final String FOR_LOADER = "Forge";
2022
public static final Logger LOGGER = LogManager.getLogger();
23+
public static final boolean isDedicatedServer = FMLEnvironment.dist.isDedicatedServer();
2124

2225
public MocapMod()
2326
{
@@ -30,6 +33,7 @@ public static void setup(final FMLCommonSetupEvent event)
3033
MocapMod.LOGGER.info(getFullName() + " - Author: mt1006 (mt1006x)");
3134
Fields.init();
3235
MocapPackets.register();
36+
Action.init();
3337
}
3438

3539
public static String getName()
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package com.mt1006.mocap.command;
2+
3+
import com.mojang.brigadier.Command;
4+
import com.mojang.brigadier.arguments.StringArgumentType;
5+
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
6+
import com.mojang.brigadier.context.CommandContext;
7+
import com.mojang.brigadier.context.CommandContextBuilder;
8+
import com.mojang.brigadier.context.ParsedCommandNode;
9+
import com.mt1006.mocap.mocap.playing.PlayerData;
10+
import com.mt1006.mocap.utils.Utils;
11+
import net.minecraft.commands.CommandSourceStack;
12+
import net.minecraft.commands.Commands;
13+
import org.apache.commons.lang3.function.TriFunction;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
import java.util.List;
17+
import java.util.function.BiFunction;
18+
import java.util.function.Function;
19+
20+
public class CommandUtils
21+
{
22+
public static RequiredArgumentBuilder<CommandSourceStack, String> withPlayerArguments(Command<CommandSourceStack> command)
23+
{
24+
return Commands.argument("playerName", StringArgumentType.string()).executes(command)
25+
.then(Commands.literal("from_player").then(Commands.argument("skinPlayerName", StringArgumentType.greedyString()).executes(command)))
26+
.then(Commands.literal("from_file").then(Commands.argument("skinFilename", StringArgumentType.greedyString()).executes(command)))
27+
.then(Commands.literal("from_mineskin").then(Commands.argument("mineskinURL", StringArgumentType.greedyString()).executes(command)));
28+
}
29+
30+
public static @Nullable String getString(CommandContext<?> ctx, String name)
31+
{
32+
try { return StringArgumentType.getString(ctx, name); }
33+
catch (Exception exception) { return null; }
34+
}
35+
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)
59+
{
60+
return Commands.argument(arg, StringArgumentType.string()).executes((ctx) -> stringCommand(function, ctx, arg));
61+
}
62+
63+
public static RequiredArgumentBuilder<CommandSourceStack, String> withTwoStringArguments(TriFunction<CommandSourceStack, String, String, Boolean> function, String arg1, String arg2)
64+
{
65+
return Commands.argument(arg1, StringArgumentType.string())
66+
.then(Commands.argument(arg2, StringArgumentType.string())
67+
.executes((ctx) -> twoStringCommand(function, ctx, arg1, arg2)));
68+
}
69+
70+
private static int stringCommand(BiFunction<CommandSourceStack, String, Boolean> function, CommandContext<CommandSourceStack> ctx, String arg)
71+
{
72+
try
73+
{
74+
String name = StringArgumentType.getString(ctx, arg);
75+
return function.apply(ctx.getSource(), name) ? 1 : 0;
76+
}
77+
catch (Exception exception)
78+
{
79+
Utils.sendException(exception, ctx.getSource(), "mocap.error.unable_to_get_argument");
80+
return 0;
81+
}
82+
}
83+
84+
private static int twoStringCommand(TriFunction<CommandSourceStack, String, String, Boolean> function, CommandContext<CommandSourceStack> ctx, String arg1, String arg2)
85+
{
86+
try
87+
{
88+
String name1 = StringArgumentType.getString(ctx, arg1);
89+
String name2 = StringArgumentType.getString(ctx, arg2);
90+
return function.apply(ctx.getSource(), name1, name2) ? 1 : 0;
91+
}
92+
catch (Exception exception)
93+
{
94+
Utils.sendException(exception, ctx.getSource(), "mocap.error.unable_to_get_argument");
95+
return 0;
96+
}
97+
}
98+
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+
111+
public static <T> @Nullable CommandContextBuilder<T> getFinalCommandContext(CommandContextBuilder<T> ctx)
112+
{
113+
while (true)
114+
{
115+
String command = getCommandNode(ctx, 0);
116+
if (command != null && (command.equals("mocap") || command.equals("mocap:mocap"))) { return ctx; }
117+
118+
ctx = ctx.getChild();
119+
if (ctx == null) { return null; }
120+
}
121+
}
122+
123+
public static @Nullable String getCommandNode(CommandContext<?> ctx, int pos)
124+
{
125+
return getCommandNode(ctx.getNodes(), pos);
126+
}
127+
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)
134+
{
135+
int size = nodes.size();
136+
if (pos < 0) { pos += size; }
137+
if (pos >= size || pos < 0) { return null; }
138+
return nodes.get(pos).getNode().getName();
139+
}
140+
}

0 commit comments

Comments
 (0)