Jump to content

Sun Collector Tick Problem


Recommended Posts



I have a logic problem...

I want to make a sun collector which gets a sunstar every 24'000 ticks. The sun collectorr has a gui, in that gui the count of ticks gets rendered. Yet I have stored the amount of ticks in the TileEntitySunCollecter but the Problem is, that all Blocks of Type Sun Collector have the same count, because of the static variable in TileEntitySunCollector.

So my question how can I update a count every tick and make it avaible for my ConatinerSunCollecter and for my GuiSunCollector without be the same variable for all blocks?

The ContainerSunCollector must update the items in the Block Inventory and the GuiSunCollector must render the amount of ticks...

I hope you guys can help me...And sorry for my englisch I'm only 13 and german....

Thank you in advance for every help.

Link to comment
Share on other sites

Yes, i tried that but the problem is, that I can't acces than from GuiSunColector.


package Cerebrum.Basis;

import java.util.Set;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

import org.lwjgl.opengl.GL11;

public class GuiSunCollector extends GuiContainer {

        public GuiSunCollector (InventoryPlayer inventoryPlayer,
                        TileEntitySunCollector tileEntity) {
                //the container is instanciated and passed to the superclass for handling
                super(new ContainerSunCollector(inventoryPlayer, tileEntity));
        protected void drawGuiContainerForegroundLayer(int param1, int param2) {
                //draw text and stuff here
                //the parameters for drawString are: string, x, y, color
                fontRenderer.drawString("Sun Collector", 8, 6, 4210752);
                //draws "Inventory" or your regional equivalent
                fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
                fontRenderer.drawString(""+TileEntitySunCollector.count, 8, 16, 4210752);

        protected void drawGuiContainerBackgroundLayer(float par1, int par2,
                        int par3) {
                //draw your Gui here, only thing you need to change is the path
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                int x = (width - xSize) / 2;
                int y = (height - ySize) / 2;
                this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

There's an Error because count is not static...

I must get access to the TileEntity in the constructor, right?

How can I do that?

Link to comment
Share on other sites

public TileEntitySunCollector sunCollector;

public GuiSunCollector (InventoryPlayer inventoryPlayer,
                        TileEntitySunCollector tileEntity) {
                //the container is instanciated and passed to the superclass for handling
                super(new ContainerSunCollector(inventoryPlayer, tileEntity));
                this.sunCollector = tileEntity;

then use sunCollector.count ;)

Link to comment
Share on other sites

Thank you...this works but how can I change increase the variable count now from TickHandler? Or increase it every tick otherwise?


My TickHandler:

if (ModLoader.getMinecraftInstance().theWorld.isDaytime()){

This don't works...because count is non static.

Or is there a way to update count every tick inside of the TileEntitySunCollector without a TickHandler?

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.

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 figured out what was wrong ... you can spot it pretty quick most likely: { "type": "minecraft:smelting", "ingredient": { "item": "minecraft:gold_nugget_ore" }, "result": "minecraft:gold_nugget", "experience": 0.25, "cookingtime": 150 }   ... so, after changing `minecraft` to `foundations` for all the custom items and all the recipes work. Well that's what copy/paste will get you. One last question about recipes, though. What does the following json key/value do in the game? "group": "copper_ingot"  
    • # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # #     rhino.acme.com          # source server #     x.acme.com              # x client host # localhost name resolution is handled within DNS itself. #       localhost #    ::1             localhost ### apps.corel.com ### mc.corel.com origin-mc.corel.com ### iws.corel.com
    • Is there a way to create a custom map marker for a custom structure/biome (same as a vanilla mansion)?
    • I’ve scrounged the Internet for solutions and found absolutely nothing that has worked for me I have posted my code in a GitHub Repository. I bet the culprit is somewhere in the Container or TileEntity classes (Furnace packages are in blocks/coke_furnace or blocks/foundry) PS I know I’m on 1.12.2 and that it’s not supported I don’t want to update my game or my code. Lol It’s my favorite version and the most widely modded. I don’t plan to release the mod, I’m just customizing my game to my will. I’ll send it to friends but that’s it.
    • 1.19.2 With forge 43.2.4   https://mclo.gs/zCAx1MG      
  • Topics

  • Create New...

Important Information

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