Jump to content

[solved] Just looking for an idea to implement tent block.


tomtomtom09

Recommended Posts

Im currently rewriting/improving my camping mod.

 

Main goal is to use less blocks as possible.

 

It's not a lot more code to add different tent variation just don't like using lots of block ids :D

 

Problem I have is my old mod used 90 different blocks just for tents:

*i do have block states on all tents to check the direction placed so tents are placed in all directions.

Tent version with torches, makes tents easy to craft on first night.

-10 small tent with torches/bed.

-10 medium tent with torches/bed.

10 large tent with torches/bed.

Tent version with lanterns.

-10 small tent with lanterns/bed.

-10 medium tent with lanterns/bed.

10 large tent with lanterns/bed.

Empty tent with nothing inside.

-10 small tent.

-10 medium tent.

10 large tent

 

Im just wondering is it possible to add more block states to a block with different outcomes when right clicked or maybe a simpler alternative?

Developer of CampCraft

Link to comment
Share on other sites

You could store some of this data in a

TileEntity

, you can still access it in the blockstates file if you create properties for the various data types and override

Block#getActualState

to set them from the

TileEntity

.

 

I have some examples of this here:

  • Coloured Rotatable Block:
    Block

    ,
    TileEntity

    , blockstates file - Stores the colour in the metadata and the facing in the
    TileEntity


  • Coloured Multi Rotatable Block:
    Block

    ,
    TileEntity

    , blockstates file - Stores the colour in the metadata and the facing and face rotation in the
    TileEntity

 

In your case, you could probably have the following properties:

  • Facing - An
    EnumFacing

    , probably limited to horizontals.

  • Size - An enum with three values: Small, Medium, Large.
  • Lighting - An enum with three values: None, Lanterns, Torches.
  • Variant - An enum with ten values (whatever the ten variants are).
  • Has Bed - A boolean. Only include this if having a bed is independent of the lighting.

 

If the facing is limited to horizontals, you can store it in two bits of metadata; leaving two bits (four possible values) to store the size or lighting. You can store the rest in the

TileEntity

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Thank you for the helping :)

 

didn't think about storing block data inside a TileEntity.

 

Should look something like this once finished:

Facing - 4 values n/e/s/w: stored in TileEntity.

Size - 3 values : s/m/l. stored in block class

Equipment - 3 values : empty/torch/lantern. stored in block class

Fabric Type - 10 values. stored in block class

 

Should be fun playing around with properties :)

 

 

 

 

Developer of CampCraft

Link to comment
Share on other sites

Metadata is limited to 4 bits, 16 possible combinations of values.

 

To store multiple values in metadata, you need to use bitwise operations to put values in or get values out of each bit. Each bit can only be used for a single value.

 

10 possible values for Fabric Type will require all 4 bits of metadata to store (the highest value is 9, which is 1001 in binary), leaving no room for any other values.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

My bad though properties had increased the limit for some reason xD.

 

My mad ramblings  :P

 

Always been unsure with using meta data so I properly will be wrong in a minute :D, I've never used multiple values in metadata before.

 

so each bit can hold 4 combinations of a single value.

 

This is my thinking:

2 bits to store 8 fabric variation.

1 bit for the size.

1 bit for equipment.

Then store the block rotation in the tile entity.

Developer of CampCraft

Link to comment
Share on other sites

Honestly, store the rotation in metadata, then store the rest in the TE.

 

(2 bits for fabric, BTW, is 4 colors)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.