Jump to content

Recommended Posts

Posted

Hello,

 

I've got a problem, i'm trying to make a block that when you activate redstone it pushes out gold blocks in front of it, so you can walk over it and on the other side, you can deactivate the redstone and the block pulls the gold blocks back. (named bridgeblock)

 

xA1xA2x --A=lever

xR1xR2x --R=redstone

xS1xS2x --S=bridgeblock

 

But when I've got 2 bridgeblocks and place redstone and a lever behind them and I pull A1, S2 starts, and when i first pull A2, S1 starts.

 

And I've got another problem, the code, that I use to pull the blocks back pulls the blocks back from the bridgeblocks to the last block, but when I try to invert that, it doesn't work.

 

I'm storing all the information about the bridgeblocks in a ArrayList with a "/" behind each information and in the TickHandler i use String.split("/") to get them back.

 

Here is the bridgeblock code:

 

http://gw.minecraftforge.net/2XYM

 

And here the TickHandler:

 

http://gw.minecraftforge.net/oc7t

 

It's like Wireless Redstone, but that was not intended :P

 

I hope some Pro's can help me :D

 

ss7

You sir are a god damn hero.

Posted

Thank you for your fast reply!

 

There is no difference between a powered and a unpowered block in my code. I't just finds the entry in the arraylist, deletes it and creates

a new entry with the same x, y, z, side, blockspushed but a new redstone strength. And yeah, i planned to use a TileEntity, beacause I'm gonna make a GUI for it, but i still don't understand the benefit, when you use a TileEntity. I know that you can get and set data, but you can also do that with a normal block.

 

Have you got a little example with a TileEntity, because I have no clue how it works.

 

ss7

You sir are a god damn hero.

Posted

TileEntity can save without limits all types of values within the world save. With blocks, as soon as the world unload, they are reset to default, and you can only have 16 bits of additional values. (your Array of String will never be saved by a block, consider it is only temporary)

You can have gui and inventories with TileEntity, though it is not necessary.

 

Have a look at this repository, this mod does things close to what you want.

Posted

Hello,

 

I looked at the code of your mod, but i don't understand it. I knowed that with 16 types, but with a normal block you can also write and read NBT-Data, so why should i use a TileEntity? And that with the crazy redstone signal is still not solved. I mean, it works quite well yet, so why do i have to rewrite all and use a TileEntity?

 

ss7

You sir are a god damn hero.

Posted

with a normal block you can also write and read NBT-Data

Huh ?  ??? No, you can't, except if the block has a tileentity (or some ItemStack, which I don't know how you'd get it)

 

And that with the crazy redstone signal is still not solved. I mean, it works quite well yet, so why do i have to rewrite all and use a TileEntity?

Well, you have to differentiate powered and unpowered state.

Just try to place a glass block next to that powered block of yours, or place your block on a powered area, then unpower it. You'll see why this is necessary.

This might fix both of your issues.

If not, use a TileEntity (you don't have to rewrite all, just move most things from block and TickHandler into the TileEntity)

By the way, you won't need your TickHandler with a TileEntity.

Posted

Hello,

 

So what should i do? GotoLink says i need a unpowered and a powered block and a TE, and Chibill say i don't.

 

And why would this code not work:

 

[embed=425,349]NBTTagList taglist = par1nbtTagCompound.getTagList("Inventory");

 

for (int i = 0; i < taglist.tagCount(); i++)

{

NBTTagCompound tag = (NBTTagCompound)taglist.tagAt(i);

 

    byte slot = tag.getByte("Slot");

 

    if (slot >= 0 && slot < inventory.length)

    {

    inventory[slot] = ItemStack.loadItemStackFromNBT(tag);

    }

}[/embed]

 

For now, i'm trying with a TileEntity and no unpowered and powered block.

 

And sorry for my bad english, i'm from Germany.

 

EDIT: Now i have my TileEntity, but i don't know what things i should move into that, because i don't want to store the bridges array in a

TileEntity of one of the bridges. It must be on a block that is not a bridge. And i don't know how to implements a update() method in my TileEntity. I've tried it with updateEntity() but that doesn't worked. I have no idea what i have to do next.

 

ss7

You sir are a god damn hero.

Posted

Hello,

 

I moved all my code to the TileEntity and it's the same problem :(. When i have 2 bridges and place a lever at the first and pull it the second extends. Two blocks each second are pushed, but i don't know why. Here is my code:

 

In the main Mod class is just a ArrayList with all the locations of the bridges for the TickHandler.

 

Sorry for the name of one of the pastes, it's not BridgeTileEntity, it's the BridgeBlock:

 

http://gw.minecraftforge.net/kfos

 

http://gw.minecraftforge.net/EHBQ

 

http://gw.minecraftforge.net/gttp

 

ss7

You sir are a god damn hero.

Posted

Your TickHandler uses World ticks, that is both client and server ones.

Use the world instance instead of the ModLoader.etc shit.

(with World ticks, the world instance is tickData[0])

 

AFAIK, you don't need your tickhandler.

Simply override

public void updateEntity() {}

with your tick() method.

Posted

Hello,

 

Thank you for your answer, GotoLink, i've now moved the Tick() code to updateEntity() and now the timing works, but that with the redstone is still the case.

 

ss7

You sir are a god damn hero.

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.