📄
pasted-code-1776513853200.txt
txt
26 lines
▶
I want to create a fake player (NPC) that joins the game and behaves in a creepy, mysterious way.
Behavior:
When the fake player spawns, it should automatically detect and focus on the nearest real player.
It should move toward that player but maintain a distance:
Maximum distance: 60 blocks
Minimum distance: 15 blocks
If the fake player is farther than 60 blocks, it should move closer.
If it is within 15 blocks, it must stop moving and only look at the player, constantly tracking their position.
Appearance & Identity:
The fake player should have a strange, unknown-looking name (using glitched or unusual Unicode characters if possible).
The overall vibe should feel unsettling, eerie, and mysterious.
Reactions:
When hit: send the message "stop" in chat
When below 50% health: send "STOP" in chat
Upon death:
First send: "You shouldn't have done that"
Then send: "You will pay"
Goal:
The fake player should create a spooky and unsettling experience for real players, as if it’s watching and reacting intelligently.
Planning before writing:
FakePlayerEntityextendsServerPlayerEntitywith aDummyNetworkHandlerto avoid NPEs — runs its own AI tick (movement + rotation) and overridesdamage/onDeathfor dialogue reactionsDummyNetworkHandlerextendsServerPlayNetworkHandlerwith no-optick(),sendPacket(),disconnect(), andisConnectionOpen() = trueto prevent the server from ejecting our NPCNpcManagersingleton handles spawn-on-join, player-list packets for new joiners, scheduled death messages, and the per-tick AI dispatchCreeperNpcModwiresServerPlayConnectionEvents.JOIN+ServerTickEvents.END_SERVER_TICKinto NpcManager
Here’s a summary of what was built:
CreeperNPC — 9 files, zero mixins needed.
File | Role |
|---|---|
FakePlayerEntity | Extends ServerPlayerEntity; custom tick() runs movement AI + baseTick(), overrides damage() for “stop”/“STOP” reactions and onDeath() for delayed final messages |
DummyNetworkHandler | Extends ServerPlayNetworkHandler with all network methods no-op’d and isConnectionOpen() returning true so the server never ejects the NPC |
NpcManager | Singleton; spawns NPC on first player join, sends PlayerListS2CPacket (tab-list visibility), PlayerRemoveS2CPacket on death, and drains a scheduled-message queue each server tick for the 3-second delayed death message |
CreeperNpcMod | Wires ServerPlayConnectionEvents.JOIN and ServerTickEvents.END_SERVER_TICK |
Behaviour at a glance:
Spawns 30 blocks from the first real player to join, positioned on the surface
Every tick: finds nearest real player → looks at them; if distance > 15 moves at 0.15 blocks/tick toward them, clamping exactly at 15; ground-snaps via
MOTION_BLOCKINGheightmapHit → broadcasts
<N̷ U̵L̶L̸> stop; drops below 50% HP once →STOP; killed →"You shouldn't have done that"immediately then"You will pay"after 3 seconds (60 ticks)
The compilation failed with this error:
Compilation failed with 6 error(s):
ERROR in src/main/java/com/example/creepernpc/FakePlayerEntity.java at line 25: incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
super(server, world, profile, ConnectedClientData.createDefault(profile, false));
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 51: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 63: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 51: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 63: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/FakePlayerEntity.java at line 25: incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
super(server, world, profile, ConnectedClientData.createDefault(profile, false));
^
=== COMPILATION ERROR ANALYSIS ===
TYPE MISMATCHES:
- incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
- incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
ACTION: Fix variable types or casting
FILES TO INVESTIGATE:
- src/main/java/com/example/creepernpc/FakePlayerEntity.java
- src/main/java/com/example/creepernpc/NpcManager.java
- src/main/java/com/example/creepernpc/NpcManager.java
- src/main/java/com/example/creepernpc/FakePlayerEntity.java
Please fix this error by creating a new artifact with the corrected code.
The compilation failed with this error:
Compilation failed with 6 error(s):
ERROR in src/main/java/com/example/creepernpc/FakePlayerEntity.java at line 25: incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
super(server, world, profile, ConnectedClientData.createDefault(profile, false));
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 51: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 63: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 51: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/NpcManager.java at line 63: method entryFromPlayer in class PlayerListS2CPacket cannot be applied to given types;
PlayerListS2CPacket.entryFromPlayer(
^
ERROR in src/main/java/com/example/creepernpc/FakePlayerEntity.java at line 25: incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
super(server, world, profile, ConnectedClientData.createDefault(profile, false));
^
=== COMPILATION ERROR ANALYSIS ===
TYPE MISMATCHES:
- incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
- incompatible types: ConnectedClientData cannot be converted to SyncedClientOptions
ACTION: Fix variable types or casting
FILES TO INVESTIGATE:
- src/main/java/com/example/creepernpc/FakePlayerEntity.java
- src/main/java/com/example/creepernpc/NpcManager.java
- src/main/java/com/example/creepernpc/NpcManager.java
- src/main/java/com/example/creepernpc/FakePlayerEntity.java
Please fix this error by creating a new artifact with the corrected code.
package com.example.creepernpc;
import net.fabricmc.api.ClientModInitializer;
public class CreeperNpcClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
}
}