Skip to content

Commit 2269ef0

Browse files
committed
1.0.1
1 parent 6c8bfdf commit 2269ef0

10 files changed

Lines changed: 31 additions & 36 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
[![Server environment](https://img.shields.io/badge/Environment-server-blue?style=flat-square)](https://github.com/samolego/Taterzens)
55
[![Singleplayer environment](https://img.shields.io/badge/Environment-singleplayer-yellow?style=flat-square)](https://github.com/samolego/Taterzens)
66

7-
A fabric citizens attempt.
7+
A fabric / forge citizens attempt.
88

99
You can find documentation [here](https://samolego.github.io/Taterzens/).

common/src/main/java/org/samo_lego/taterzens/mixin/ServerPlayNetworkHandlerMixin_PacketFaker.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
import org.spongepowered.asm.mixin.injection.Inject;
2828
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2929

30-
import java.util.Collections;
31-
import java.util.HashSet;
30+
import java.util.ArrayList;
31+
import java.util.Arrays;
3232
import java.util.List;
33+
import java.util.stream.Collectors;
3334

3435
import static net.minecraft.network.packet.s2c.play.PlayerListS2CPacket.Action.ADD_PLAYER;
3536
import static net.minecraft.network.packet.s2c.play.PlayerListS2CPacket.Action.REMOVE_PLAYER;
@@ -42,14 +43,15 @@
4243
public abstract class ServerPlayNetworkHandlerMixin_PacketFaker {
4344

4445
@Shadow public ServerPlayerEntity player;
46+
47+
@Shadow public abstract void sendPacket(Packet<?> packet);
48+
4549
@Unique
4650
private boolean taterzens$skipCheck;
4751
@Unique
48-
private final HashSet<PlayerListS2CPacket> taterzens$tablistQueue = new HashSet<>();
52+
private final List<TaterzenNPC> taterzens$tablistQueue = new ArrayList<TaterzenNPC>();
4953
private int taterzens$queueTimer;
5054

51-
@Shadow public abstract void sendPacket(Packet<?> packet);
52-
5355
/**
5456
* Changes entity type if entity is an instance of {@link TaterzenNPC}.
5557
*
@@ -78,9 +80,7 @@ private void changeEntityType(Packet<?> packet, GenericFutureListener<? extends
7880
PlayerListS2CPacket playerAddPacket = new PlayerListS2CPacket(ADD_PLAYER);
7981
//noinspection ConstantConditions
8082
((PlayerListS2CPacketAccessor) playerAddPacket).setEntries(
81-
Collections.singletonList(
82-
playerAddPacket.new Entry(profile, 0, GameMode.SURVIVAL, npc.getName())
83-
)
83+
Arrays.asList(playerAddPacket.new Entry(profile, 0, GameMode.SURVIVAL, npc.getName()))
8484
);
8585
taterzens$skipCheck = true;
8686
this.sendPacket(playerAddPacket);
@@ -91,18 +91,12 @@ playerAddPacket.new Entry(profile, 0, GameMode.SURVIVAL, npc.getName())
9191
this.sendPacket(packet);
9292

9393
PlayerListS2CPacket playerRemovePacket = new PlayerListS2CPacket(REMOVE_PLAYER);
94-
//noinspection ConstantConditions
95-
((PlayerListS2CPacketAccessor) playerRemovePacket).setEntries(
96-
Collections.singletonList(
97-
playerRemovePacket.new Entry(profile, 0, GameMode.SURVIVAL, npc.getName())
98-
)
99-
);
10094
// And now we can remove it from tablist
10195
// we must delay the tablist packet so as to allow
10296
// the client to fetch skin.
10397
// If player is immediately removed from the tablist,
10498
// client doesn't care about the skin.
105-
this.taterzens$tablistQueue.add(playerRemovePacket);
99+
this.taterzens$tablistQueue.add(npc);
106100
this.taterzens$queueTimer = config.taterzenTablistTimeout;
107101

108102
this.taterzens$skipCheck = false;
@@ -123,8 +117,23 @@ playerRemovePacket.new Entry(profile, 0, GameMode.SURVIVAL, npc.getName())
123117
private void removeTaterzenFromTablist(PlayerMoveC2SPacket packet, CallbackInfo ci) {
124118
if(!this.taterzens$tablistQueue.isEmpty() && --this.taterzens$queueTimer == 0) {
125119
this.taterzens$skipCheck = true;
126-
this.taterzens$tablistQueue.forEach(this::sendPacket);
120+
121+
PlayerListS2CPacket taterzensRemovePacket = new PlayerListS2CPacket(REMOVE_PLAYER);
122+
List<PlayerListS2CPacket.Entry> taterzenList = this.taterzens$tablistQueue
123+
.stream()
124+
.map(npc -> taterzensRemovePacket.new Entry(
125+
npc.getGameProfile(),
126+
0,
127+
GameMode.SURVIVAL,
128+
npc.getName()
129+
)
130+
)
131+
.collect(Collectors.toList());
132+
//noinspection ConstantConditions
133+
((PlayerListS2CPacketAccessor) taterzensRemovePacket).setEntries(taterzenList);
134+
this.sendPacket(taterzensRemovePacket);
127135
this.taterzens$tablistQueue.clear();
136+
128137
this.taterzens$skipCheck = false;
129138
}
130139
}

common/src/main/java/org/samo_lego/taterzens/mixin/accessors/EntityAccessor.java

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

common/src/main/java/org/samo_lego/taterzens/mixin/accessors/MobSpawnS2CPacketAccessor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ public interface MobSpawnS2CPacketAccessor {
1010
@Accessor("id")
1111
int getId();
1212

13-
@Accessor("entityTypeId")
14-
int getEntityTypeId();
1513
}

common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static class Permissions {
8686
* Permission level required to execute /taterzens command.
8787
* Valid only if LuckPerms isn't present.
8888
*/
89-
@SerializedName("npc_command_permission_level")
89+
@SerializedName("taterzens_command_permission_level")
9090
public int taterzensCommandPermissionLevel = 4;
9191

9292
public final String _comment_allowSettingHigherPermissionLevel1 = "// Whether to allow players to set the permission level";
44.5 KB
Loading

common/src/main/resources/taterzens.common.mixins.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"ServerPlayNetworkHandlerMixin_MsgEditor",
1111
"ServerPlayNetworkHandlerMixin_PacketFaker",
1212
"ThreadedAnvilChunkStorageMixin_TaterzenList",
13-
"accessors.EntityAccessor",
1413
"accessors.EntityTrackerEntryAccessor",
1514
"accessors.EntityTrackerUpdateS2CPacketAccessor",
1615
"accessors.MobSpawnS2CPacketAccessor",

fabric/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dependencies {
4242
modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}"
4343
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}"
4444

45+
4546
// LuckPerms
4647
modImplementation 'me.lucko:fabric-permissions-api:0.1-SNAPSHOT'
4748
/*modRuntime group: 'me.lucko.luckperms', name: 'luckperms-api', version: '4.0'

forge/src/main/java/org/samo_lego/taterzens/mixin/NetworkRegistryMixin_MarkServerside.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public class NetworkRegistryMixin_MarkServerside {
3939
private static void taterzens$removeTaterzensFromRegistrySync(BiFunction<NetworkInstance, String, Boolean> testFunction, CallbackInfoReturnable<List<String>> cir, List<String> results) {
4040
//results.remove("taterzens");
4141
if(config.disableRegistrySync) {
42-
System.out.println(results);
42+
/*System.out.println(results);
4343
instances.values().forEach(networkInstance -> {
4444
System.out.println("Checking: split");
4545
System.out.println(((NetworkInstanceAccessor) networkInstance).networkProtocolVersion());
4646
System.out.println(((NetworkInstanceAccessor) networkInstance).clientAcceptedVersions());
4747
System.out.println(((NetworkInstanceAccessor) networkInstance).getServerAcceptedVersions());
48-
});
48+
});*/
4949
cir.setReturnValue(Collections.emptyList());
5050
}
5151
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ fabric_version=0.32.5+1.16
1313
forge_version=36.0.46
1414

1515
# Mod Properties
16-
mod_version = 1.0.0
16+
mod_version = 1.0.1
1717
maven_group = org.samo_lego
1818
archives_base_name = taterzens

0 commit comments

Comments
 (0)