Jump to content

Recommended Posts

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

Posted

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

Posted

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.

Announcements



×
×
  • Create New...

Important Information

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