Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirasawaSama committed Sep 5, 2021
1 parent 97eedec commit a035d60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Allow StoneCutter to hurt player.
- Allow Shulkers spawn in end cities.
- Allow player to leash villagers.
- Send fake permission level 4 packet to player.
- Add `/mspt <ms>` command to modify tps.
- Modify server mod name.

Expand All @@ -32,6 +33,7 @@ java -javaagent:NekoAgent-1.0-SNAPSHOT.jar=enableStoneCutterDamage+enableShulker
- enableShulkerSpawningInEndCities
- enableLeashableViallagers
- enableSetMSPTCommand
- enableFakeLevel4Permission
- maxShulkersCount=4
- minShulkersCount=1

Expand Down
13 changes: 12 additions & 1 deletion src/main/java/cn/apisium/nekoagent/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

public final class Main {
private static boolean enableSandDuplication, disableObsidianSpikesReset, enableStoneCutterDamage,
enableShulkerSpawningInEndCities, enableSetMSPTCommand, enableLeashableViallagers;
enableShulkerSpawningInEndCities, enableSetMSPTCommand, enableLeashableViallagers,
enableFakePermissionLevel4;
private static String serverName;
private static int maxShulkersCount = 4, minShulkersCount = 1;
private final static ClassPool pool = ClassPool.getDefault();
Expand All @@ -29,6 +30,7 @@ public static void premain(final String agentArgs, final Instrumentation inst) {
if (agentArgs.contains("enableSetMSPTCommand")) enableSetMSPTCommand = true;
if (agentArgs.contains("enableShulkerSpawningInEndCities")) enableShulkerSpawningInEndCities = true;
if (agentArgs.contains("enableLeashableViallagers")) enableLeashableViallagers = true;
if (agentArgs.contains("enableFakeLevel4Permission")) enableFakePermissionLevel4 = true;
Matcher matcher = Pattern.compile("maxShulkersCount=(\\d+)").matcher(agentArgs);
if (matcher.find()) maxShulkersCount = Integer.parseInt(matcher.group(1));
matcher = Pattern.compile("minShulkersCount=(\\d+)").matcher(agentArgs);
Expand Down Expand Up @@ -89,6 +91,15 @@ public byte[] transform(final ClassLoader loader, String className, final Class<
className = className.replace('/', '.');
final CtClass clazz;
switch (className) {
case "net.minecraft.network.protocol.game.PacketPlayOutEntityStatus":
if (!enableFakePermissionLevel4) return null;
try {
pool.insertClassPath(new LoaderClassPath(loader));
clazz = pool.get(className);
clazz.getConstructor(buildDesc(null, "net.minecraft.world.entity.Entity", "B"))
.insertBefore("{ if ($2 > 23 && $2 < 28) $2 = 28; }");
break;
} catch (Throwable e) { throw new RuntimeException(e); }
case "net.minecraft.world.entity.Entity":
if (!enableSandDuplication) return null;
try {
Expand Down

0 comments on commit a035d60

Please sign in to comment.