Jump to content

Redstone is buggy!


Moritz

Recommended Posts

Hello i did find out how to makes a redstone Signal. And it works very well. But i have 1 problem.

 

It must have a block between the redstonewire and the block (that provides the redstone signal) else there would be no signal!

 

here is my sourcecode: https://github.com/Speiger/DynamicTools/blob/master/spmod_common/speiger/src/tinychest/common/blocks/BlockAdvTinyChest.java

 

so how can i fix it?

Link to comment
Share on other sites

Ok i explaine it again.

 

I made a Chest. Which if (it is active) create a redstone signal on the top. and when its deactive it creates a Signal on the bottom.

Now the problem is it does need a block between it!

but i want to make it like a redstone torch,repeater, presureplate, button, lever.

 

So how can i fixing it?

 

Link to comment
Share on other sites

  • 2 weeks later...

I'm not sure if I understand your intention, but let's see now.

 

You want a block between your chest and the redstone, so that you need to power the block between them in order to be able to power the chest?

 

The block which is in between could it be any kind of block or could is it a specific block from your mod?

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

I'm not sure if I understand your intention, but let's see now.

 

You want a block between your chest and the redstone, so that you need to power the block between them in order to be able to power the chest?

 

The block which is in between could it be any kind of block or could is it a specific block from your mod?

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

First at all i do not need to make my material to a circuit. I tried that but it came the same result.

 

That you cant view my code is because i deleted the source from github.

 

Second: What the first picture is showen how my block is powering other blocks.

 

But what i want is that my block act as a normal redstonesignalprovider. Thats why i made the second pic with the redstone torch.

 

I mean my block is powerring the block which is touching my block block xD

 

Link to comment
Share on other sites

First at all i do not need to make my material to a circuit. I tried that but it came the same result.

 

That you cant view my code is because i deleted the source from github.

 

Second: What the first picture is showen how my block is powering other blocks.

 

But what i want is that my block act as a normal redstonesignalprovider. Thats why i made the second pic with the redstone torch.

 

I mean my block is powerring the block which is touching my block block xD

 

Link to comment
Share on other sites

As redstonetorch/block/repeater/wire.

 

My block is powerring the block next to my block and that is not what i want^^

I want a normal redstonesignal like a mfsu mfsu but in a special direcition.

 

If full: Redstone signal on top

else if Empty: Redstone signal on bottom

else return false;

Link to comment
Share on other sites

As redstonetorch/block/repeater/wire.

 

My block is powerring the block next to my block and that is not what i want^^

I want a normal redstonesignal like a mfsu mfsu but in a special direcition.

 

If full: Redstone signal on top

else if Empty: Redstone signal on bottom

else return false;

Link to comment
Share on other sites

If full: Redstone signal on top

else if Empty: Redstone signal on bottom

else return false;

 

Now this is the first clear thing you have said about what you are trying to do :)

 

So you have a variable that you change and when it is at max value it will power blocks above it while its less it powerss those to the side?

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

If full: Redstone signal on top

else if Empty: Redstone signal on bottom

else return false;

 

Now this is the first clear thing you have said about what you are trying to do :)

 

So you have a variable that you change and when it is at max value it will power blocks above it while its less it powerss those to the side?

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

public boolean isStrongPoweringTo(World par1, int par2, int par3, int par4, int par5)
{
        return isPoweringTo(par1, par2, par3, par4, par5);
}

public boolean isWeakPoweringTo(World par1, int par2, int par3, int par4, int par5)
{
      return isPoweringTo(par1, par2, par3, par4, par5);
}


public boolean isPoweringTo(World par1, int x, int y, int z, int side)
{
      TileEntityAdvTinyChest tile = (TileEntityAdvTinyChest)par1.getBlockTileEntity(x, y, z);
      if(tile.isFull())return par5 == 0;
      else if(tile.isEmpty())return par5 == 1;
      else return false;
}

public boolean canProvidePower()
{
     return true;
}

 

This is the code with that i make the signal.

 

So how can i solve my problem?

 

Link to comment
Share on other sites

Your code can't possibly run, it will not compile if it's like this:

 

public boolean isPoweringTo(World par1, int x, int y, int z, int side)
{
      TileEntityAdvTinyChest tile = (TileEntityAdvTinyChest)par1.getBlockTileEntity(x, y, z);
      if(tile.isFull())return par5 == 0;
      else if(tile.isEmpty())return par5 == 1;
      else return false;
}

It's impossible that this code let's your game run.

So are you sure this is the code producing the above result?

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Yeah the compiler says all is ok and on top is the result

 

here my full advtinychest code (its not on the latest update but i didn't change anything on the redstone part)

 

package speiger.src.tinychest.common.blocks;

import java.util.List;
import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import speiger.src.api.common.addonslib.tinychest.TinyChestIDs;
import speiger.src.tinychest.TinyChest;
import speiger.src.tinychest.common.core.TinyChestCore;
import speiger.src.tinychest.common.tileentity.TileEntityAdvancedTinyChest;
import speiger.src.tinychest.common.tileentity.TileEntityBasicTinyChest;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestAcht;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestDrei;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestEins;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestFunf;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestNeun;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestSechs;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestSieben;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestVier;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestZwei;
import speiger.src.tinychest.common.tileentity.advanced.SpecailTinyChest;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockAdvTinyChest extends BlockContainer
{

private static TinyChestIDs tiny;

public BlockAdvTinyChest(int id) 
{
	super(id, Material.iron);
	this.setCreativeTab(TinyChest.tinyChest);
}


@SideOnly(Side.CLIENT)
@Override
public int getBlockTexture(IBlockAccess var1, int var2, int var3, int var4, int side)
{
	int meta = var1.getBlockMetadata(var2, var3, var4);
	TileEntityAdvancedTinyChest tile = (TileEntityAdvancedTinyChest)var1.getBlockTileEntity(var2, var3, var4);

	if(side == tile.getFacing())
	{
		if(meta == 0) return 11;
		else if(meta == 1) return 12;
		else if(meta == 2) return 13;
		else if(meta == 3) return 14;
		else if(meta == 4) return 15;
		else if(meta == 5) return 16;
		else if(meta == 6) return 17;
		else if(meta == 7) return 18;
		else if(meta ==  return 19;
		else if(meta == 9) return 22;
		else return 0;
	}
	else if(side == 0 || side == 1)
	{
		return 21;
	}
	else
	{
		return 20;
	}		
}


@Override
    public void onBlockPlacedBy(World var1, int var2, int var3, int var4, EntityLiving var5)
    {
    	
        if (!var1.isRemote)
        {
            TileEntityAdvancedTinyChest var6 = (TileEntityAdvancedTinyChest)var1.getBlockTileEntity(var2, var3, var4);

            if (var5 == null)
            {
            	var6.setFacing(2);
            }
            else
            {
                int var7 = MathHelper.floor_double((double)(var5.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
                switch (var7)
                {
                    case 0:
                    	var6.setFacing(2);
                        break;

                    case 1:
                    	var6.setFacing(5);
                    	break;

                    case 2:
                    	var6.setFacing(3);
                    	break;

                    case 3:
                    	var6.setFacing(4);
                }
            }               
        }
    
    }


public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3)
{
        par3.add(new ItemStack(par1, 1, 0));
        par3.add(new ItemStack(par1, 1, 1));
        par3.add(new ItemStack(par1, 1, 2));
        par3.add(new ItemStack(par1, 1, 3));
        par3.add(new ItemStack(par1, 1, 4));
        par3.add(new ItemStack(par1, 1, 5));
        par3.add(new ItemStack(par1, 1, 6));
        par3.add(new ItemStack(par1, 1, 7));
        par3.add(new ItemStack(par1, 1, );
        par3.add(new ItemStack(par1, 1, 9));
}

    public boolean canProvidePower()
    {
        return true;
    }
    
    public boolean isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
    	return this.isProvidingWeakPower(par1IBlockAccess, par2, par3, par4, par5);
    }
    
    public boolean isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
    	return isPoweringTo(par1IBlockAccess, par2, par3, par4, par5);
    }
    

    
    public boolean isPoweringTo(IBlockAccess par1, int par2, int par3, int par4, int par5)
    {
    	TileEntityAdvancedTinyChest tile = (TileEntityAdvancedTinyChest)par1.getBlockTileEntity(par2, par3, par4);
    	
    	if(tile.isFull()) return par5 == 1;
    	if(tile.isEmpty()) return par5 == 0;
    	else return false;

}
    

    
    public boolean onBlockActivated(World par1, int par2, int par3, int par4, EntityPlayer par5, int par6, float par7, float par8, float par9)
    {
    	if(par5.isSneaking()) return false;
    	
    	if(!par1.isRemote)
    	{
    		int meta = par1.getBlockMetadata(par2, par3, par4);
    		int id = 0;
    		if(meta == 0)id = tiny.advtinychestguieins;
    		else if(meta == 1)id = tiny.advtinychestguizwei;
    		else if(meta == 2)id = tiny.advtinychestguidrei;
   			else if(meta == 3)id = tiny.advtinychestguivier;
   			else if(meta == 4)id = tiny.advtinychestguifunf;
   			else if(meta == 5)id = tiny.advtinychestguisechs;
   			else if(meta == 6)id = tiny.advtinychestguisieben;
    		else if(meta == 7)id = tiny.advtinychestguiacht;
    		else if(meta == 8)id = tiny.advtinychestguineun;
    		else if(meta == 9)id = tiny.speacialtinychestid;
    		
    		TileEntityAdvancedTinyChest tile = (TileEntityAdvancedTinyChest)par1.getBlockTileEntity(par2, par3, par4);
    		if(tile != null)
    		{
    			par5.openGui(TinyChest.instance, id, par1, par2, par3, par4);
    			return true;
    		}
    								
    	}
    	return true;
    	
    }
    


@Override
public TileEntity createNewTileEntity(World var1) 
{
	return null;
}

public TileEntity createNewTileEntity(World var1, int meta)
{
	if(meta == 0)
	{
		return new AdvancedTinyChestEins();
	}
	else if(meta == 1)
	{
		return new AdvancedTinyChestZwei();
	}
	else if(meta == 2)
	{
		return new AdvancedTinyChestDrei();
	}
	else if(meta == 3)
	{
		return new AdvancedTinyChestVier();
	}
	else if(meta == 4)
	{
		return new AdvancedTinyChestFunf();
	}
	else if(meta == 5)
	{
		return new AdvancedTinyChestSechs();
	}
	else if(meta == 6)
	{
		return new AdvancedTinyChestSieben();
	}
	else if(meta == 7)
	{
		return new AdvancedTinyChestAcht();
	}
	else if(meta == 
	{
		return new AdvancedTinyChestNeun();
	}
	else if(meta == 9)
	{
		return new SpecailTinyChest();
	}

	return null;
}


public void updateTick(World world, int i, int j, int k, Random random)
    {
	notifyNeighbors(world, i, j, k);
	world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
    }

public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
    {
	notifyNeighbors(world, i, j, k);
    }

public void notifyNeighbors(World world, int i, int j, int k)
{
	world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
        world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
        world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
        world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
        world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
        world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
}


public void onBlockAdded(World world, int i, int j, int k)
    {
        if(world.getBlockMetadata(i, j, k) == 0)
        {
            super.onBlockAdded(world, i, j, k);
        }
        
        world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
    }

public int tickRate()
{
	return 1;
}


}

Link to comment
Share on other sites

public boolean isPoweringTo(World par1, int x, int y, int z, int side)
{
      TileEntityAdvTinyChest tile = (TileEntityAdvTinyChest)par1.getBlockTileEntity(x, y, z);
      if(tile.isFull())return par5 == 0;
      else if(tile.isEmpty())return par5 == 1;
      else return false;
}

 

wtf is par5 here?

it's not initialized anywhere?

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

sry then i made a minderror here

 

par5 == side

 

sorry but you have the code

 

package speiger.src.tinychest.common.blocks;

import java.util.List;
import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import speiger.src.api.common.addonslib.tinychest.TinyChestIDs;
import speiger.src.tinychest.TinyChest;
import speiger.src.tinychest.common.core.TinyChestCore;
import speiger.src.tinychest.common.tileentity.TileEntityAdvancedTinyChest;
import speiger.src.tinychest.common.tileentity.TileEntityBasicTinyChest;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestAcht;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestDrei;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestEins;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestFunf;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestNeun;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestSechs;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestSieben;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestVier;
import speiger.src.tinychest.common.tileentity.advanced.AdvancedTinyChestZwei;
import speiger.src.tinychest.common.tileentity.advanced.SpecailTinyChest;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockAdvTinyChest extends BlockContainer
{

private static TinyChestIDs tiny;

public BlockAdvTinyChest(int id) 
{
	super(id, Material.iron);
	this.setCreativeTab(TinyChest.tinyChest);
}


@SideOnly(Side.CLIENT)
@Override
public int getBlockTexture(IBlockAccess var1, int var2, int var3, int var4, int side)
{
	int meta = var1.getBlockMetadata(var2, var3, var4);
	TileEntityAdvancedTinyChest tile = (TileEntityAdvancedTinyChest)var1.getBlockTileEntity(var2, var3, var4);

	if(side == tile.getFacing())
	{
		if(meta == 0) return 11;
		else if(meta == 1) return 12;
		else if(meta == 2) return 13;
		else if(meta == 3) return 14;
		else if(meta == 4) return 15;
		else if(meta == 5) return 16;
		else if(meta == 6) return 17;
		else if(meta == 7) return 18;
		else if(meta ==  return 19;
		else if(meta == 9) return 22;
		else return 0;
	}
	else if(side == 0 || side == 1)
	{
		return 21;
	}
	else
	{
		return 20;
	}		
}


@Override
    public void onBlockPlacedBy(World var1, int var2, int var3, int var4, EntityLiving var5)
    {
    	
        if (!var1.isRemote)
        {
            TileEntityAdvancedTinyChest var6 = (TileEntityAdvancedTinyChest)var1.getBlockTileEntity(var2, var3, var4);

            if (var5 == null)
            {
            	var6.setFacing(2);
            }
            else
            {
                int var7 = MathHelper.floor_double((double)(var5.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
                switch (var7)
                {
                    case 0:
                    	var6.setFacing(2);
                        break;

                    case 1:
                    	var6.setFacing(5);
                    	break;

                    case 2:
                    	var6.setFacing(3);
                    	break;

                    case 3:
                    	var6.setFacing(4);
                }
            }               
        }
    
    }


public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3)
{
        par3.add(new ItemStack(par1, 1, 0));
        par3.add(new ItemStack(par1, 1, 1));
        par3.add(new ItemStack(par1, 1, 2));
        par3.add(new ItemStack(par1, 1, 3));
        par3.add(new ItemStack(par1, 1, 4));
        par3.add(new ItemStack(par1, 1, 5));
        par3.add(new ItemStack(par1, 1, 6));
        par3.add(new ItemStack(par1, 1, 7));
        par3.add(new ItemStack(par1, 1, );
        par3.add(new ItemStack(par1, 1, 9));
}

    public boolean canProvidePower()
    {
        return true;
    }
    
    public boolean isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
    	return this.isProvidingWeakPower(par1IBlockAccess, par2, par3, par4, par5);
    }
    
    public boolean isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
    	return isPoweringTo(par1IBlockAccess, par2, par3, par4, par5);
    }
    

    
    public boolean isPoweringTo(IBlockAccess par1, int par2, int par3, int par4, int par5)
    {
    	TileEntityAdvancedTinyChest tile = (TileEntityAdvancedTinyChest)par1.getBlockTileEntity(par2, par3, par4);
    	
    	if(tile.isFull()) return par5 == 1;
    	if(tile.isEmpty()) return par5 == 0;
    	else return false;

}
    

    
    public boolean onBlockActivated(World par1, int par2, int par3, int par4, EntityPlayer par5, int par6, float par7, float par8, float par9)
    {
    	if(par5.isSneaking()) return false;
    	
    	if(!par1.isRemote)
    	{
    		int meta = par1.getBlockMetadata(par2, par3, par4);
    		int id = 0;
    		if(meta == 0)id = tiny.advtinychestguieins;
    		else if(meta == 1)id = tiny.advtinychestguizwei;
    		else if(meta == 2)id = tiny.advtinychestguidrei;
   			else if(meta == 3)id = tiny.advtinychestguivier;
   			else if(meta == 4)id = tiny.advtinychestguifunf;
   			else if(meta == 5)id = tiny.advtinychestguisechs;
   			else if(meta == 6)id = tiny.advtinychestguisieben;
    		else if(meta == 7)id = tiny.advtinychestguiacht;
    		else if(meta == 8)id = tiny.advtinychestguineun;
    		else if(meta == 9)id = tiny.speacialtinychestid;
    		
    		TileEntityAdvancedTinyChest tile = (TileEntityAdvancedTinyChest)par1.getBlockTileEntity(par2, par3, par4);
    		if(tile != null)
    		{
    			par5.openGui(TinyChest.instance, id, par1, par2, par3, par4);
    			return true;
    		}
    								
    	}
    	return true;
    	
    }
    


@Override
public TileEntity createNewTileEntity(World var1) 
{
	return null;
}

public TileEntity createNewTileEntity(World var1, int meta)
{
	if(meta == 0)
	{
		return new AdvancedTinyChestEins();
	}
	else if(meta == 1)
	{
		return new AdvancedTinyChestZwei();
	}
	else if(meta == 2)
	{
		return new AdvancedTinyChestDrei();
	}
	else if(meta == 3)
	{
		return new AdvancedTinyChestVier();
	}
	else if(meta == 4)
	{
		return new AdvancedTinyChestFunf();
	}
	else if(meta == 5)
	{
		return new AdvancedTinyChestSechs();
	}
	else if(meta == 6)
	{
		return new AdvancedTinyChestSieben();
	}
	else if(meta == 7)
	{
		return new AdvancedTinyChestAcht();
	}
	else if(meta == 
	{
		return new AdvancedTinyChestNeun();
	}
	else if(meta == 9)
	{
		return new SpecailTinyChest();
	}

	return null;
}


public void updateTick(World world, int i, int j, int k, Random random)
    {
	notifyNeighbors(world, i, j, k);
	world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
    }

public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
    {
	notifyNeighbors(world, i, j, k);
    }

public void notifyNeighbors(World world, int i, int j, int k)
{
	world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
        world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
        world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
        world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
        world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
        world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
}


public void onBlockAdded(World world, int i, int j, int k)
    {
        if(world.getBlockMetadata(i, j, k) == 0)
        {
            super.onBlockAdded(world, i, j, k);
        }
        
        world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
    }

public int tickRate()
{
	return 1;
}


}

 

There is my full tiny chest code^^ Sry about the minderror^^

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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