Jump to content

CAS_ual_TY

Members
  • Posts

    72
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by CAS_ual_TY

  1. Hello, I would like to render my GUI content inside a certain rectangle with anything beyond the edge of that rectangle getting cut off. I have looked into the advancement GUI for that but it is honestly too confusing for me. (I also tried google) If anyone could point me in the right direction that would be great. I would really like to understand how this works. I mean I could also just check every single element, if it is at the edge and then adjust it, but I am quite sure there is a simpler solution to this (?). Thanks in advance! Any tip or piece of knowledge would be greatly appreciated EDIT: Fixed spoiler and formatting
  2. The greatest Version will always be the newest version. Simply because the additions give you so many new possibilities you did not have before. Sure, a lot of things are lost and some stuff might become harder, but in the end the advantages outweight the disadvantages. Take the last 2 game breakers as an example: Integrated server, 1.3 -> (almost all) mods are now universal Resource Packs, 1.8 -> 3D items and customization have never been easier etc. As an example, I am currently creating another gun mod for 1.12.2. I myself am creating it in 2D but if any user wants to turn it into a 3D mod, he can do that any time now. Go back a couple of versions and things like this are a lot harder to do. The modders who claim that 1.7 is the best version are simply too lazy to adapt. But at some point enough 1.7 "mainstream" mods will be replaceable by new mods on the newest version and the 1.7 leftovers will switch to the new minecraft versions.
  3. NBT, I planned on making the mod opensource anyways. Ill do that the next days. This is my acc: https://github.com/cas-ual-ty
  4. Its easier to make just all different overlays and then overlay them onto the item using IBakedModel. So my item has 6 different layers overlayed onto it. For each layer I have made the different json models and textures, I have not done any combinations, those are done in code. Ill just share my code with you, I think its pretty self explaining, but some comments are there making it easy to understand: @Override public void registerGun(IForgeRegistry<Item> registry, ItemGun gun) { super.registerGun(registry, gun); registeredGuns.add(gun); ModelResourceLocation main = new ModelResourceLocation(GunCus.MOD_ID + ":" + gun.getModelRL() + "/gun", "inventory"); ModelLoader.setCustomModelResourceLocation(gun, 0, main); ArrayList<ModelResourceLocation> list = new ArrayList<ModelResourceLocation>(); list.add(main); int i; int j; Attachment attachment; for(i = 0; i < EnumAttachmentType.values().length; ++i) //All layers { for(j = 0; j < Attachment.getAmmountForSlot(i); ++j) //All attachments per layer { if(gun.canSetAttachment(i, j)) //Check if attachment is compatible { attachment = Attachment.getAttachment(i, j); if(attachment != null && attachment.shouldLoadModel()) //null-attachment exists, as well as some which are not visible { list.add(new ModelResourceLocation(GunCus.MOD_ID + ":" + gun.getModelRL() + "/" + attachment.getModelRL(), "inventory")); //Add MRL to the list } } } } ModelBakery.registerItemVariants(gun, list.toArray(new ModelResourceLocation[list.size()])); //Register all attachment MRLs found so that they will be loaded } @SubscribeEvent public void modelBake(ModelBakeEvent event) { int i; int j; Attachment attachment; ModelResourceLocation mrl; IBakedModel main; IBakedModel[][] models; //These are the attachment models which will be passed onto the gun model for use for(ItemGun gun : ProxyClient.registeredGuns) //Cycle through all guns { models = new IBakedModel[EnumAttachmentType.values().length][]; for(i = 0; i < models.length; ++i) //This represents the layers { models[i] = new IBakedModel[Attachment.getAmmountForSlot(i)]; for(j = 0; j < Attachment.getAmmountForSlot(i); ++j) //Ammount of attachments for each layer { if(gun.canSetAttachment(i, j)) //Check if compatible { attachment = Attachment.getAttachment(i, j); if(attachment != null && attachment.shouldLoadModel()) //Make sure its not null-attachment and the model is needed { models[i][j] = event.getModelRegistry().getObject(new ModelResourceLocation(GunCus.MOD_ID + ":" + gun.getModelRL() + "/" + attachment.getModelRL(), "inventory")); //Add attachment model to the array } } } } mrl = new ModelResourceLocation(GunCus.MOD_ID + ":" + gun.getModelRL() + "/gun", "inventory"); //This is the MRL of the main item (gun) main = event.getModelRegistry().getObject(mrl); //Get the model of the gun event.getModelRegistry().putObject(mrl, new BakedModelGun(main, models)); //Replace model of the gun with custom IBakedModel and pass all the attachment models to it } } public class BakedModelGun implements IBakedModel { /* * The only usage of this class is the item overrides list: * Basically get the itemstack, pass it onto the modelFinal, then return modelFinal for rendering, * so that during the rendering you have information about the itemstack */ private final IBakedModel modelMain; private final BakedModelGunFinalized modelFinal; private final OverridesList overridesList; public BakedModelGun(IBakedModel modelMain, IBakedModel[][] attachmentModels) { this.modelMain = modelMain; this.modelFinal = new BakedModelGunFinalized(this.modelMain, attachmentModels); this.overridesList = new OverridesList(this); } public BakedModelGunFinalized getModelFinal() { return modelFinal; } @Override public ItemOverrideList getOverrides() { return this.overridesList; } @Override public TextureAtlasSprite getParticleTexture() { return this.modelMain.getParticleTexture(); } @Override public List<BakedQuad> getQuads(IBlockState arg0, EnumFacing arg1, long arg2) { return this.modelMain.getQuads(arg0, arg1, arg2); } @Override public boolean isAmbientOcclusion() { return this.modelMain.isAmbientOcclusion(); } @Override public boolean isBuiltInRenderer() { return this.modelMain.isBuiltInRenderer(); } @Override public boolean isGui3d() { return this.modelMain.isGui3d(); } private static class OverridesList extends ItemOverrideList { private BakedModelGun modelGun; public OverridesList(BakedModelGun modelGun) { super(Collections.EMPTY_LIST); this.modelGun = modelGun; } @Override public IBakedModel handleItemState(IBakedModel originalModel, ItemStack itemStack, World world, EntityLivingBase entity) { return this.modelGun.getModelFinal().setCurrentItemStack(itemStack); } } } public class BakedModelGunFinalized implements IBakedModel { private final IBakedModel modelMain; private final IBakedModel[][] attachmentModels; private ItemStack itemStack; public BakedModelGunFinalized(IBakedModel modelMain, IBakedModel[][] attachmentModels) { this.modelMain = modelMain; this.attachmentModels = attachmentModels; this.itemStack = null; } public BakedModelGunFinalized setCurrentItemStack(ItemStack itemStack) { this.itemStack = itemStack; return this; } @Override public ItemOverrideList getOverrides() { return this.modelMain.getOverrides(); } @Override public TextureAtlasSprite getParticleTexture() { return this.modelMain.getParticleTexture(); } @Override public List<BakedQuad> getQuads(IBlockState arg0, EnumFacing arg1, long arg2) { ArrayList<BakedQuad> list = new ArrayList<BakedQuad>(); List<BakedQuad> list1 = this.modelMain.getQuads(arg0, arg1, arg2); ItemGun gun = (ItemGun) this.itemStack.getItem(); Paint paint = gun.<Paint>getAttachmentCalled(this.itemStack, EnumAttachmentType.PAINT.getSlot()); IBakedModel model; if(paint != null && paint.shouldRegister()) { model = this.attachmentModels[EnumAttachmentType.PAINT.getSlot()][paint.getID()]; if(model != null) { list1 = model.getQuads(arg0, arg1, arg2); } } if(list1 != null && !list1.isEmpty()) { list.addAll(list1); } List<BakedQuad> list2; Attachment attachment; for(int i = 0; i < EnumAttachmentType.values().length; ++i) { attachment = gun.getAttachment(itemStack, i); if(attachment != null && attachment.shouldRender()) { model = this.attachmentModels[i][attachment.getID()]; if(model != null) { list2 = model.getQuads(arg0, arg1, arg2); if(list2 != null && !list2.isEmpty()) { list.addAll(list2); } } } } return list; } @Override public boolean isAmbientOcclusion() { return this.modelMain.isAmbientOcclusion(); } @Override public boolean isBuiltInRenderer() { return this.modelMain.isBuiltInRenderer(); } @Override public boolean isGui3d() { return this.modelMain.isGui3d(); } private static final Matrix4f NULL_MATRIX = new Matrix4f(); @Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType transformType) { if(transformType == TransformType.FIRST_PERSON_RIGHT_HAND) { EntityPlayer entityPlayer = Minecraft.getMinecraft().player; if(entityPlayer != null && !entityPlayer.isSprinting() && !entityPlayer.isSneaking()) { if(entityPlayer.getHeldItemMainhand().getItem() instanceof ItemGun && entityPlayer.getHeldItemOffhand().isEmpty() && Minecraft.getMinecraft().gameSettings.keyBindUseItem.isKeyDown()) { ItemStack itemStack = entityPlayer.getHeldItemMainhand(); ItemGun gun = (ItemGun) itemStack.getItem(); Optic optic = gun.<Optic>getAttachmentCalled(itemStack, EnumAttachmentType.OPTIC.getSlot()); if(optic != null && optic.canAim()) { return Pair.of(this, NULL_MATRIX); } } } } return Pair.of(this, this.modelMain.handlePerspective(transformType).getRight()); } }
  5. This 100% Once people stop downloading 1.7.x mods then their authors will be forced to quit or update.
  6. readFromNBT contains all the basic stuff of an Entity: Position, motion, fall distance, if its on fire, prev tick rotation etc.. readEntityFromNBT is for classes which extend the Entity class to add their own new variables. So eg. the EntityTNT contains the fuse timer in there. readEntityFromNBT is abstract in the Entity class and gets called by readFromNBT.
  7. Which tutorial did you use? Because from what I can see, your ModBlocks class is not registered to the event bus. I do not know if it is different with the registry stuff, but usually you register the class with your events by using MinecraftForge.EVENT_BUS.register(new_instance_of_your_class); Try add that to the preInit of your mod. In this case the instance would be a new ModBlocks instance.
  8. I have already said that I am in fact defining the rotations in the json models and that I do not modify them in code at all. Here is an example: https://imgur.com/a/thAr5ET Anyways, I have found the solution to the problem. The IBakedModel interface has default methods which are defining that. I have simply added @Override public ItemCameraTransforms getItemCameraTransforms() { return this.modelMain.getItemCameraTransforms(); } @Override public boolean isAmbientOcclusion(IBlockState blockState) { return this.modelMain.isAmbientOcclusion(blockState); } @Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType transformType) { return this.modelMain.handlePerspective(transformType); } to the class. The modelMain field is of course the model which previously is stored at the ModelResourceLocation before it is replaced at that exact location with this IBakedModel. EDIT: So I figured some more stuff out. You need to do this instead: @Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType transformType) { return Pair.of(this, this.modelMain.handlePerspective(transformType).getRight()); }
  9. Sorry, yes I should have asked more clearly but you nailed it. Rotation is what is off and I need to fix that in code. Basically in the IBakedModel different json models are simply combined and rendered together. Adding rotation inside these json models does not change anything, however. I have googled and it seems that i have to work with ICustomModelLoader ahd IModel, but I have had these questions above about that. Thanks in advance
  10. - Check your common proxy for that import - Make sure a common class does not access a method statically of a class which imports client only stuff These are cases that can happen quickly and without intention (through human error or sometimes when IDEs do stuff) and I have seen them a couple of times already.
  11. hello, itse me again. Basically I setup a working "structure" in which Items have different attachments which are then rendered overlayed on to the item. These attachments have multiple json models and textures: The model and texture of the attachment itself and a model and texture for each item it can be put on to. All IBakedModels are setup correctly and everything is working; except for the rotations, those are off. I have checked and this does not come from the json files (when not using IBakedModels then all rotations are fine, I also tested json+rotation+IBakedModel but the rotations there dont matter at all). Now, I have already researched a bit, about using IModel and ICustomModelLoader but I have questions: - Should I simply point ICustomModelLoader to a new IModel, which then just points to the IBakedModel and thats it? - IBakedModel requires a lot of other models so that i works which are fetched from the ModelBakeEvent. How would I get those when using the ICustomModelLoader? Would I use the ::onResourceManagerReload function to get these models? - Any examples out there I could take a look at? - This is the solution(s) I found via google. Any better ones out there?
  12. Hello! Basically, I have an item which saves a lot of NBT data to an itemstack. Now, this data can become so huge, that when updating the data to the client, the client would be disconnected because of a too big packet. Now, this information is not needed on the client, so I disabled the updating of the NBT to the client. Everything works fine now, except for one thing: When moving the item around in the inventory, while in creative, it loses all stored data! I simply can not explain why or how. I have already tried using the specific nbt share tag method (commented out in the given code below), but that is also not working. I honestly have no idea anymore. Looking for help. Now before posting the code, you will see that I have added a debug output to the method which basically saves the data. This print does not get called at all, when just moving the item around. public class ItemStorage extends Item { public ItemStorage() { this.setMaxStackSize(1); this.setMaxDamage(0); this.setHasSubtypes(false); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { playerIn.openGui(Dueling.instance, 5, worldIn, 0, 0, 0); // ContainerStorage container = (ContainerStorage) playerIn.openContainer; return super.onItemRightClick(worldIn, playerIn, handIn); } public static final String NBT_SIZE = "LIST_SIZE"; public NonNullList<ItemStack> getItems(ItemStack itemStack) { NBTTagCompound nbt = this.getSubCompound(itemStack); int size = nbt.getInteger(ItemStorage.NBT_SIZE); NonNullList<ItemStack> items = NonNullList.<ItemStack>withSize(size, ItemStack.EMPTY); ItemStorage.loadAllItems(nbt, items); return items; } public void setItems(ItemStack itemStack, NonNullList<ItemStack> items) { System.out.println("saving"); NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger(ItemStorage.NBT_SIZE, items.size()); ItemStorage.saveAllItems(nbt, items); this.setSubCompound(itemStack, nbt); } public NBTTagCompound getSubCompound(ItemStack itemStack) { if(!itemStack.hasTagCompound()) { itemStack.setTagCompound(new NBTTagCompound()); } return itemStack.getTagCompound().getCompoundTag(Dueling.MOD_ID); } public void setSubCompound(ItemStack itemStack, NBTTagCompound tag) { if(!itemStack.hasTagCompound()) { itemStack.setTagCompound(new NBTTagCompound()); } itemStack.getTagCompound().setTag(Dueling.MOD_ID, tag); } @Override public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) { super.getSubItems(tab, items); } @Override public boolean getShareTag() { return false; } /*@Override public NBTTagCompound getNBTShareTag(ItemStack itemStack) { NBTTagCompound nbt = itemStack.getTagCompound(); NBTTagCompound nbtNew = new NBTTagCompound(); if(nbt != null) { for(String key : nbt.getKeySet()) { if(!key.equals(Dueling.MOD_ID)) { nbtNew.setTag(key, nbt.getTag(key)); } } } itemStack.setTagCompound(nbt); return nbtNew; }*/ public static NBTTagCompound saveAllItems(NBTTagCompound tag, NonNullList<ItemStack> list) { return ItemStorage.saveAllItems(tag, list, true); } public static NBTTagCompound saveAllItems(NBTTagCompound tag, NonNullList<ItemStack> list, boolean saveEmpty) { NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < list.size(); ++i) { ItemStack itemstack = list.get(i); if (!itemstack.isEmpty()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("Slot", i); itemstack.writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } if (!nbttaglist.hasNoTags() || saveEmpty) { tag.setTag("Items", nbttaglist); } return tag; } public static void loadAllItems(NBTTagCompound tag, NonNullList<ItemStack> list) { NBTTagList nbttaglist = tag.getTagList("Items", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound.getInteger("Slot")/* & 255 */; if (j >= 0 && j < list.size()) { list.set(j, new ItemStack(nbttagcompound)); } } } } Appreciating any help!
  13. Hello! I am currently making a custom villager and I would like to know if there is a way of detecting when a player has successfully traded. I could potentially just overwrite the GUI/Container but I would prefer not having to do that obviously... Google didnt quite help. Thank you for any replies!
  14. Hello, basically the FontRenderer is rendering a given text in white, unless I am holding any Item or Block in my hand. Pictures of what I mean (the Strings in the middle are what Im talking about): [EDIT: It seems like I pasted the code and question inside the spoiler as well and it doesnt let me edit the text. Is there a "raw" option, which shows the bb code instead of compiling them inside the editor?]
  15. Im doing it at the end of preInit. Which event would I need then? Well, as I said, trading card game with 8313 cards so far. By default, all cards have the same look in their Item form (all use the back side). But you can enable an option, which, instead, lets every single card item use the respective texture. Additionally, you can choose the size of these textures (default: 128). In the playing GUI, cards are always using the correct picture.
  16. If I dont call it I get missing texture errors. Also, currently I am loading in exactly 8313 textures. When using 128x128 textures everything works fine. When using 256x256 textures, however, I am getting the bottom error. Does this happen because my PC is too weak or because the texture atlas is too small or rather it can not fit everything?: [15:41:41] [main/INFO] [FML]: Unable to fit: tcg:53100061 - size: 256x256 - Maybe try a lowerresolution resourcepack? [15:41:41] [main/INFO] [FML]: Holder{width=512, height=512, name=tcg:items/back} [15:41:41] [main/INFO] [FML]: Holder{width=256, height=256, name=tcg:10000002} [15:41:41] [main/INFO] [FML]: Holder{width=256, height=256, name=tcg:10000010} [15:41:41] [main/INFO] [FML]: Holder{width=256, height=256, name=tcg:10000022} ... //I removed like 9k lines here [15:41:41] [main/INFO] [FML]: Holder{width=16, height=16, name=minecraft:items/wooden_armorstand} [15:41:41] [main/INFO] [FML]: Holder{width=16, height=16, name=minecraft:white} [15:41:41] [main/INFO] [FML]: Holder{width=16, height=16, name=missingno} [15:41:41] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ---- // On the bright side, I bought you a teddy bear! Time: 4/16/18 3:41 PM Description: Initializing game net.minecraft.client.renderer.StitcherException: Unable to fit: tcg:53100061 - size: 256x256 - Maybe try a lowerresolution resourcepack? at net.minecraft.client.renderer.texture.Stitcher.doStitch(Stitcher.java:71) at net.minecraft.client.renderer.texture.TextureMap.finishLoading(TextureMap.java:213) at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:112) at net.minecraft.client.renderer.texture.TextureMap.loadSprites(TextureMap.java:91) at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:172) at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) at net.minecraft.client.Minecraft.init(Minecraft.java:559) at net.minecraft.client.Minecraft.run(Minecraft.java:421) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at net.minecraft.client.renderer.texture.Stitcher.doStitch(Stitcher.java:71) at net.minecraft.client.renderer.texture.TextureMap.finishLoading(TextureMap.java:213) at net.minecraft.client.renderer.texture.TextureMap.loadTextureAtlas(TextureMap.java:112) at net.minecraft.client.renderer.texture.TextureMap.loadSprites(TextureMap.java:91) at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:172) at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) at net.minecraft.client.Minecraft.init(Minecraft.java:559) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:421) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25) -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_161, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 5278637096 bytes (5034 MB) / 8520204288 bytes (8125 MB) up to 8520204288 bytes (8125 MB) JVM Flags: 3 total; -Xincgc -Xmx8192M -Xms8192M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.42 Powered by Forge 14.23.2.2635 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:----- |:--------- |:------------ |:-------------------------------- |:--------- | | UCH | minecraft | 1.12.2 | minecraft.jar | None | | UCH | mcp | 9.42 | minecraft.jar | None | | UCH | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.2.2635.jar | None | | UCH | forge | 14.23.2.2635 | forgeSrc-1.12.2-14.23.2.2635.jar | None | | UCH | tcg | 0.1-1.12.2 | bin | None | Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 390.77' Renderer: 'GeForce GTX 1070/PCIe/SSE2' Launched Version: 1.12.2 LWJGL: 2.9.4 OpenGL: GeForce GTX 1070/PCIe/SSE2 GL version 4.6.0 NVIDIA 390.77, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 8x Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz [15:41:41] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Minecraft Coding 1.12.2\run\.\crash-reports\crash-2018-04-16_15.41.41-client.txt
  17. IRessourcePack is literally a dream when it comes to this, thanks! Everything works now. Did I "register" (add) the rp correctly? (I know, the field_xxx String is missing. you wouldnt know it by any chance?) EDIT: Unless it got changed it is getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao", "ap") I think For people who will google this: public class ResourcePackCards implements IResourcePack { private File cardImageDir; public ResourcePackCards(File cardImageDir) { this.cardImageDir = cardImageDir; } @Override public InputStream getInputStream(ResourceLocation location) throws IOException { return new FileInputStream(new File(this.cardImageDir.getAbsolutePath() + "/" + location.getResourcePath().replace("textures/", ""))); } @Override public boolean resourceExists(ResourceLocation location) { return new File(this.cardImageDir.getAbsolutePath() + "/" + location.getResourcePath().replace("textures/", "")).exists(); } @Override public Set<String> getResourceDomains() { return ImmutableSet.<String>of(Main.MOD_ID); } @Override public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) throws IOException { return null; } @Override public BufferedImage getPackImage() throws IOException { return TextureUtil.readBufferedImage(DefaultResourcePack.class.getResourceAsStream("/" + (new ResourceLocation("pack.png")).getResourcePath())); } @Override public String getPackName() { return "Cards Images"; } } //in preInit (client side only) List<IResourcePack> defaultResourcePacks = null; defaultResourcePacks = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks"); defaultResourcePacks.add(new ResourcePackCards(this.cardImageDir)); Minecraft.getMinecraft().refreshResources();
  18. Thanks! Kinda what I expected. Almost everything seems to be working, I still have a problem however, It doesnt seem like my textures get loaded from outside the jar. I am getting an error that these textures could not be found. Anyone got any idea? @SubscribeEvent public void stitcherEventPre(TextureStitchEvent.Pre event) { File[] images = this.cardImageDir.listFiles(); for(File f : images) { try { Minecraft mc = Minecraft.getMinecraft(); DynamicTexture dt = new DynamicTexture(ImageIO.read(f)); ResourceLocation rl = mc.getTextureManager().getDynamicTextureLocation(TCG.MOD_ID + ":" + "card_" + f.getName().replace("_1.png", ""), dt); TextureAtlasSprite tas = event.getMap().registerSprite(rl); System.out.println(tas.getIconName()); //TODO debug System.out.println(""); } catch(Exception e) { e.printStackTrace(); } } } [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: The following texture errors were found. [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: ================================================== [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: DOMAIN dynamic/tcg [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: -------------------------------------------------- [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: domain dynamic/tcg is missing 20 textures [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: domain dynamic/tcg is missing a resource manager - it is probably a side-effect of automatic texture processing [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: ------------------------- [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: The missing resources for domain dynamic/tcg are: [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_34541863_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_44256816_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_295517_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_91231901_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_86198326_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_73262676_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_14261867_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_21597117_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_49140998_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_8949584_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_83994646_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_67048711_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_86988864_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_64163367_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_68170903_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_23771716_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_24140059_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_57769391_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_6850209_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: textures/card_11714098_1.png [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: ------------------------- [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: No other errors exist for domain dynamic/tcg [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: ================================================== [19:10:09] [main/ERROR] [FML.TEXTURE_ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  19. Hello, I am currently working on bringing a trading card game to minecraft. Informations are read from public online APIs, including the cards' look. The card images are being downloaded when the player can see the respective card. Alternatively I could also implement a downloading of all images beforehand, but there are quite a lot of cards out there so I would prefer not to do it that way. Which brings me to my point: How do I render an external texture for my item? I followed the structure of this: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe15_item_dynamic_item_model I have the location of the File/BufferedImage but I do not know how to load it in, without reloading all textures. Code of the IBakedModel that is being called once the texture is downloaded and ready (I think it is pretty obvious that I have no idea how to do it, the code was just an experiment): public class CardIBakedModelCardID implements IBakedModel { public IBakedModel modelMain; private int cardID; private List<BakedQuad> list = null; public CardIBakedModelCardID(IBakedModel modelMain, int cardID, BufferedImage image) { this.modelMain = modelMain; this.cardID = cardID; } @Override public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { if(this.list == null) { this.list = new ArrayList<BakedQuad>(); List<BakedQuad> list2 = this.modelMain.getQuads(state, side, rand); for(BakedQuad quad : list2) { Minecraft mc = Minecraft.getMinecraft(); DynamicTexture dt = new DynamicTexture(Main.getImageForID(this.cardID)); ResourceLocation rl = mc.getTextureManager().getDynamicTextureLocation(Main.MOD_ID + ":" + "card" + this.cardID, dt); TextureAtlasSprite tas = mc.getTextureMapBlocks().registerSprite(rl); this.list.add(new BakedQuadRetextured(quad, tas)); } } return this.list; } @Override public boolean isAmbientOcclusion() { return this.modelMain.isAmbientOcclusion(); } @Override public boolean isGui3d() { return this.modelMain.isGui3d(); } @Override public boolean isBuiltInRenderer() { return false; } @Override public TextureAtlasSprite getParticleTexture() { return this.modelMain.getParticleTexture(); } @Override public ItemOverrideList getOverrides() { throw new UnsupportedOperationException("The finalised model does not have an override list."); } } Everything else is working already, this code is also being called, but the texture ingame is simply nothing / transparent. I hope someone can help me and everything I thought out is possible. Thanks in advance!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.