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.

Featured Replies

Posted

So guys im trying to make a block which emits redstone power based on tile entity data. The thing is that it works but doesn't keep updating every tick so its just stuck in the same redstone state. Even scheduling block updates doesn't help. Here's my code.

 

TileEntityRedstoneTimer:

package net.net23.aregsroom.mc.lotostuff.entities.tile;

import net.minecraft.tileentity.TileEntity;
import net.net23.aregsroom.mc.lotostuff.Constants;

/**
* Created by DeLL on 05/08/2016.
*/
public class TileEntityRedstoneTimer extends TileEntity{

    public float tix = 0;
    public int side = 3;

    @Override
    public boolean canUpdate() {
        return true;
    }

    @Override
    public void updateEntity() {
        if(worldObj.isRemote) return;
        tix++;
        if(tix>20){
            side++;
            if(side>6){
                side=3;
                tix=0;
            }
            worldObj.scheduleBlockUpdate(xCoord,zCoord,yCoord, Constants.rTimer,Constants.rTimer.tickRate(worldObj));
        }
    }
}

RedstoneTimer:

package net.net23.aregsroom.mc.lotostuff.tools.blocks;

import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.net23.aregsroom.mc.lotostuff.entities.tile.TileEntityRedstoneTimer;

import static net.net23.aregsroom.mc.lotostuff.Constants.tabMetal;

public class RedstoneTimer extends Block implements ITileEntityProvider {


    public RedstoneTimer() {
        super(Material.circuits);
        setCreativeTab(tabMetal);
        setBlockName("rtimer");
        setHardness(5);
        setHarvestLevel("pickaxe", 1);
        setStepSound(Block.soundTypeMetal);
        setResistance(2);
        setLightOpacity(0);
        GameRegistry.registerBlock(this, getUnlocalizedName().substring(5));
    }

    @Override
    public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
        return new TileEntityRedstoneTimer();
    }

    @Override
    public int isProvidingWeakPower(IBlockAccess iba, int x, int y, int z, int side) {
        TileEntityRedstoneTimer t = (TileEntityRedstoneTimer) iba.getTileEntity(x, y, z);
        if (t.side == side) {
            return 15;
        }
        return 0;
    }

    @Override
    public boolean canProvidePower() {
        return true;

    }
}

Any help would be really appreciated

Currently developing a mod called Lot'O'Stuff for 1.7.10 (I know very well its outdated.)

Your tile needs to implement ITickable for it to get access to a method (onUpdate) that is scheduled every tick.

Use your updateEntity code in that instead.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

  • Author

Please, I beg you. Stop asking me to upgrade. Yeah ok I am using the mechanics wrong. Could you help me?

Currently developing a mod called Lot'O'Stuff for 1.7.10 (I know very well its outdated.)

This is what is called when you schedule a update for a block.

 

public void updateTick(World world, int x, int y, int z, Random rand) {}

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author

Yeah ok so it turns out that I don't need to schedule update ticks. I want to "update" my isProvidingRedstonePower every tick

Currently developing a mod called Lot'O'Stuff for 1.7.10 (I know very well its outdated.)

Guest
This topic is now closed to further replies.

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.