Skip to content

Commit

Permalink
DisguiseLib 1.2.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Feb 6, 2022
1 parent e1dd2a7 commit 694a07e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}"

modCompileOnly "xyz.nucleoid:disguiselib-fabric:${rootProject.disguiselib_version}"
modCompileOnly "com.github.samolego.Config2Brigadier:config2brigadier:${rootProject.c2b_version}"
modCompileOnly "com.github.samolego.Config2Brigadier:config2brigadier-common:${rootProject.c2b_version}"

// Built using vanillagradle, no need for remapping
//compileOnly("com.github.samolego:Config2Brigadier:55370d49b3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mojang.authlib.GameProfile;
import net.minecraft.world.entity.Entity;
import org.samo_lego.taterzens.npc.TaterzenNPC;
import xyz.nucleoid.disguiselib.casts.EntityDisguise;
import xyz.nucleoid.disguiselib.api.EntityDisguise;

/**
* Just DisguiseLib methods in their own
Expand All @@ -23,4 +23,8 @@ public static void setGameProfile(TaterzenNPC taterzen, GameProfile gameProfile)
public static void clearDisguise(TaterzenNPC taterzen) {
((EntityDisguise) taterzen).removeDisguise();
}

public static boolean isDisguised(Entity entity) {
return ((EntityDisguise) entity).isDisguised();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import org.samo_lego.taterzens.compatibility.DisguiseLibCompatibility;
import org.samo_lego.taterzens.interfaces.ITaterzenEditor;
import org.samo_lego.taterzens.mixin.accessors.ClientboundAddPlayerPacketAccessor;
import org.samo_lego.taterzens.mixin.accessors.ClientboundPlayerInfoPacketAccessor;
Expand All @@ -41,6 +42,7 @@
import static net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action.ADD_PLAYER;
import static net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER;
import static org.samo_lego.taterzens.Taterzens.config;
import static org.samo_lego.taterzens.compatibility.ModDiscovery.DISGUISELIB_LOADED;

/**
* Used to "fake" the TaterzenNPC entity type.
Expand Down Expand Up @@ -82,11 +84,10 @@ private void changeEntityType(Packet<?> packet, GenericFutureListener<? extends
if(packet instanceof ClientboundAddPlayerPacket && !this.taterzens$skipCheck) {
Entity entity = world.getEntity(((ClientboundAddPlayerPacketAccessor) packet).getId());

if(!(entity instanceof TaterzenNPC npc))
if(!(entity instanceof TaterzenNPC npc) || (DISGUISELIB_LOADED && DisguiseLibCompatibility.isDisguised(entity)))
return;

GameProfile profile = npc.getGameProfile();

ClientboundPlayerInfoPacket playerAddPacket = new ClientboundPlayerInfoPacket(ADD_PLAYER);
//noinspection ConstantConditions
((ClientboundPlayerInfoPacketAccessor) playerAddPacket).setEntries(
Expand Down
5 changes: 4 additions & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"fabric": ">=0.45.1"
},
"recommends": {
"disguiselib": ">=1.0.0"
"disguiselib": ">=1.2.1"
},
"breaks": {
"disguiselib": "<1.2.1"
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ maven_group = org.samo_lego
archives_base_name = taterzens

# Dependencies
disguiselib_version = 1.0.8
c2b_version = 1.0.2
disguiselib_version = 1.2.1
c2b_version = 1.1.1
sgui_version = 1.0.0-rc5+1.18+pre5

0 comments on commit 694a07e

Please sign in to comment.