Jump to content

Tavi007

Members
  • Posts

    145
  • Joined

  • Last visited

Everything posted by Tavi007

  1. Hey, Indescriptive title aside I currently need help with 2 things. The first one is most likely something easy to fix and I'm just to stupid right now. I got the famous black-purple texture displayed as my block texture, but the block itemstack is showing the correct texture tho. Here are the blockstate and model file: My second problem is about the build.gradle file. I finished another mod, which is a library mod. Before I try to upload it to Maven Central, I would like to test it first by importing it into my test project. Since I got the jar locally I added implementation fg.deobf(files('C:/Minecraft Modding/ElementalCombat/build/libs/elementalcombat-forge-1.16.5-1.1.1-api.jar')) to the dependencies section of the build.gradle file. This does add the jar as library, but I run into a FieldNotFound exception on startup. The missing field has an obfuscated name, so I don't really know, what is missing. All I know is in which line the error occures and it's this one: https://github.com/Tavi007/ElementalCombat/blob/b562cba34d2bee7a647aa4d088372c917d67a3d4/src/main/java/Tavi007/ElementalCombat/init/EnchantmentList.java#L39 Do I get the error, because the minecraft mapping wasn't applied correctly? Or is it due to something completly different? I'm at a complete loss here. And here is the link to the gradle file: https://github.com/Tavi007/ElementalCombat-Weaponry/blob/main/build.gradle (It currently only uses the api jar, because this way I can keep working on it.)
  2. Ah okay. I knew, it must be something simple, that I overlooked. Texture will be changed anyway. I just threw some stuff together, but thanks for the heads up anyway.
  3. Hello. I want to render a small texture for a HUD. I currently have this for testing prupose: @SubscribeEvent public static void displayData(RenderGameOverlayEvent.Post event) { if(event.getType().equals(RenderGameOverlayEvent.ElementType.ALL)) { Minecraft mc = Minecraft.getInstance(); MatrixStack matrixStack = event.getMatrixStack(); mc.getTextureManager().bindTexture(new ResourceLocation("elementalcombat", "textures/icons/fire.png")); matrixStack.push(); matrixStack.scale(0.1F, 0.1F, 0.1F); mc.ingameGUI.blit(matrixStack, 0, 0, 0, 0, 256, 256); matrixStack.pop(); mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION); } } The image gets rendered, but I have few issues. 1. If I don't scale the matrixstack, the image is gigantic and takes up the full left side of the screen. 2. If I don't set the uWidth or vHeight to 256, only parts of the texture gets rendered. This is weird, cause the sprite has the size of 7x7 px. Why is the sprite ingame so gigantic and also exceed the 7x7 size? If I change my ResourceLocation to GUI_ICONS_LOCATION and disable the scaling, the rendered sprite has the normal size, that I would expect from it.
  4. ah okay. I will see, what will work best for me.
  5. Now you lost me. Where am I supposed to lazily initialise the values? In AttackData, in AttackDataCapability or somewhere complelty different?
  6. Okay, got it. I think, I can use the AttackDataAPI and DefenseDataAPI classes for this, because I (and anyone else) should always use these to interact with my capabilities.Or would this be bad practice? Thank you for your help anyway
  7. https://github.com/Tavi007/ElementalCombat you have to look in api/attack or api/defense for the capability
  8. Ah, so whenever I craft an item, the values, that were set in attachCapability will be overriden by the desirialized cpability from the old stack (which was an air item). That explains the bug. I could change the constructor of my capabilities to use ItemStack and then read from my Map<ResourceLocation, DataFromJson> in there, but I don't see, how this will solve the bug.
  9. Hmm, I already thought, that it would work like this. I guess, that the itemstack in the result slot gets created as an air item. Therefor the attachCapability event gets triggered with an air item and the default default values will be used. So what happens with the result stack, when I place the last iron ingot for crafting an iron sword and the result slot gets updated? And how could I detect that exact moment?
  10. just two maps and two strings. I use json files, so anyone can override them with datapacks. Basically each item, that should have default values, also has a corresponding json file. (if an item does not have a corresponding json file, then it will get default default values.) The information in the files are loaded into a Map<ResourceLocation, DataFromJson> once when the server starts, so i can get them whenever i need them. When the attach event (or the item craft event) trigger i resolve the resourceLocation, get the DataFromJson and then set the itemstack capability. As long as the Map doesn't get humongous, this method shouldn't be a performance issure.
  11. Hey, I stumbled across a bug in my mod, when using the workbench (and presumably any other sort of crafting station). I have an itemstack capability, that gets its default value through json files. So usually when the AttachCapabilityEvent<ItemStack> triggers, I can succesfully add these values to the item. However when the result slot in the workbench container updates to a new item, the attach event does not trigger and the capability stays empty. I added a hook using ItemCraftedEvent, so the values are being set, when the crafting results gets picked up, but I also added some costum tooltips, that displays the capability data. So currently it will not show any of my data, when the mouse hovers above the crafting result. Only after picking it up, the correct data can be seen. This might confuse the player, so I would like to know, if there is method for setting the default values the moment the resulting stack is generated. Also I fear, that the ItemCraftedEvent does not trigger for machines from other mods. This would mean, that it would be possible to create itemstacks with incorrect capability data. I hope my explanation is clear enough. If not, I can add some pictures to show you, what I mean.
  12. Bump let me summarize my questions: 1. What do I need to do, so that my mod can be added to any project using build.gradle? 2. Why does my second mod crash, when I add the compiled jar from my first mod manually to the project?
  13. Hey! I don't know, if this is the right place to ask the questions, but I don't know any better. So please bear with me I recently split my mod into 2 parts, one of which is basically a library, that includes all the functionality and an API. The other mod is my personal playground, that uses the former mod. I want other people be able to use the API without necessarily have to include my other playground mod (cause it's not really balanced, nor does it look pretty currently...). I want to realese my API in the same way as other mods do it, so a dev can easily include the right jar into their project using the gradle.build file (mods like curios and hwyla do it this way). I know that I need a remote repository, where the files are located, but I don't know, how I could setup one up. Is it possible to use curseforge for this? If so, how? Also I've tried to add to the API jar (which I build using 'gradlew build') manually to the playground mod by configuring the build path of my project in eclipse. This did kinda work, because I could call any method from this jar and the mod could also be build. However on startup the API mod runs into an error, that it didn't had previously and I don't understand why this happens. Here is the error log: ---- Minecraft Crash Report ---- // I let you down. Sorry :( Time: 02.03.21 13:18 Description: Mod loading error has occurred java.lang.Exception: Mod Loading has failed at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:85) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.client.ClientModLoader.completeModLoading(ClientModLoader.java:188) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.lambda$null$1(Minecraft.java:513) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.util.Util.acceptOrElse(Util.java:323) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:509) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.gui.ResourceLoadProgressGui.render(ResourceLoadProgressGui.java:113) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:492) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1002) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:612) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_271] {} at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271] {} at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_271] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.6.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at Tavi007.ElementalCombat.init.EnchantmentList.registerEnchantments(EnchantmentList.java:39) ~[elementalcombat:1.16.4-1.1] {re:classloading} -- MOD elementalcombat -- Details: Mod File: elementalcombat-forge-1.16.4-1.1.jar Failure message: Elemental Combat (elementalcombat) encountered an error during the load_registries event phase java.lang.NoSuchFieldError: field_77329_d Mod Version: 1.2 Mod Issue URL: NOT PROVIDED Exception message: java.lang.NoSuchFieldError: field_77329_d Stacktrace: at Tavi007.ElementalCombat.init.EnchantmentList.registerEnchantments(EnchantmentList.java:39) ~[elementalcombat-forge-1.16.4-1.1.jar:1.16.4-1.1] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_4_EnchantmentList_registerEnchantments_Register.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-3.0.5-service.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) ~[eventbus-3.0.5-service.jar:?] {} at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:120) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:35.1] {re:classloading} at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:121) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) ~[?:1.8.0_271] {} at net.minecraftforge.fml.ModWorkManager$SyncExecutor.driveOne(ModWorkManager.java:56) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.ModWorkManager$DrivenExecutor.drive(ModWorkManager.java:40) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.ModLoader.waitForTransition(ModLoader.java:243) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:230) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:196) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.client.ClientModLoader.lambda$begin$1(ClientModLoader.java:103) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:123) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:103) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.<init>(Minecraft.java:442) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:149) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_271] {} at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271] {} at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_271] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.6.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} -- System Details -- Details: Minecraft Version: 1.16.4 Minecraft Version ID: 1.16.4 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_271, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1378683432 bytes (1314 MB) / 1692401664 bytes (1614 MB) up to 3787980800 bytes (3612 MB) CPUs: 8 JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump ModLauncher: 8.0.6+85+master.325de55 ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /mixin-0.8.2.jar mixin PLUGINSERVICE /eventbus-3.0.5-service.jar eventbus PLUGINSERVICE /forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-2.2.0-shadowed.jar accesstransformer PLUGINSERVICE /forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-launcher.jar runtimedistcleaner PLUGINSERVICE /mixin-0.8.2.jar mixin TRANSFORMATIONSERVICE /forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-launcher.jar fml TRANSFORMATIONSERVICE FML: 35.1 Forge: net.minecraftforge:35.1.4 FML Language Providers: [email protected] minecraft@1 Mod List: client-extra.jar |Minecraft |minecraft |1.16.4 |COMMON_SET|a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f main |Elemental Combat - Weaponry |elementalcombat_weaponry |1.0 |COMMON_SET|NOSIGNATURE forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.|Forge |forge |35.1.4 |COMMON_SET|NOSIGNATURE elementalcombat-forge-1.16.4-1.1.jar |Elemental Combat |elementalcombat |1.2 |VALIDATE |NOSIGNATURE Crash Report UUID: 5d638879-48e2-4631-8cdb-a5b17fc91978 edit: I forgot my repositories: https://github.com/Tavi007/ElementalCombat <- this has the API https://github.com/Tavi007/ElementalCombat-Weaponry <- this is the playground
  14. Well TIL. Before I fix this problem, I would like to know, if my idea with the layer will even work. I've added this to my TextureLayer class: protected static <T extends LivingEntity> void renderCutoutModel(EntityModel<T> modelIn, ResourceLocation textureLocationIn, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entityIn, float red, float green, float blue) { IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RenderType.getEntityCutoutNoCull(textureLocationIn)); modelIn.render(matrixStackIn, ivertexbuilder, packedLightIn, LivingRenderer.getPackedOverlay(entityIn, 0.0F), red, green, blue, 0.01F); } so i can change the alpha value and see if this will affect the tranparency of my layer. Sadly that didn't do much. I've also read further into the vanilla render to see when exactly the color changes (and how). I don't really get how that packedOverlay integer changes the color. Normally it has the value 655360 and if hurttime>0 it has the value 196608. Adding this: ResourceLocation texturLocation = event.getRenderer().getEntityTexture(entityIn); RenderType rendertype = event.getRenderer().getEntityModel().getRenderType(texturLocation); IVertexBuilder ivertexbuilder = event.getBuffers().getBuffer(rendertype); event.getRenderer().getEntityModel().render(event.getMatrixStack(), ivertexbuilder, event.getLight(), 655360, 0.0F, 1.0F, 0.0F, 1.0F); to my LvingRender hook I was able to play around with packedOverlay value a bit more (tho the actual entity looks messed up. But I was only interessted in the overlay color). I could create a white overlay if I set the value to 1655360, but not any other color. Again, I don't understand how these numbers are used while rendering. I could however make the entity look greenish, by reducing the red and blue color (currently both are set to 0). Not that it matters, because I can't change them on the real model render anyway. I'm losing hope, that this feature will work Thank god, it isn't something fundamental, but I would have been really nice to have this included.
  15. I know that my question is a general java problem and that this forum should not be used as a java tutorial... I thought I would be fine, since T extends LivingEntity and M extends EntityModel<LivingEntity>. So if my renderer is an instance of LivingRenderer, shouldn't be the types T and M at least be LivingEntity and EntityModel ?
  16. LivingRenderer has the following definition: public abstract class LivingRenderer<T extends LivingEntity, M extends EntityModel<T>> extends EntityRenderer<T> implements IEntityRenderer<T, M> So I should be safe to cast it to LivingRenderer<LivingEntity, EntityModel<LivingEntity>> and will never crash, right? Also what about my other questions? To summarize my open questions: - Do semi-transparent texture work as a layer? - Will the layer be added to all LivingEntities (vanilla and modded) using the current method? If not, how can I get the LivingRenderer from the LivingEntity? - How can I make my layer be the outermost layer? If you do not know the answere to some of these, it's not a problem. But maybe you know someone, who might know the solution. Maybe a better solution would be to have another event hook added/move the .pre-event right before this.entityModel.render() is called in LivingRenderer#render. This way one could make last second changes to the rendering (and I could change the used OverlayTexture). Just to throw this idea in...
  17. For Minecraft.getInstance(): Resource leak: '<unassigned Closeable value>' is not closed at this location For the cast: Type safety: Unchecked cast from EntityRenderer<capture#2-of ?> to LivingRenderer<LivingEntity,EntityModel<LivingEntity>> and I casted it, because the normal EntityRenderer does not have the addLayer method.
  18. That didn't really help, because I don't know how I would get the renderer for each entity. I might have found an other solution. I added this to my FMLClientSetupEvent subscriber: Minecraft.getInstance().getRenderManager().renderers.forEach((entityType, entityRenderer) -> { if(entityRenderer instanceof LivingRenderer<?, ?>) { LivingRenderer<LivingEntity, EntityModel<LivingEntity>> livingRenderer = (LivingRenderer<LivingEntity, EntityModel<LivingEntity>>) entityRenderer; livingRenderer.addLayer(new TransparentGreenLayer(livingRenderer)); } }); and it did add the layer to the vanilla mobs (I tested it with a drowned). However I got 2 warnings doing this ('resource' for Minecraft.getInstance() and 'unchecked' for the cast.) I fear, that this could lead to a crash at some point. Also I'm unsure, if the layer will be added to other modded livingEntities, since I'm not using a forgeRegistry. I would feel much safer, if I could get the same loop via ForgeRegistries.ENTITIES. On another note. Currently the added layer isn't transparent, even though the texture is. If I change the texture to be completly transparent, it seems to be working, cause I couldn't see any layer, but the code was running (tested with a breakpoint). So are semi-transparent texture simply not working as a layer? That would be bad for my case and it would make my ultimate goal impossible (at least with a layer). @diesieben07 do you know someone, who has more insight on that matter?
  19. Do you know, how I could do a loop over all registered (Living-)EntityRenderer? You can start from the RenderManager, if it's the right direction...
  20. I'm a bit puzzled right now. Do I have to add the layer to every LivingEntityRenderer using a loop or are the 'base' classes MobRenderer and PlayerRenderer enough? In both cases I do not understand, how to do this exactly. All I know is Minecraft#getInstance().getRenderManager()... I do get, that moving the logic to the render function will fix the problem with the infinite duration. But what about the semi transparent texture? Will that even work this way? Besides what about the vanilla way. Reading through the minecraft code I didn't found a way to use the vanilla OverlayTexture directly. Or did you notice something?
  21. Okay, which event would be better suited for adding the layer? And you mean, I need to add a check in TransparentGreenLayer#render ? As for the red flash, I found the following. From LivingRenderer: public void render(T entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) { ... if (rendertype != null) { IVertexBuilder ivertexbuilder = bufferIn.getBuffer(rendertype); int i = getPackedOverlay(entityIn, this.getOverlayProgress(entityIn, partialTicks)); this.entityModel.render(matrixStackIn, ivertexbuilder, packedLightIn, i, 1.0F, 1.0F, 1.0F, flag1 ? 0.15F : 1.0F); } } public static int getPackedOverlay(LivingEntity livingEntityIn, float uIn) { return OverlayTexture.getPackedUV(OverlayTexture.getU(uIn), OverlayTexture.getV(livingEntityIn.hurtTime > 0 || livingEntityIn.deathTime > 0)); } ... } Following the stacktrace to IVertexBuilder I found this part: default IVertexBuilder overlay(int overlayUV) { return this.overlay(overlayUV & '\uffff', overlayUV >> 16 & '\uffff'); } The input in overla() is the same as the return value from getPackedOverlay(). I don't really understand, what the method from IVertexBuilder does here, nor do I not understand how I could use it to change the red color to a green one...
  22. Hello! I've been trying to add a special LayerRenderer, but I ran into a few problems. I want a layer that 1. can be applied to any LivingEntity. 2. is applied for a limited duration. 3. has a green, but also transparent, texture. 4. is the outermost layer. My ultimate goal is to have a green flash, similar to the red flash, that happens, when the entity gets damaged. If you know of another method besides layers, please let me know. I already tried to implement the renderer myself and this is my current state: In RenderEvents.java: @SubscribeEvent public static void onRenderLivingEventPre(RenderLivingEvent.Pre<LivingEntity, EntityModel<LivingEntity>> event) { LivingEntity entityIn = event.getEntity(); ImmersionData data = (ImmersionData) entityIn.getCapability(ImmersionDataCapability.IMMERSION_DATA_CAPABILITY, null).orElse(new ImmersionData()); if(entityIn.hurtTime > 0) { if (data.disableFlag) { data.setHurtTime(entityIn.hurtTime); entityIn.hurtTime = 0; //desync client and server hurtTime. Is this a problem? //to do: add green overlay texture if (flag) { TransparentGreenLayer layer = new TransparentGreenLayer(event.getRenderer()); event.getRenderer().addLayer(layer); flag = false; } } } else { data.disableFlag = false; } } TransparentGreenLayer.java: public class TransparentGreenLayer extends LayerRenderer<LivingEntity, EntityModel<LivingEntity>> { private final ResourceLocation transparentGreenTexture = new ResourceLocation(ElementalCombat.MOD_ID, "textures/models/transparent_green.png"); public TransparentGreenLayer(IEntityRenderer<LivingEntity, EntityModel<LivingEntity>> p_i226040_1_) { super(p_i226040_1_); } @Override public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, LivingEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { if (!entitylivingbaseIn.isInvisible()) { renderCutoutModel(this.getEntityModel(), transparentGreenTexture, matrixStackIn, bufferIn, packedLightIn, entitylivingbaseIn, 1.0F, 1.0F, 1.0F); } } } Rest can be found here (https://github.com/Tavi007/ElementalCombat/tree/testingGreenFlash) Currently the layer will be applied, but it's not transparent and once applied will stay permanently. Also it's applied to all entities (of the same type) simultaneously and some layers are applied after mine. The result looks like this: So can anyone help me please?
  23. Thank you poopoodice for leading me in the right direction. I could figure out quite a bit by myself and I'm going to explain what I did, so you guys can tell me, if it is a good solution or not. Generally both the screen shake and the red overlay texture are bound to the hurttime of the entity. I would have loved to change the hurttime directly, but the used forge event hook (LivingHurtEvent) happens before the hurttime gets its value. So i needed work around this problem. Problem 1: disabling the red flash. My solution was to temporarly set the hurttime of the entity to zero using RenderLivingEvent.Pre and Post. I added a capability for livingEntities, that holds a copy of the hurt time and a flag, that is set to true, when I want to disable the overlay texture. I also needed to send a message, because the server side event decides, when the entity (on the client side) should be rendered differently. With this capability in place I could do the following events: @SubscribeEvent public static void onRenderLivingEventPre(RenderLivingEvent.Pre<LivingEntity, EntityModel<LivingEntity>> event) { LivingEntity entityIn = event.getEntity(); HurtRenderData data = (HurtRenderData) entityIn.getCapability(HurtRenderDataCapability.HURT_RENDER_CAPABILITY, null).orElse(new HurtRenderData()); if(entityIn.hurtTime > 0) { if (data.disableFlag) { data.setHurtTime(entityIn.hurtTime); entityIn.hurtTime = 0; //desync client and server hurtTime. Is this a problem? //to do: add green overlay texture } } else { data.disableFlag = false; } } @SubscribeEvent public static void onRenderLivingEventPost(RenderLivingEvent.Post<LivingEntity, EntityModel<LivingEntity>> event) { LivingEntity entityIn = event.getEntity(); HurtRenderData data = (HurtRenderData) entityIn.getCapability(HurtRenderDataCapability.HURT_RENDER_CAPABILITY, null).orElse(new HurtRenderData()); if (data.disableFlag && data.getHurtTime() > 0) { entityIn.hurtTime = data.getHurtTime(); data.setHurtTime(0); } } I desyncronize the hurttime on client and server on purpose for a short amount of time, so that when the game renders the entity, with a hurttime of 0. To minimize the time, that client and server are desyncronized I reset the hurttime in the post event. It might be sufficient to set the hurttime to zero once and be done with it. However I do not know, if this can cause problems. Problem 2: disabling the screenshake Since there isn't a pre and post event for the EntityViewRenderEvent, I needed to trick the game differently. I had 2 options: Either remove the right matrix from the matrixstack or roll the camera back into the normal position. I assume, that removing the right matrixstack is the efficient solution, but I didn't know how I could do it. Instead I went with rolling the camera back into position. @SubscribeEvent public static void onEntityViewRenderEvent(CameraSetup event) { Minecraft mc = Minecraft.getInstance(); if(mc.player != null) { if (mc.player.hurtTime > 0) { HurtRenderData data = (HurtRenderData) mc.player.getCapability(HurtRenderDataCapability.HURT_RENDER_CAPABILITY, null).orElse(new HurtRenderData()); if(data.disableFlag) { // Use the same calculation as in GameRenderer#hurtCameraEffect. float f = (float) (mc.player.hurtTime - event.getRenderPartialTicks()); f = f / (float) mc.player.maxHurtTime; f = MathHelper.sin(f * f * f * f * (float)Math.PI); event.setRoll(f * 14.0F); // counter acts the screen shake. Only the hand is moving now. } } } } Again I use the flag from the capability to check, if I even want the roll back. Now I only need to do the same calculation as in GameRenderer#hurtCameraEffect, but instead of rolling to the left (hurtCameraEffect uses -f * 14.0F to roll the camera) I roll to the right. The result is a canceled animation (Tho the arm still twitches, because that is a different render. But I'm okay with this). I still have some question left: -How can I add a green overlay texture? I could add a LayerRender, which is just a slightly transparent green color, but I do not understand how I can do this. -As for disabling the hurt sound, I probably just need the right sound event. I haven't started to look into this yet, but If someone has an idea, which event could be the right one, plesae tell me. The help is appreciated.
  24. I'm currently also working on subduing the flash. My current idea is to save the hurt time in a capability befor the red flash happens and setting it to 0 (using LivingRenderEvent.Pre) and reset the hurttime after the rendering (using LivingRendereEvent.Post). I'll will admit, that this solution is kinda dirty, because I'm desyncronizing the hurttime on purpose.
  25. Bump. Can someone at least help me find the method, that applies the red overlay texture to a livingEntity in the minecraft code? Or the method, that makes the screen shake on hit? Thank you in advance
×
×
  • Create New...

Important Information

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