Jump to content

[1.12] "Mana" Capability


The_SlayerMC

Recommended Posts

So my mod has a mana type of use called "Essence"

Whats happening is its nulling out when getting the value somewhere and i cant for the life of me figure it out

 

I know where it nulls out and i dont see why when its just trying the get the value of the mana bar

 

	[22:35:48] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Player665 joined the game
[22:35:48] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.fml.common.gameevent.TickEvent$PlayerTickEvent@2eed9875:
java.lang.NullPointerException: null
    at net.journey.client.BarTickHandler.tickEnd(BarTickHandler.java:79) ~[BarTickHandler.class:?]
    at net.journey.client.BarTickHandler.onTick(BarTickHandler.java:30) ~[BarTickHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_27_BarTickHandler_onTick_PlayerTickEvent.invoke(.dynamic) ~[?:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
    at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:369) [FMLCommonHandler.class:?]
    at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:416) [EntityPlayer.class:?]
    at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:326) [EntityPlayer.class:?]
    at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423) [EntityPlayerMP.class:?]
    at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185) [NetHandlerPlayServer.class:?]
    at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212) [NetworkDispatcher$1.class:?]
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) [NetworkManager.class:?]
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) [NetworkSystem.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
[22:35:48] [Server thread/ERROR] [FML]: Index: 3 Listeners:
[22:35:48] [Server thread/ERROR] [FML]: 0: NORMAL
[22:35:48] [Server thread/ERROR] [FML]: 1: ASM: net.journey.event.ArmorAbilityEvent@2d980ff2 playerTick(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V
[22:35:48] [Server thread/ERROR] [FML]: 2: ASM: net.journey.event.PlayerEvent@14f13587 onTick(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V
[22:35:48] [Server thread/ERROR] [FML]: 3: ASM: net.journey.client.BarTickHandler@45c95343 onTick(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V
[22:35:49] [Server thread/ERROR] [FML]: 4: ASM: net.journey.event.PlayerEvent@290df0bf onTick(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V
[22:35:49] [Server thread/ERROR] [FML]: 5: ASM: net.journey.event.ClientTickEvent@7a843a7a clientTickEvent(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V
[22:35:49] [Server thread/ERROR] [net.minecraft.server.MinecraftServer]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking player
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:212) ~[NetworkSystem.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) ~[MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) ~[MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
Caused by: java.lang.NullPointerException
    at net.journey.client.BarTickHandler.tickEnd(BarTickHandler.java:79) ~[BarTickHandler.class:?]
    at net.journey.client.BarTickHandler.onTick(BarTickHandler.java:30) ~[BarTickHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_27_BarTickHandler_onTick_PlayerTickEvent.invoke(.dynamic) ~[?:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) ~[EventBus.class:?]
    at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:369) ~[FMLCommonHandler.class:?]
    at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:416) ~[EntityPlayer.class:?]
    at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:326) ~[EntityPlayer.class:?]
    at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423) ~[EntityPlayerMP.class:?]
    at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185) ~[NetHandlerPlayServer.class:?]
    at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212) ~[NetworkDispatcher$1.class:?]
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) ~[NetworkManager.class:?]
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) ~[NetworkSystem.class:?]
    ... 5 more
[22:35:49] [Server thread/ERROR] [net.minecraft.server.MinecraftServer]: This crash report has been saved to: D:\Development\Minecraft\Forge\1.12\.\crash-reports\crash-2018-07-31_22.35.49-server.txt
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Stopping server
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving players
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving worlds
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/overworld
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Boiling Point
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Depths
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Euca
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Senterian
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Golden Grains
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Terrania
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Cloudia
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Corba
[22:35:49] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'New World'/Frozen
[22:35:50] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// I just don't know what went wrong :(
	Time: 7/31/18 10:35 PM
Description: Ticking player
	java.lang.NullPointerException: Ticking player
    at net.journey.client.BarTickHandler.tickEnd(BarTickHandler.java:79)
    at net.journey.client.BarTickHandler.onTick(BarTickHandler.java:30)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_27_BarTickHandler_onTick_PlayerTickEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:369)
    at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:416)
    at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:326)
    at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423)
    at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185)
    at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212)
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307)
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
    at java.lang.Thread.run(Unknown Source)
	
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
	-- Head --
Thread: Client thread
Stacktrace:
    at net.journey.client.BarTickHandler.tickEnd(BarTickHandler.java:79)
    at net.journey.client.BarTickHandler.onTick(BarTickHandler.java:30)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_27_BarTickHandler_onTick_PlayerTickEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPostTick(FMLCommonHandler.java:369)
    at net.minecraft.entity.player.EntityPlayer.updateSize(EntityPlayer.java:416)
    at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:326)
	-- Player being ticked --
Details:
    Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)
    Entity ID: 206
    Entity Name: Player665
    Entity's Exact location: 203.50, 69.00, 250.50
    Entity's Block location: World: (203,69,250), Chunk: (at 11,4,10 in 12,15; contains blocks 192,0,240 to 207,255,255), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
    Entity's Momentum: 0.00, -0.08, 0.00
    Entity's Passengers: []
    Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
    at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423)
    at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185)
    at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212)
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307)
	-- Ticking connection --
Details:
    Connection: net.minecraft.network.NetworkManager@2b9ac5e
Stacktrace:
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
    at java.lang.Thread.run(Unknown Source)
	

 

	public interface IEssence {
	    public boolean useEssence(int points);
    public void addEssence(int points);
    public void setEssence(int essence);
    public int getEssenceValue();
    public void update();
    public void regen();
}
	

 

	public class EssenceBar implements IEssence {
	    private int essenceValue = 10;
    
    @Override
    public boolean useEssence(int points) {
        if(essenceValue < points) 
            return false;
        essenceValue -= points;
        return true;
    }
	    @Override
    public void addEssence(int points) {
        essenceValue += points;
        if(essenceValue > 10) essenceValue = 10;
    }
	    @Override
    public void setEssence(int essence) {
        essenceValue = essence;
    }
	    @Override
    public int getEssenceValue() {
        return essenceValue;
    }
	    @Override
    public void update() {
        if(essenceValue > 10) essenceValue = 10;        
    }
    
    @Override
    public void regen() {
        essenceValue += 1;
    }
}
	

 

	public class EssenceProvider implements ICapabilitySerializable<NBTBase> {
	    @CapabilityInject(IEssence.class)
    public static final Capability<IEssence> ESSENCE_CAP = null;
    
    private IEssence INSTANCE = ESSENCE_CAP.getDefaultInstance();
    
    @Override
    public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
        return capability == ESSENCE_CAP;
    }
	    @Override
    public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
        return capability == ESSENCE_CAP ? ESSENCE_CAP.<T>cast(this.INSTANCE) : null;
    }
	    @Override
    public NBTBase serializeNBT() {
        return ESSENCE_CAP.getStorage().writeNBT(ESSENCE_CAP, INSTANCE, null);
    }
	    @Override
    public void deserializeNBT(NBTBase nbt) {
        ESSENCE_CAP.getStorage().readNBT(ESSENCE_CAP, INSTANCE, null, nbt);
    }
	}
	

 

	public class EssenceStorage implements IStorage<IEssence> {
	    @Override
    public NBTBase writeNBT(Capability<IEssence> capability, IEssence instance, EnumFacing side) {
        return new NBTTagInt(instance.getEssenceValue());
    }
	    @Override
    public void readNBT(Capability<IEssence> capability, IEssence instance, EnumFacing side, NBTBase nbt) {
        instance.setEssence(((NBTTagInt)nbt).getInt());
    }
}
	

 

	COMMON PROXY PRE INIT:
	 
	MinecraftForge.EVENT_BUS.register(JourneyCapabilityHandler.class);
        CapabilityManager.INSTANCE.register(IEssence.class, new EssenceStorage(), EssenceBar.class);
        SlayerAPI.registerEvent(new BarTickHandler());
	

 

	BAR RENDERING CODE
	public class BarTickHandler {
    
    private int ticks = 10;
	    @SubscribeEvent
    public void onTick(PlayerTickEvent event) {
        if(event.phase == Phase.END) tickEnd(event.player);
    }
    
    @SideOnly(Side.CLIENT)
    @SubscribeEvent
    public void renderEvent(RenderTickEvent event) {
        onTickRender(Minecraft.getMinecraft().player);
    }
	    @SideOnly(Side.CLIENT)
    private void onTickRender(EntityPlayer player) {
        Minecraft mc = Minecraft.getMinecraft();
        if(mc.currentScreen == null) {
            if(!player.capabilities.isCreativeMode) {
                IEssence mana = player.getCapability(EssenceProvider.ESSENCE_CAP, null);
                GL11.glPushMatrix();
                GlStateManager.enableBlend();
                GlStateManager.enableAlpha();
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GuiIngame gig = mc.ingameGUI;
                ScaledResolution scaledresolution = new ScaledResolution(mc);
                mc.getTextureManager().bindTexture(new ResourceLocation(SlayerAPI.MOD_ID, "textures/gui/misc.png"));
                //int sw = scaledresolution.getScaledWidth(), sh = scaledresolution.getScaledHeight();
                int y = scaledresolution.getScaledHeight() - 30, x = 10, x1 = 10, x2 = 10;
                gig.drawTexturedModalRect(x - 10, y + 10, 0, 177, 117, 19);
                gig.drawTexturedModalRect(x - 10, y - 5, 0, 177, 117, 19);
                gig.drawTexturedModalRect(x - 10, y - 20, 0, 177, 117, 19);
	                gig.drawTexturedModalRect(x - 6, y - 13, 0, 23, 109, 5);
                for(int i = 0; i < mana.getEssenceValue(); i++) {
                    if(!(i >= 10)) {
                        x += 11;
                        gig.drawTexturedModalRect(x - 17, y - 13, 0, 0, 10, 5);
                    }
                }
                GlStateManager.disableAlpha();
                GlStateManager.disableBlend();
                GL11.glPopMatrix();
            }
        }
    }
	    private void tickEnd(EntityPlayer player) {
        IEssence mana = player.getCapability(EssenceProvider.ESSENCE_CAP, null);
        if(ticks-- <= 0) ticks = 10;
        
        if(ticks >= 10) 
            mana.regen(); // THIS ONE IS NULLING OUT
        
        mana.update();
    }
}
	

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Link to comment
Share on other sites

The mana capability is null. 

Your code is full of issues that you must fix:

  • You are reaching across logical sides in a lot of places like here(PlayerTickEvent is common, Minecraft is client only).
  • Why is this class named ClientTickEvent? There is nothing client about it, it's common code. Also it is probably a bad idea to create a new Random object twice each tick per player.
  • You are using numerical IDs which is a really bad idea since they can and will unpredictably change.
  • Forge already has a built-in update checker. This is just extra work you don't have to do. It also does the check on the main thread which means that if the page is unavailable for some reason or takes a really long time to respond the client will stall potentially forever(or at least untill the timeout happens).
  • Why is this in your client package? Presumably the mana regeneration is server-only or at the very least common code, is it not?
  • You are using GL11 directly and by doing that corrupting the state of the GlStateManager. You must use GlStateManager, not GL11.
  • As far as I know RenderTickEvent is fired every frame regardless of whether there is a player or not. You must be checking for the player in your event handler. The only reason it doesn't crash now is because of this line and that is not the propper check. If some mod nullifies the currentScreen before the world is started your code will crash.
  • Why on earth are you only adding your capability on the client? This is the root cause of your problem. Presumably you need this capability on the server aswell yes? Otherwise it serves no purpose. Or are you going to send packets based on trusting the client?
  • Oh it is also worth pointing out that currently every entity in the game apart from the only one that needs it has your mana capability. I don't think that this is whay you wanted.
  • Especially considering that right in the same file on the next few lines you are copying the capability disregarding whether it's the client asking you to clone it or the server.
  • Code-style issues #1 and #3

And those are just the issues I found at a quick glance at the repo. I'm sure there are many more.

 

Link to comment
Share on other sites

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Link to comment
Share on other sites

  • What is this package? What does it even mean?
  • Why are you now registering your capabilities in init? Capabilities should be available as soon as possible, not delayed untill init.
  • You are still using direct calls to GL11.
  • The more players on the server the faster this will tick down and thereby the faster the mana will regen... for one player out of them all. Store this value in the capability.
  • Why did you just straight up delete your clone event? You need that to persist capability data.

Apart from that your capability registration seems correct. Does the issue still persist?

Link to comment
Share on other sites

9 hours ago, V0idWa1k3r said:
  • What is this package? What does it even mean?
  • Why are you now registering your capabilities in init? Capabilities should be available as soon as possible, not delayed untill init.
  • You are still using direct calls to GL11.
  • The more players on the server the faster this will tick down and thereby the faster the mana will regen... for one player out of them all. Store this value in the capability.
  • Why did you just straight up delete your clone event? You need that to persist capability data.

Apart from that your capability registration seems correct. Does the issue still persist?

Yes the issue still happens

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I invested a total of £65,000 with a company that ultimately became a scam. The journey began when I made my first deposit of £15,000, driven by promises of high returns and secure investments. Encouraged by what seemed to be a growing balance, I invested an additional £20,000, believing I was making a wise financial decision. At first, I saw some profits, which only reinforced my trust in the company. However, when I attempted to withdraw some of my earnings, I was met with unexpected resistance. The company told me that I needed to set a target of £50,000 to make any withdrawals. This request seemed reasonable at the time, so I complied. To reach this target, I made yet another deposit of £15,000, bringing my total investment to £50,000. After achieving the target, I was eager to access my funds. Unfortunately, when I submitted my withdrawal request, it was denied without a clear explanation. Instead, I was informed that I needed to pay an additional amount to unlock my funds. This was incredibly frustrating and felt like a trap, but desperate to recover my money, I reluctantly paid £15,000 more. At this point, my total investment had escalated to £65,000, and I felt completely trapped in a situation I never intended to be in. Feeling defeated and anxious, I began searching for solutions online. During this search, I came across TECH CYBER FORCE RECOVERY, a company that had successfully assisted others in retrieving their lost funds from similar scams. Intrigued by the positive testimonials, I decided to give them a chance. From the very first consultation, I was impressed by their professionalism and expertise. The team at TECH CYBER FORCE RECOVERY took the time to understand my situation thoroughly. They guided me through every step of the recovery process, ensuring I was informed and involved throughout. Their transparent communication and expert advice gave me a renewed sense of hope. With their help, I learned about my legal rights and the steps I could take to increase my chances of recovering my investment. TECH CYBER FORCE RECOVERY's dedication to my case was evident, and I felt supported at every turn. Eventually, thanks to their tireless efforts and expertise, I was able to recover my funds. Looking back, I realize how crucial it is to be cautious when investing. My experience taught me valuable lessons about due diligence and the importance of seeking professional help when faced with financial difficulties. I wholeheartedly recommend TECH CYBER FORCE RECOVERY to anyone who finds themselves in a similar predicament. Their support made all the difference in my journey to reclaim my money. WEBSITE.W.W.W.techcyberforcerecovery.info       EMAIL. .T.e.c.h.c.y.be..rs.f..o.r.c.e.r.e.c.o.v.e.r.y.@.c.y.b.e.r.s.e.r.v.i.c.e.s..c.o.m
    • You can try other builds of Quark/Zeta
    • Hello all, I recently tried to upgrade my Minecraft mod to version 1.21.3, and I seem to have a problem with the `RenderSystem#setShaderColor` method. Here is how the screen is usually supposed to look like: Here is how it looks at present: To further explain, the note labels atop of the note buttons are colored cyan (here) using `RenderSystem#setShaderColor`. The note buttons and labels get their colors from their native texture - white. This means that even though I set the coloring to apply to the label (top), it is applied to the button (bottom). What I conclude is happening then, in essence, is that this method (at least for my case) does not color the blit after - but rather the blit before..?  This also blocks me from later resetting the shader, as I need to set it back to white before the blitting is done, and not when it's done. So like... what? I've tested this further with other components that require this method, and this preceding-like behavior seems to be pretty consistent for them too.   I should mention that all the snippets I am about to show have all worked in past versions. In my class `ClientUtil`, the following methods are defined: public static void setShaderColor(final Color color, final float alpha) { RenderSystem.setShaderColor( color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, alpha ); } public static void setShaderColor(final Color color) { setShaderColor(color, 1); } public static void resetShaderColor() { setShaderColor(Color.WHITE); } //... public static RenderType guiRT(final ResourceLocation loc) { return RenderType.guiTextured(loc); } And here is the snippet from `NoteButtonRenderer#renderNote` using it: // "Note" here refers to those symbols in the middle of a note button protected void renderNote(final GuiGraphics gui, final InstrumentThemeLoader themeLoader) { final int noteWidth = noteButton.getWidth()/2, noteHeight = noteButton.getHeight()/2; ClientUtil.setShaderColor((noteButton.isPlaying() && !foreignPlaying) ? themeLoader.notePressed() : themeLoader.noteReleased() ); gui.blit(ClientUtil::guiRT, noteTextureProvider.get(), noteButton.getX() + noteWidth/2, noteButton.getY() + noteHeight/2, 0, 0, noteWidth, noteHeight, noteWidth, noteButton.getHeight()/2 ); ClientUtil.resetShaderColor(); } You may find the full source here. The odd thing is that Minecraft does seem to use this method the regular way I showed, for instance `SkyRenderer#renderSkyDisc` (not sure if I'l allowed to paste it). Could it be that I'm doing something wrong that leads to this issue..? I'm really stumped on this one.  I couldn't really find any change logs or documentation for this rendering API (even in this Fabric blog post), so I'm sorry if this seems obvious or anything.  Either way, any help would be appreciated.
    • This did work. rip Quark Thank you
    • It says Quark Requires zeta. do i just remove Quark? https://mclo.gs/cq799kI
  • Topics

×
×
  • Create New...

Important Information

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