Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.14.4] Problem with creating Container for TileEntity


Tieso2001
 Share

Recommended Posts

I followed this tutorial from McJty: https://wiki.mcjty.eu/modding/index.php?title=Tut14_Ep4.

to create a container for my TileEntity. I got everything worked except the screen part.

 

I have this:

Spoiler

public class ClientProxy implements IProxy {

    @Override
    public void init() {
        ScreenManager.registerFactory(ModContainerTypes.CASK_CONTAINER, CaskScreen::new);
    }

    @Override
    public World getClientWorld() {
        return Minecraft.getInstance().world;
    }

    @Override
    public PlayerEntity getClientPlayer() {
        return Minecraft.getInstance().player;
    }
}

 

The problem is CaskScreen::new says it is a bad return type and that it cannot convert CaskScreen to U. What did I do wrong?

 

CaskScreen.class:

Spoiler

public class CaskScreen extends ContainerScreen<CaskContainer> {

    private ResourceLocation GUI = new ResourceLocation(BoneAppleTea.MOD_ID, "textures/gui/cask_gui.png");

    public CaskScreen(CaskContainer container, PlayerInventory inventory, ITextComponent name) {
        super(container, inventory, name);
    }

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

    @Override
    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
        super.drawGuiContainerForegroundLayer(mouseX, mouseY);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
        GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.minecraft.getTextureManager().bindTexture(GUI);
        int relX = (this.width - this.xSize) / 2;
        int relY = (this.height - this.ySize) / 2;
        this.blit(relX, relY, 0, 0, this.xSize, this.ySize);
    }
}

 

 

Edited by Tieso2001
Link to comment
Share on other sites

18 hours ago, diesieben07 said:

Show the ModContainerTypes class.

Spoiler

@SubscribeEvent
    public static void onRegisterContainerTypes(final RegistryEvent.Register<ContainerType<?>> event) {
        event.getRegistry().registerAll(
                IForgeContainerType.create(((windowId, inv, data) -> {
                    BlockPos pos = data.readBlockPos();
                    return new CaskContainer(windowId, BoneAppleTea.proxy.getClientWorld(), pos, inv, BoneAppleTea.proxy.getClientPlayer());
                })).setRegistryName("cask")
        );
    }

 

Spoiler

@ObjectHolder(BoneAppleTea.MOD_ID)
public class ModContainerTypes {

    public static final ContainerType<?> CASK_CONTAINER = Null();
}

 

 

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.