New Anvil Recipe System

This commit is contained in:
Kam committed 2025-02-10 02:44:28 -05:00
1 parent 9cda5503ed
commit 48dd7bedea
15 files changed
+592 -221

No files matched your search

@@ -62,6 +62,13 @@ public class SyncController {
carpentryNBT()
), player);
PacketHandler.Instance.sendToPlayer(new SyncPacket(
EnumSyncType.ANVIL_RECIPES,
EnumSyncAction.RELOAD,
-1,
anvilNBT()
), player);
DBCAddon.instance.syncPlayer(player);
syncPlayerData(player, false);
}
@@ -88,6 +95,17 @@ public class SyncController {
return compound;
}
public static NBTTagCompound anvilNBT(){
RecipeController controller = RecipeController.Instance;
NBTTagList list = new NBTTagList();
NBTTagCompound compound = new NBTTagCompound();
for(RecipeAnvil recipe : controller.anvilRecipes.values()){
list.appendTag(recipe.writeNBT());
}
compound.setTag("recipes", list);
return compound;
}
public static NBTTagCompound factionsNBT(){
NBTTagList list = new NBTTagList();
NBTTagCompound compound = new NBTTagCompound();
@@ -201,6 +219,15 @@ public class SyncController {
));
}
public static void syncAllAnvilRecipes() {
PacketHandler.Instance.sendToAll(new SyncPacket(
EnumSyncType.ANVIL_RECIPES,
EnumSyncAction.RELOAD,
-1,
anvilNBT()
));
}
@SideOnly(Side.CLIENT)
public static void clientSync(EnumSyncType enumSyncType, NBTTagCompound fullCompound) {
switch (enumSyncType){
@@ -325,6 +352,21 @@ public class SyncController {
RecipeController.syncRecipes = new HashMap<Integer, RecipeCarpentry>();
break;
}
case ANVIL_RECIPES: {
NBTTagList list = fullCompound.getTagList("recipes", 10);
if(list == null)
return;
for(int i = 0; i < list.tagCount(); i++)
{
RecipeAnvil recipe = RecipeAnvil.read(list.getCompoundTagAt(i));
RecipeController.syncAnvilRecipes.put(recipe.id, recipe);
}
RecipeController.Instance.anvilRecipes = RecipeController.syncAnvilRecipes;
RecipeController.syncAnvilRecipes = new HashMap<Integer, RecipeAnvil>();
break;
}
}
}