diff --git a/build.gradle b/build.gradle index db906f6..7ce1f00 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '10.5.0' +version = '10.5.1' group = 'tabula' archivesBaseName = 'Tabula-1.16.5' @@ -69,7 +69,7 @@ dependencies { // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.16.5-36.0.55' - implementation fg.deobf("ichunutil:iChunUtil:10.5.0") + implementation fg.deobf("ichunutil:iChunUtil:10.5.1") // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" diff --git a/src/main/java/me/ichun/mods/tabula/client/core/ConfigClient.java b/src/main/java/me/ichun/mods/tabula/client/core/ConfigClient.java index 73f722b..2acf3e2 100644 --- a/src/main/java/me/ichun/mods/tabula/client/core/ConfigClient.java +++ b/src/main/java/me/ichun/mods/tabula/client/core/ConfigClient.java @@ -18,6 +18,10 @@ public class ConfigClient extends ConfigBase public boolean animateImports = true; + public boolean addEntityTags = true; + + public boolean readEmptyNbt = true; + @Prop(min = 0, max = 10) public int guiMaxDecimals = 2; diff --git a/src/main/java/me/ichun/mods/tabula/client/export/types/handInfo/WindowExportHandInfo.java b/src/main/java/me/ichun/mods/tabula/client/export/types/handInfo/WindowExportHandInfo.java index 4ecf09f..d9d7b55 100644 --- a/src/main/java/me/ichun/mods/tabula/client/export/types/handInfo/WindowExportHandInfo.java +++ b/src/main/java/me/ichun/mods/tabula/client/export/types/handInfo/WindowExportHandInfo.java @@ -10,6 +10,7 @@ import me.ichun.mods.ichunutil.common.module.tabula.formats.ImportList; import me.ichun.mods.ichunutil.common.module.tabula.project.Project; import me.ichun.mods.tabula.client.export.ExportList; +import me.ichun.mods.tabula.client.gui.IProjectInfo; import me.ichun.mods.tabula.client.gui.WorkspaceTabula; import me.ichun.mods.tabula.client.tabula.Mainframe; import me.ichun.mods.tabula.common.Tabula; @@ -85,6 +86,23 @@ public void nextStep() } //Delete all the non-relevant parts + for(Project.Part part : leftParts) + { + if(!(part.parent instanceof Project)) + { + part.parent.disown(part); + projectInfo.project.adopt(part); + } + } + for(Project.Part part : rightParts) + { + if(!(part.parent instanceof Project)) + { + part.parent.disown(part); + projectInfo.project.adopt(part); + } + } + ArrayList parts = new ArrayList<>(projectInfo.project.parts); for(Project.Part part : parts) { @@ -97,7 +115,6 @@ public void nextStep() for(Project.Part leftPart : leftParts) { leftPart.rotAX = 0F; - parent.mainframe.updatePart(leftPart, true); } for(Project.Part rightPart : rightParts) @@ -108,9 +125,15 @@ public void nextStep() { rightPart.showModel = false; } + } - parent.mainframe.updatePart(rightPart, true); + projectInfo.markProjectDirty(); + + if(parent.mainframe.origin != null && !parent.mainframe.sessionEnded) + { + parent.mainframe.sendContent("", projectInfo.project.identifier, "", projectInfo.project, (byte)2); } + parent.projectChanged(IProjectInfo.ChangeType.PARTS); alignedLeft = new ArrayList<>(leftParts); alignedRight = new ArrayList<>(rightParts); diff --git a/src/main/java/me/ichun/mods/tabula/client/gui/window/WindowToolbar.java b/src/main/java/me/ichun/mods/tabula/client/gui/window/WindowToolbar.java index 0f384b3..c69ce5b 100644 --- a/src/main/java/me/ichun/mods/tabula/client/gui/window/WindowToolbar.java +++ b/src/main/java/me/ichun/mods/tabula/client/gui/window/WindowToolbar.java @@ -16,6 +16,7 @@ import me.ichun.mods.tabula.client.tabula.Mainframe; import me.ichun.mods.tabula.common.Tabula; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; @@ -372,6 +373,10 @@ public void openImportProject() public void openImportMCProject() { + if(Screen.hasShiftDown()) + { + WindowImportMCProject.resetHasInit(); + } Window window = new WindowImportMCProject(getWorkspace()); getWorkspace().openWindowInCenter(window, 0.4D, 0.8D); window.init(); diff --git a/src/main/java/me/ichun/mods/tabula/client/gui/window/popup/WindowImportMCProject.java b/src/main/java/me/ichun/mods/tabula/client/gui/window/popup/WindowImportMCProject.java index 162d11a..c1292f1 100644 --- a/src/main/java/me/ichun/mods/tabula/client/gui/window/popup/WindowImportMCProject.java +++ b/src/main/java/me/ichun/mods/tabula/client/gui/window/popup/WindowImportMCProject.java @@ -3,6 +3,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import me.ichun.mods.ichunutil.client.gui.bns.Workspace; import me.ichun.mods.ichunutil.client.gui.bns.window.Window; +import me.ichun.mods.ichunutil.client.gui.bns.window.WindowPopup; import me.ichun.mods.ichunutil.client.gui.bns.window.constraint.Constraint; import me.ichun.mods.ichunutil.client.gui.bns.window.view.View; import me.ichun.mods.ichunutil.client.gui.bns.window.view.element.*; @@ -34,10 +35,13 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.item.crafting.RecipeManager; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.profiler.EmptyProfiler; import net.minecraft.resources.IResource; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.tags.ITagCollectionSupplier; +import net.minecraft.tags.TagCollectionManager; +import net.minecraft.tags.TagRegistryManager; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; @@ -65,6 +69,7 @@ public class WindowImportMCProject extends Window { public static final ArrayList MODELS = new ArrayList<>(); + public static class ModelInfo implements Comparable { @@ -127,6 +132,11 @@ public void originEntity(Class aClass) } private static boolean hasInit; + public static void resetHasInit() + { + hasInit = false; + } + public static void initModels() { if(!hasInit) @@ -236,7 +246,7 @@ public void setSpawnAngle(float angle) { } - }, World.OVERWORLD, DimensionType.OVERWORLD_TYPE, () -> EmptyProfiler.INSTANCE, false, false, 0L) { + }, World.OVERWORLD, DimensionType.OVERWORLD_TYPE, () -> EmptyProfiler.INSTANCE, true, false, 0L) { @Override public DynamicRegistries func_241828_r() { @@ -309,7 +319,25 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) } }; - Map, EntityRenderer> renderers = Minecraft.getInstance().getRenderManager().renderers; + Minecraft mc = Minecraft.getInstance(); + + //More hackery: Should fix errors with Tags eg in DungeonMobs + if(Tabula.configClient.addEntityTags && mc.world == null) + { + ITagCollectionSupplier oriManager = TagCollectionManager.getManager(); + ITagCollectionSupplier itagcollectionsupplier = ITagCollectionSupplier.getTagCollectionSupplier(oriManager.getBlockTags(), oriManager.getItemTags(), oriManager.getFluidTags(), oriManager.getEntityTypeTags()); + itagcollectionsupplier = ITagCollectionSupplier.reinjectOptionalTags(itagcollectionsupplier); + + TagCollectionManager.setManager(itagcollectionsupplier); + net.minecraftforge.common.ForgeTagHandler.reinjectOptionalTagsCustomTypes(); + + TagRegistryManager.fetchTags(itagcollectionsupplier); + + TagCollectionManager.setManager(oriManager); + } + + Map, EntityRenderer> renderers = mc.getRenderManager().renderers; + boolean[] errored = new boolean[] { false }; renderers.forEach((entityType, entityRenderer) -> { try { @@ -318,7 +346,24 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) { instance = entityType.create(worldInstance); } - catch(Throwable ignored){} + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } + + if(Tabula.configClient.readEmptyNbt && instance != null) + { + try + { + instance.read(new CompoundNBT()); + } + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } + } ResourceLocation texLoc = null; if(entityRenderer instanceof HorseRenderer) @@ -333,12 +378,13 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) { texLoc = RenderHelper.getEntityTexture(entityRenderer, instance); } - catch(Throwable ignored) + catch(Throwable e) { + errored[0] = true; + e.printStackTrace(); } } - if(texLoc == null) { try @@ -360,8 +406,10 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) clz = clz.getSuperclass(); } } - catch(Throwable ignored) + catch(Throwable e) { + errored[0] = true; + e.printStackTrace(); } } } @@ -425,7 +473,11 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) clz = clz.getSuperclass(); } } - catch(Throwable ignored){} + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } if(entityRenderer instanceof LivingRenderer) { @@ -453,7 +505,11 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) clz = clz.getSuperclass(); } } - catch(Throwable ignored){} + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } //we have the texture. let's get all the models now. try @@ -473,7 +529,10 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) if(model != null) { ModelInfo info = new ModelInfo(texLoc1, model, layer); - info.origin = texLoc1.getNamespace(); + if(texLoc1 != null) + { + info.origin = texLoc1.getNamespace(); + } if(!MODELS.contains(info)) { MODELS.add(info); @@ -485,11 +544,19 @@ public Biome getNoiseBiomeRaw(int x, int y, int z) clz = clz.getSuperclass(); } } - catch(Throwable ignored){} + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } } } } - catch(Throwable ignored){} + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } }); Map, TileEntityRenderer> tileRenderers = TileEntityRendererDispatcher.instance.renderers; @@ -522,9 +589,10 @@ else if(RenderMaterial.class.isAssignableFrom(f.getType())) clz = clz.getSuperclass(); } } - catch(Throwable ignored) + catch(Throwable e) { - ignored.printStackTrace(); + errored[0] = true; + e.printStackTrace(); } @@ -563,7 +631,11 @@ else if(ModelRenderer.class.isAssignableFrom(f.getType())) clz = clz.getSuperclass(); } } - catch(Throwable ignored){} + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } if(rendererIsModel) { @@ -575,7 +647,11 @@ else if(ModelRenderer.class.isAssignableFrom(f.getType())) } } } - catch(Throwable ignored){} + catch(Throwable e) + { + errored[0] = true; + e.printStackTrace(); + } }); ModelInfo playerInfo = new ModelInfo(new ResourceLocation("textures/entity/steve.png"), new PlayerModel<>(0F, false), Minecraft.getInstance().getRenderManager().skinMap.get("default")); @@ -607,6 +683,11 @@ else if(ModelRenderer.class.isAssignableFrom(f.getType())) strings.add(info.model.getClass().getSimpleName() + " - " + info.source.getClass().getSimpleName() + (info.origin != null ? " - " + info.origin : "")); return strings; }); + + if(errored[0] && mc.currentScreen instanceof WorkspaceTabula) + { + WindowPopup.popup((WorkspaceTabula)mc.currentScreen, 0.5D, 180, null, I18n.format("window.importMC.errored")); + } } } diff --git a/src/main/java/me/ichun/mods/tabula/client/tabula/Mainframe.java b/src/main/java/me/ichun/mods/tabula/client/tabula/Mainframe.java index eeb656f..12268f8 100644 --- a/src/main/java/me/ichun/mods/tabula/client/tabula/Mainframe.java +++ b/src/main/java/me/ichun/mods/tabula/client/tabula/Mainframe.java @@ -916,6 +916,8 @@ public ProjectInfo(@Nonnull Mainframe mainframe, Project project) } } } + + createState(); } public void tick() diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index eb02745..4830982 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -16,6 +16,6 @@ issueTrackerURL="https://github.com/iChun/Tabula/issues" [[dependencies.tabula]] modId="ichunutil" mandatory=true - versionRange="[10.5.0,11)" + versionRange="[10.5.1,11)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/assets/tabula/lang/en_us.json b/src/main/resources/assets/tabula/lang/en_us.json index 9221942..534a793 100644 --- a/src/main/resources/assets/tabula/lang/en_us.json +++ b/src/main/resources/assets/tabula/lang/en_us.json @@ -59,6 +59,7 @@ "window.importMC.title": "Import Minecraft Model", "window.importMC.newProject": "New?", "window.importMC.newProjectFull": "Import the model into a new project?", + "window.importMC.errored": "We caught an error trying to get all the models. Some models may be unavailable. Check the console for errors.", "window.loadTexture.title": "Load Texture", "window.loadTexture.updateTextureDimensions": "Update?", @@ -225,7 +226,7 @@ "topdock.save": "Save", "topdock.saveAs": "Save As", "topdock.import": "Import Project", - "topdock.importMC": "Import From Minecraft", + "topdock.importMC": "Import From Minecraft\n\nHold SHIFT to force an animation re-render", "topdock.export": "Export Project", "topdock.cut": "Cut", "topdock.copy": "Copy", @@ -282,7 +283,9 @@ "config.tabula.prop.chatSound.name": "Chat Sound", "config.tabula.prop.allowEveryoneToEdit.name": "Allow Everyone To Edit", "config.tabula.prop.editors.name": "Allowed Editors", - "config.tabula.prop.animateImports.name": "Animate Imports", + "config.tabula.prop.animateImports.name": "ImportMC: Animate Imports", + "config.tabula.prop.addEntityTags.name": "ImportMC: Add Entity Tags", + "config.tabula.prop.readEmptyNbt.name": "ImportMC: Read Empty NBT", "config.tabula.prop.chatWindow.name": "Chat Window Settings", "config.tabula.prop.tooltipTime.name": "Tooltip Time", "config.tabula.prop.forceGuiScale.name": "Force Gui Scale", @@ -302,7 +305,9 @@ "config.tabula.prop.chatSound.desc": "Enable chat sounds?", "config.tabula.prop.allowEveryoneToEdit.desc": "Allow anyone who connects to your Tabula session to edit the model", "config.tabula.prop.editors.desc": "People allowed to edit models in your multiplayer Tabula session.\\nSeparate usernames by with a comma and a space (\", \" - no quotes)", - "config.tabula.prop.animateImports.desc": "Try to animate the possibly imported models to fix their rotations?", + "config.tabula.prop.animateImports.desc": "Try to animate the possibly imported models to fix their rotations? May cause issues.", + "config.tabula.prop.addEntityTags.desc": "Load up the data pack to add EntityType tags when trying to animate entity models. May cause issues.", + "config.tabula.prop.readEmptyNbt.desc": "Make the entity \"read\" an empty NBT Tag to set some fields. May cause issues.", "config.tabula.prop.chatWindow.desc": "Don't touch this. Seriously.", "config.tabula.prop.tooltipTime.desc": "Time (in ticks) for tooltip to appear.", "config.tabula.prop.forceGuiScale.desc": "Force a GUI scale when entering the Tabula screen. Follows MC's GUI Scale, -1 disables, 0 is auto",