generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Update to 1.20.4
Showing
10 changed files
with
139 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx2G | ||
# Fabric Properties | ||
minecraft_version=1.20.1 | ||
yarn_mappings=1.20.1+build.1 | ||
loader_version=0.14.18 | ||
minecraft_version=1.20.4 | ||
yarn_mappings=1.20.4+build.1 | ||
loader_version=0.15.3 | ||
#Fabric api | ||
fabric_version=0.88.1+1.20.1 | ||
fabric_version=0.91.1+1.20.4 | ||
# Mod Properties | ||
mod_version=1.3.4 | ||
mod_version=1.3.5 | ||
maven_group=xyz.nucleoid | ||
archives_base_name = disguiselib |
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
102 changes: 102 additions & 0 deletions
102
...n/java/xyz/nucleoid/disguiselib/impl/mixin/ServerCommonNetworkHandlerMixin_Disguiser.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,102 @@ | ||
package xyz.nucleoid.disguiselib.impl.mixin; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.data.DataTracker; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.network.PacketCallbacks; | ||
import net.minecraft.network.listener.ClientPlayPacketListener; | ||
import net.minecraft.network.packet.BrandCustomPayload; | ||
import net.minecraft.network.packet.Packet; | ||
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket; | ||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; | ||
import net.minecraft.network.packet.s2c.play.*; | ||
import net.minecraft.server.network.ServerCommonNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import xyz.nucleoid.disguiselib.api.DisguiseUtils; | ||
import xyz.nucleoid.disguiselib.api.EntityDisguise; | ||
import xyz.nucleoid.disguiselib.impl.mixin.accessor.*; | ||
import xyz.nucleoid.disguiselib.impl.packets.ExtendedHandler; | ||
import xyz.nucleoid.disguiselib.impl.packets.FakePackets; | ||
|
||
import java.util.*; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.function.Consumer; | ||
|
||
import static xyz.nucleoid.disguiselib.impl.DisguiseLib.DISGUISE_TEAM; | ||
|
||
@Mixin(ServerCommonNetworkHandler.class) | ||
public abstract class ServerCommonNetworkHandlerMixin_Disguiser { | ||
@Shadow | ||
public abstract void sendPacket(Packet<?> packet); | ||
|
||
@Unique | ||
private boolean disguiselib$skipCheck; | ||
|
||
/** | ||
* Checks the packet that was sent. If the entity in the packet is disguised, the | ||
* entity type / id in the packet will be changed. | ||
* | ||
* As minecraft client doesn't allow moving if you send it an entity with the same | ||
* id as player, we send the disguised player another entity, so they will see their | ||
* own disguise. | ||
* | ||
* @param packet packet being sent | ||
*/ | ||
@Inject( | ||
method = "send", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;Z)V" | ||
), | ||
cancellable = true | ||
) | ||
private void disguiseEntity(Packet<ClientPlayPacketListener> packet, PacketCallbacks callbacks, CallbackInfo ci) { | ||
if (!this.disguiselib$skipCheck) { | ||
if (!(this instanceof ExtendedHandler self)) { | ||
return; | ||
} | ||
if (packet instanceof BundleS2CPacket bundleS2CPacket) { | ||
if (bundleS2CPacket.getPackets() instanceof ArrayList<Packet<ClientPlayPacketListener>> list) { | ||
var list2 = new ArrayList<Packet<ClientPlayPacketListener>>(); | ||
var adder = new ArrayList<Packet<ClientPlayPacketListener>>(); | ||
var atomic = new AtomicBoolean(true); | ||
for (var packet2 : list) { | ||
atomic.set(true); | ||
adder.clear(); | ||
self.disguiselib$transformPacket(packet2, () -> atomic.set(false), list2::add); | ||
|
||
if (atomic.get()) { | ||
list2.add(packet2); | ||
} | ||
|
||
list2.addAll(adder); | ||
} | ||
|
||
list.clear(); | ||
list.addAll(list2); | ||
} | ||
} else { | ||
this.disguiselib$skipCheck = true; | ||
self.disguiselib$transformPacket(packet, ci::cancel, this::sendPacket); | ||
this.disguiselib$skipCheck = false; | ||
} | ||
} | ||
} | ||
|
||
@Inject(method = "onCustomPayload", at = @At("TAIL")) | ||
private void onClientBrand(CustomPayloadC2SPacket packet, CallbackInfo ci) { | ||
if (packet.payload() instanceof BrandCustomPayload && this instanceof ExtendedHandler self) { | ||
self.disguiselib$onClientBrand(); | ||
} | ||
} | ||
} |
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
35 changes: 0 additions & 35 deletions
35
src/main/java/xyz/nucleoid/disguiselib/impl/mixin/accessor/PlayerSpawnS2CPacketAccessor.java
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
src/main/java/xyz/nucleoid/disguiselib/impl/packets/ExtendedHandler.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,11 @@ | ||
package xyz.nucleoid.disguiselib.impl.packets; | ||
|
||
import net.minecraft.network.listener.ClientPlayPacketListener; | ||
import net.minecraft.network.packet.Packet; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public interface ExtendedHandler { | ||
void disguiselib$transformPacket(Packet<ClientPlayPacketListener> packet, Runnable remove, Consumer<Packet<ClientPlayPacketListener>> add); | ||
void disguiselib$onClientBrand(); | ||
} |
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