Jump to content

Adding a chest into a structure and placing random but defined loot in it


Ablaze

Recommended Posts

Hi!

    In my last thread I learnt how to PROPERLY generate a structure. But now, I want to learn how to place a chest in the structure and put random but defined loot in it, just like the blacksmith chest. I tried copying the code, but it didn't work. Can someone give a step by step noob guide?

 

Regards,

Ablaze.

 

P.S. I also want to learn what tile entities are and how to create them, can someone give me a good up to date link for learning about tile entities?

Add me on Skype: AblazeTheBest. Send a message saying "#HeyAblaze"

 

Currently: Making a mod!

Link to comment
Share on other sites

World#setBlock(x,y,z, Block.chest.blockID);
tileentity = World#getBlockTileEntity(x,y,z);
if(tileentity instanceof IInventory){
     IInventory(tileentity)#setInventorySlotContents(int, ItemStack);
}

 

Thanks, that helped.

 

I also want to learn what tile entities are and how to create them, can you give me a good up to date link for learning about tile entities?

 

Regards,

Ablaze

Add me on Skype: AblazeTheBest. Send a message saying "#HeyAblaze"

 

Currently: Making a mod!

Link to comment
Share on other sites

Related to inventories and GUIs I would say VSWE's interface tutorial deals some with them:

 

I'd start there, and after that I would have tried to make my own furnace looking at TileEntityFurnace for guidance (but NOT copy-pasting it, just reading, understanding how it works!) :)

 

 

Also remember that TileEntities are nothing magical.

They are just a way to store extra logic for a block.

TileEntities can get updates on every tick, minecraft will call it's Update(UpdateEntity?) method every tick and you can do your logic there.

Also TE's Can store any amount of data you want, they are not limited to the 16 bits metadata that the block has.

TE's can reference the blocks they are located along with, they know their location in the world (xyz) and all that.

 

Their data get's saved to NBT, you have to write your own save and load code into the respective methods in order to save your variables.

Here again understanding TileEntityFurnace is of great value! :)

 

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

Link to comment
Share on other sites

Related to inventories and GUIs I would say VSWE's interface tutorial deals some with them:

 

I'd start there, and after that I would have tried to make my own furnace looking at TileEntityFurnace for guidance (but NOT copy-pasting it, just reading, understanding how it works!) :)

 

 

Also remember that TileEntities are nothing magical.

They are just a way to store extra logic for a block.

TileEntities can get updates on every tick, minecraft will call it's Update(UpdateEntity?) method every tick and you can do your logic there.

Also TE's Can store any amount of data you want, they are not limited to the 16 bits metadata that the block has.

TE's can reference the blocks they are located along with, they know their location in the world (xyz) and all that.

 

Their data get's saved to NBT, you have to write your own save and load code into the respective methods in order to save your variables.

Here again understanding TileEntityFurnace is of great value! :)

 

Okay, thanks for the quick reply!

 

Now, I know what ticks are, basically 1/20th of a second. But what would ticks have to do in modding? Can you give me some examples?

 

Regards,

Ablaze.

 

P.S. Please answer this question - If I have any further doubts about tile entities and ticks can I consult you?

Add me on Skype: AblazeTheBest. Send a message saying "#HeyAblaze"

 

Currently: Making a mod!

Link to comment
Share on other sites

Tileentitys are called every tick, so you can update the tileentity 20 times per second. If you use this code:

int tickCount = 0;
public void updateEntity ()
{
      tickCount++;
}

every second tickCount gets incremented by 20. So when its at 10 seconds, tickCount is at 200. The furnace uses that method to check if there are items to be smelted, and to decrease the fuel level. So its actually very nice to use.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

P.S. Please answer this question - If I have any further doubts about tile entities and ticks can I consult you?

 

You may, by simply creating a thread here in this support section and I and/or others will help you out as best we can :)

By creating a thread about your question you achieve several things you wouldn't do by PMing me.

 

First of all, you get a faster response. I'm only at the boards so and so often and my afk life may take me away for even longer at times. By comparison there's many regular users of these boards which all are highly skilled (lol most of them way beyond my abilities!). So you are guaranteed a faster and possibility of a better answer by creating a thread instead of using PMs ;)

 

Secondly by creating a thread others can find it using the search function or get directed there by helpers.

This makes others learn from your questions as well, which I consider a great thing! :D

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

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.