Bonjour à tous! J'ai remarqué que beaucoup de personnes voulaient créer des blocs customisés à partir de variables qui stockent les coordonnées du block. Simple, mais pas très optimisé (Imagine on te met plus de 1000 blocks customs, pas très opti :confused:)
Du coup, en faisant des recherches, j'ai vu une très belle expression :
Les metadatas values :o.
(Utilisation de l'expression : "metadata [value] %text% of %player/entitie/block/world%" )
Donc, voici le code (après j'explique ligne par ligne)
on place of diamond block:
if the player's tool is a diamond block named "&cFakeDiamondBlock":
set the metadata value "Type" of the event-block to "FakeDiamondBlock"
on break of diamond block:
if the metadata value "Type" of the event-block is "FakeDiamondBlock":
cancel event
drop 1 dirt at the event-block
set the event-block to air
on place of diamond block:
if the player's tool is a diamond block named "&cFakeDiamondBlock":
C'est évident :p
Là, on rentre dans les metadatas :
set the metadata value "Type" of the event-block to "FakeDiamondBlock"
Là, c'est plus "compliqué":
Chaque block/entité/joueur/monde a une metadata value "Type". On va donc modifier cette metadata value pour reconnaitre le block/entité/joueur/monde parmit d'autres ^^. Donc la metadata value "Type" du block de faux bloc de diamant qu'on a mit est "FakeDiamondBlock"
Ensuite:
on break of diamond block:
Encore évident.
Et puis, le truc intéressant :
if the metadata value "Type" of the event-block is "FakeDiamondBlock":
On vérifie la metadata value "Type" du bloc cassé. Si cette metadata value set "FakeDiamondBlock", alors on passe à l'effet qu'on a mit (Dans mon code, c'est qu'on drop de la terre lol.). Les metadatas values servent donc à différencier un monde/block/entité/joueur des autres.
Petit exercice :
Essayez de faire un skript pour qu'un zombie spécial drop automatiquement 1 de diamant. (Vous pouvez clear les drops ou non.)
[spoiler=Indice]
METADATA VALUE
[spoiler=Indice 2]
Il faudrait d'abord pouvoir faire spawn le zombie. spawn a zombie par exemple c:. Ou on peut faire autrement. Il faut juste donner une metadata à un zombie lol.
[spoiler=Soluce]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=T'es sur?"]
[spoiler=Ok tiens :]
Sans faire spawn de zombie :
on rightclick:
if the player is holding a stick named "&cBaton de super zombie :D":
if the targeted entity is a zombie:
set the metadata value "Type" of the event-entity to "Super Zonny"
on death of a zombie:
if the metadata value "Type" of the victim is "Super Zonny":
drop a diamond at the victim
En faisant spawn un zombie:
command /spawnsuperzombie:
trigger:
spawn a zombie at the player's location
set the metadata value "Type" of the targeted entity to "Super Zonny"*
on death of a zombie:
if the metadata value "Type" of the victim is "Super Zonny":
drop a diamond at the victim