-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39a389c
commit ff7da47
Showing
10 changed files
with
115 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/net/fabricmc/smphack/Hacks/Fakeplayer/FakePlayerCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.fabricmc.smphack.Hacks.Fakeplayer; | ||
|
||
import com.mojang.brigadier.arguments.StringArgumentType; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
import net.minecraft.client.MinecraftClient; | ||
|
||
public class FakePlayerCommand { | ||
private static String fakeplayername="FakePlayer"; | ||
public static void register() { | ||
ClientCommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { | ||
LiteralArgumentBuilder<FabricClientCommandSource> fakeplayer = ClientCommandManager.literal("fakeplayer") | ||
.then(ClientCommandManager.literal("spawn") | ||
.then(ClientCommandManager.argument("name", StringArgumentType.string()) | ||
.executes(context -> { | ||
assert MinecraftClient.getInstance().player != null; | ||
fakeplayername = StringArgumentType.getString(context, "name"); | ||
System.out.println("Called Spawn with name: " + fakeplayername); | ||
FakePlayerEntity.getInstance(fakeplayername).spawn(MinecraftClient.getInstance().player); | ||
return 1; | ||
}))) | ||
.then(ClientCommandManager.literal("clear").executes(context -> { | ||
FakePlayerEntity.getInstance(fakeplayername).clear(); | ||
return 1; | ||
})); | ||
|
||
dispatcher.register(fakeplayer); | ||
}); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/net/fabricmc/smphack/Hacks/Fakeplayer/FakePlayerEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.fabricmc.smphack.Hacks.Fakeplayer; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.OtherClientPlayerEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class FakePlayerEntity extends OtherClientPlayerEntity { | ||
private static FakePlayerEntity instance; | ||
private static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
|
||
public static FakePlayerEntity getInstance(String name) { | ||
if (instance != null) { | ||
instance.clear(); | ||
} | ||
instance = new FakePlayerEntity(name); | ||
return instance; | ||
} | ||
private FakePlayerEntity(String name) { | ||
super(Objects.requireNonNull(mc.world), new GameProfile(UUID.randomUUID(), name)); | ||
this.setHealth(20f); | ||
this.setInvisible(false); | ||
this.setInvulnerable(true); | ||
} | ||
|
||
public void spawn(PlayerEntity player) { | ||
this.copyPositionAndRotation(player); | ||
Byte playerModel = player.getDataTracker().get(PlayerEntity.PLAYER_MODEL_PARTS); | ||
dataTracker.set(PlayerEntity.PLAYER_MODEL_PARTS, playerModel); | ||
this.getAttributes().setFrom(player.getAttributes()); | ||
this.setPose(player.getPose()); | ||
this.getInventory().clone(player.getInventory()); | ||
assert mc.world != null; | ||
mc.world.addEntity(getId(), this); | ||
System.out.println("FakePlayer Spawned Instance: " + this); | ||
} | ||
public void clear() { | ||
this.kill(); | ||
assert mc.world != null; | ||
mc.world.removeEntity(getId(), RemovalReason.DISCARDED); | ||
setRemoved(RemovalReason.DISCARDED); | ||
instance = null; | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters