Skip to content

Commit

Permalink
Merge branch '1.20.1' into 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ToCraft committed Mar 3, 2024
2 parents 590b616 + ee84187 commit bf5d686
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# 3.0

First of all, this update is required to make the mod work with Woodwalkers v3+.
Furthermore, this implements a feature which was originally introduced by identity- entity favourites! I hope you like the implementation.
Furthermore, this implements a feature which was originally introduced by identity- entity favourites! I hope you like
the implementation.
Of course, I've also fixed the search-algorithm, so you can search for toolbox infos, too.
There is also a brand new config option to change "killToUnlock" values per entity type.
Last but not least, the Special Shape implementation is way more advanced, you consider to donate to check it out ;D.
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.text.SimpleDateFormat

plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
Expand Down
2 changes: 0 additions & 2 deletions common/src/main/java/tocraft/remorphed/RemorphedClient.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package tocraft.remorphed;

import com.mojang.blaze3d.platform.InputConstants;
import dev.architectury.event.events.client.ClientPlayerEvent;
import dev.architectury.event.events.client.ClientTickEvent;
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.KeyMapping;
import org.lwjgl.glfw.GLFW;
import tocraft.remorphed.network.ClientNetworking;
import tocraft.remorphed.screen.RemorphedScreen;
import tocraft.remorphed.tick.KeyPressHandler;

@Environment(EnvType.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
Expand All @@ -26,6 +27,7 @@ public class ClientNetworking {
public static void registerPacketHandlers() {
NetworkManager.registerReceiver(NetworkManager.Side.S2C, NetworkHandler.UNLOCKED_SYNC,
ClientNetworking::handleUnlockedSyncPacket);
NetworkManager.registerReceiver(NetworkManager.Side.S2C, NetworkHandler.FAVORITE_SYNC, ClientNetworking::handleFavoriteSyncPacket);
}

@SuppressWarnings("unchecked")
Expand All @@ -51,6 +53,20 @@ public static void handleUnlockedSyncPacket(FriendlyByteBuf packet, NetworkManag
});
}


private static void handleFavoriteSyncPacket(FriendlyByteBuf packet, NetworkManager.PacketContext context) {
CompoundTag tag = packet.readNbt();

if (tag != null) {
ClientNetworking.runOrQueue(context, player -> {
RemorphedPlayerDataProvider data = (RemorphedPlayerDataProvider) player;
data.remorphed$getFavorites().clear();
ListTag idList = tag.getList("FavoriteShapes", Tag.TAG_COMPOUND);
idList.forEach(compound -> data.remorphed$getFavorites().add(ShapeType.from((CompoundTag) compound)));
});
}
}

public static void runOrQueue(NetworkManager.PacketContext context, ApplicablePacket packet) {
if (context.getPlayer() == null) {
CraftedCoreClient.getSyncPacketQueue().add(packet);
Expand Down
13 changes: 0 additions & 13 deletions common/src/main/java/tocraft/remorphed/network/NetworkHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -32,7 +31,6 @@ public class NetworkHandler {
public static void registerPacketReceiver() {
NetworkManager.registerReceiver(NetworkManager.Side.C2S, NetworkHandler.SHAPE_REQUEST, NetworkHandler::handleShapeRequestPacket);
NetworkManager.registerReceiver(NetworkManager.Side.C2S, FAVORITE_UPDATE, NetworkHandler::handleFavoriteRequestPacket);
NetworkManager.registerReceiver(NetworkManager.Side.S2C, NetworkHandler.FAVORITE_SYNC, NetworkHandler::handleFavoriteSyncPacket);
}

public static <T extends LivingEntity> void sendSwap2ndShapeRequest(@NotNull ShapeType<T> type) {
Expand Down Expand Up @@ -89,17 +87,6 @@ public static void sendFavoriteSync(ServerPlayer player) {
NetworkManager.sendToPlayer(player, NetworkHandler.FAVORITE_SYNC, packet);
}

private static void handleFavoriteSyncPacket(FriendlyByteBuf packet, NetworkManager.PacketContext context) {
CompoundTag tag = packet.readNbt();

ClientNetworking.runOrQueue(context, player -> {
RemorphedPlayerDataProvider data = (RemorphedPlayerDataProvider) player;
data.remorphed$getFavorites().clear();
ListTag idList = tag.getList("FavoriteShapes", Tag.TAG_COMPOUND);
idList.forEach(compound -> data.remorphed$getFavorites().add(ShapeType.from((CompoundTag) compound)));
});
}

public static void sendFavoriteRequest(ShapeType<? extends LivingEntity> type, boolean favorite) {
FriendlyByteBuf packet = new FriendlyByteBuf(Unpooled.buffer());
packet.writeResourceLocation(BuiltInRegistries.ENTITY_TYPE.getKey(type.getEntityType()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public SpecialShapeWidget(int x, int y, int width, int height, RemorphedScreen p

// check if current shape is the special shape
CompoundTag nbt = new CompoundTag();
if (Minecraft.getInstance().player != null && PlayerShape.getCurrentShape(Minecraft.getInstance().player) instanceof Wolf wolf) wolf.saveWithoutId(nbt);
if (Minecraft.getInstance().player != null && PlayerShape.getCurrentShape(Minecraft.getInstance().player) instanceof Wolf wolf)
wolf.saveWithoutId(nbt);
this.isCurrent = nbt.contains("isSpecial") && nbt.getBoolean("isSpecial");
this.isAvailable = Walkers.CONFIG.specialShapeIsThirdShape || Minecraft.getInstance().player.isCreative() || ((RemorphedPlayerDataProvider) Minecraft.getInstance().player).remorphed$getUnlockedShapes().keySet().stream().map(ShapeType::getEntityType).toList().contains(EntityType.WOLF);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import tocraft.remorphed.Remorphed;

@Mod(Remorphed.MODID)
public class PotionAbilitiesForge {
public class RemorphedForge {

public PotionAbilitiesForge() {
public RemorphedForge() {
new Remorphed().initialize();
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.19.4
supported_versions=1.19.4
archives_base_name=remorphed
artifact_type=release
mod_version=3.0
mod_version=3.1
maven_group=dev.tocraft
# Loader Versions
fabric_loader_version=0.14.25
Expand Down

0 comments on commit bf5d686

Please sign in to comment.