Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Pages | Avoiding Properties Limit & Custom Slab #680

Merged
merged 22 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docs/blocks/avoiding-properties-limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Avoiding Properties Limit
category: Tutorials
tags:
- guide
- advanced
mentions:
- Kaioga5
---

## Introduction:
As you may know, block properties have a total limit of 64 values (16 maximum per property) that you cannot exceed. This is very frustrating when creating new blocks, so I will explain you how you can avoid reaching this limit. Please note that you are not going to have more than 64 properties, however the results you'll get using this method will be equal to that!
SmokeyStack marked this conversation as resolved.
Show resolved Hide resolved

## How it works:
This method simply combines two or more properties in order to re-use them and read them either in permutations or conditions. For example, let's say you want to have a block with the English Alphabet letters. You'll need 26 property values for that, right? Well, with combinations you need way less! For the sake of simplicity, let's just use 15 property values.
SmokeyStack marked this conversation as resolved.
Show resolved Hide resolved

## The logic:
What your code will do going of by the example above is the following;
```
1 & 1 = A 1 & 5 = E 1 & 9 = I 1 & 13 = M
1 & 2 = B 1 & 6 = F 1 & 10 = J
1 & 3 = C 1 & 7 = G 1 & 11 = K
1 & 4 = D 1 & 8 = H 1 & 12 = L
```
And then;
```
2 & 1 = N 2 & 5 = R 2 & 9 = V 2 & 13 = Z
2 & 2 = O 2 & 6 = S 2 & 10 = W
2 & 3 = P 2 & 7 = T 2 & 11 = X
2 & 4 = Q 2 & 8 = U 2 & 12 = Y
```

You see how you get the same results as using 26 property values with just 15? And it can even be less if you combine more than two digits! With just 16 property values in one of your properties and using 5 values in a second property for combinations, you can read up to 4368 property values... crazy right?
SmokeyStack marked this conversation as resolved.
Show resolved Hide resolved

## How will it look like:
Using the example above as reference, your properties would look like this;
```
"properties": {
"wiki:value": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ],
"wiki:division": [ 1, 2 ]
}
SmokeyStack marked this conversation as resolved.
Show resolved Hide resolved
```
And your conditions like this;
SmokeyStack marked this conversation as resolved.
Show resolved Hide resolved
```
"condition": "query.block_property('wiki:division') == 1 && query.block_property('wiki:value') == 1"

"condition": "query.block_property('wiki:division') == 1 && query.block_property('wiki:value') == 2"
```
## What have you learned;
You have learned how to use less than 64 properties and do more, combining properties to have better possibilities.

:::tip
You can use more than 2 values in order to have more possible combinations.

SmokeyStack marked this conversation as resolved.
Show resolved Hide resolved
:::
6 changes: 6 additions & 0 deletions docs/blocks/blocks-16.md
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,12 @@ bedrock_wiki:

.. Will, in-game, yield the result: `tile.Barrel of Foxes.name`. Using language files is strongly recommended.

- You can define a specific block property in the `/fill` and `/setblock` commands where the data value would be, just as shown in the following example;
Kaioga5 marked this conversation as resolved.
Show resolved Hide resolved

`/fill ~ ~ ~ ~ ~ ~ wiki:my_block ["wiki:my_property": 1]`

`/setblock ~ ~ ~ wiki:my_block ["wiki:my_property": 1]`

- A maximum of `16` values per block property may be used.
- The following components may not exceed the default (16x) block size limitations:
- `minecraft:entity_collision`
Expand Down
80 changes: 80 additions & 0 deletions entity_variants
Kaioga5 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Entity Variants
tags:
- recipe
---

<BButton color="blue" link="render-controllers-intro">Learn more about Render Controllers</BButton>

Entity variants should be defined as an entity with a different looking than usually, and according to what you want to acomplish you could also change its stats.

On this page you will learn how to add your own variants to your entities, changing their model and texture, and how to change them in-game by using commands.

## minecraft:variant

According to Microsoft documentation, `minecraft:variant` is used to differentiate the component group of a variant of an entity from others, such as ocelot, villager and horse. We want to use this component at our `entity.json` located at `BP/entities` to differentiate the default variant, which is the entity with no modifications, between our new variant.

So let's get started by adding this component in our `entity.json` components, just like this:

```
"minecraft:variant":{
"value": 0
}
```

After having this done, we want to add a component group in order to change its variant, and it will be done just like this:

```
"component_groups": {
"wiki:variant_change": {
"minecraft:variant": {
"value": 1
}
}
}
}
```

We have the main part done, now in order to changing the variant in-game we need to make an event call the component group, this is done this way:

```
"events": {
"wiki:my_event": {
"add": {
"component_groups":[
"wiki:variant_change"
]
}
}
```

Now we are completly done with the entity's behavior, so we will move to the `entity.client.json` file at `RP/entity/`.

## entity.client.json

In the previosly mentioned file, we need to mention all the textures we want to have, in this example im modifying the vanilla `player.entity.json` file to make it able to use the zombie texture:

```
"textures": {
"default": "textures/entity/steve",
"cape": "textures/entity/cape_invisible",
"variant_one": "textures/entity/zombie/zombie"
}
```

Remember that in this example, `default`, `cape`, and `variant_one` are our own namespaces, so we can change them to whatever we wish. Next to the namespace is our textures directories.


Let's now mention all the geometries we want to list for our entity:

```
"geometry": {
"default": "geometry.humanoid.custom",
"cape": "geometry.cape",
"variant_one": "geometry.zombie"
}
```

We are now done with the `entity.client.json` file!

## Render Controller