Jump to content

Force a block to call isProvidingWeakPower


ConsoleHack000

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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