Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.15.2- 31.1.0] DefferdWorkQueue is Deprecated what should i use instead ?

Featured Replies

Posted

Dear Fellow Minecraft Modders,

i am currently trying to register an Screen Object in the FmlClientSetup event.

To do this many tutorial use the DefferdWorkQueue.runLater Method, but in my current minecraft forge version [1.15.2- 31.1.0] this class is deprecated and doesn't work.

So my question is what do is use instead to achieve the same goal.

The documentation recomends to use the IThreadListener but i cant find out how to use it over even where the Interface or class should be located.

 

When i launch the mod using the DefferdWorkQueue following error Message appears:

encounterd an errror processing defferd work

java.lang.NullPointerException: Registry Object not present

 

Source:

@SubscribeEvent
   public static void clientSetupEvent (final FMLClientSetupEvent event){
       
       DeferredWorkQueue.runLater(()->ScreenManager.registerFactory(ModContainerTypes.SOLAR_PANEL.get(),SolarPanelScreen::new));


   }

 

if you need more information in a happy to provide more.

 

Edited by TheZombie1999

  • Author

Thank you for your quick reply. 

i included my log files because i don't understand what my mistake is.

 

my code is as follows:

 

public class ModContainerTypes {
    public static final DeferredRegister<ContainerType<?>> CONTAINER_TYPES = new DeferredRegister<>(ForgeRegistries.CONTAINERS, NovusTechnica.MODID);

    public static final RegistryObject<ContainerType<SolarPanelContainer>> SOLAR_PANEL = CONTAINER_TYPES.register("solar_panel",() -> (IForgeContainerType.create(SolarPanelContainer::new)));
}

 

 

public class SolarPanelScreen extends ContainerScreen<SolarPanelContainer> {

    private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation(NovusTechnica.MODID,"/textures/gui/solar_panle_container.png");

    public SolarPanelScreen(SolarPanelContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
        super(screenContainer, inv, titleIn);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
        getMinecraft().getTextureManager().bindTexture(BACKGROUND_TEXTURE);
        int startX = this.guiLeft;
        int startY = this.guiTop;

        this.blit(startX,startY, 0,0,this.xSize,this.ySize);

        final SolarPanelTileEntity tileEntity = container.tileEntity;
      final SettableEnergyStorage settableStorage = tileEntity.energy;

      final int energyStored = settableStorage.getEnergyStored();

      if (energyStored > 0) { // Draw energy bar
         //this.blit();
            // ToDo set blit
      }
    }

    @Override
    public void render(int mouseX, int mouseY, float partickelTicks) {
        this.renderBackground();
        super.render(mouseX, mouseY, partickelTicks);
        this.renderHoveredToolTip(mouseX,mouseY);

        // TODO zahlen werte anpassen
        int relMouseX = mouseX - this.guiLeft;
      int relMouseY = mouseY - this.guiTop;
      boolean energyBarHovered = relMouseX > 151 && relMouseX < 166 && relMouseY > 10 && relMouseY < 76;
      if (energyBarHovered) {
         String tooltip = new TranslationTextComponent(
               "gui." + NovusTechnica.MODID + ".energy",
               this.container.tileEntity.energy.getEnergyStored()
         ).getFormattedText();
         this.renderTooltip(tooltip, mouseX, mouseY);
      }


    }
}

 

I have absolutly no idea whats wrong so i really need your help Thank you very much for your support !!!!

latest.log

  • Author

thanks mate now it works.

But how did you realize that i didn't register the defferdRegister, because i could figure it out form the log.

May be you could give me some insight so i can figure it out my self the next time.

and Thanks again for your time and great advise.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.