command /createblock <text>:
permission: op
trigger:
if {cblockname::*} contains arg-1:
message colored "&6&lBlock already created! Block given instead." to player
give player glowing player's held item named colored "%arg-1% - [CUSTOM BLOCK]"
stop
else:
add arg-1 to {cblockname::*}
give player glowing player's held item named colored "%arg-1% - [CUSTOM BLOCK]"
message colored "&a&lDone!" to player
on block place:
if name of event-player's held item contains "- [CUSTOM BLOCK]":
set {_name} to name of event-player's held item
loop {cblockname::*}:
if {_name} contains loop-value:
set {_2name} to loop-value
set {_random} to a random integer between 1 and 10000000000
if {cblockname::*} contains {_2name}:
set {cblockname::%{_2name}%::%{_random}%} to position of event-block
#if {cblockname::%{_2name}%::%{_random}%} is position of event-block:
#message colored "&6Debug: Block placed at %{cblockname::%{_2name}%::%{_random}%}%." to player
command /removeblock <text>:
permission: op
usage: /removeblock <name>
trigger:
remove arg-1 from {cblockname::*}
message colored "&a&lDone!&r&a Cleared %arg-1%." to player
command /blocklist:
permission: op
trigger:
message colored "&a&l----------------------------" to player
loop {cblockname::*}:
message colored "- %loop-value%"
message colored "&a&l----------------------------" to player
command /loottable <text> <text> <number> [<number>]:
permission: op
usage: /loottable <add/remove> <name> <id> (held item NOT IN COMMAND) (amount NOT IN COMMAND) [chance]
trigger:
if arg-1 is "add":
if arg-4 is set:
set {cblockname::%arg-2%::loottable::%arg-3%::chances} to arg-4
set {cblockname::%arg-2%::loottable::%arg-3%} to player's held item
message colored "&a&lDone!&r&a Added %player's held item%&a to the loot table!." to player
stop
else:
set {cblockname::%arg-2%::loottable::%arg-3%} to player's held item
message colored "&a&lDone!&r&a Added %player's held item%&a to the loot table!." to player
if arg-1 is "remove":
message colored "&a&lDone!&r&a Removed %{cblockname::%arg-2%::loottable::%arg-3%}%&a to the loot table!." to player
remove arg-3 from {cblockname::%arg-2%::loottable::*}
on break:
loop {cblockname::*}:
loop {cblockname::%loop-value%::*}:
if {cblockname::%loop-value-1%::%loop-value-2%} is position of event-block:
message "tits" to player
loop {cblockname::%loop-value-1%::loottable::*}:
clear drops
if {cblockname::%loop-value-1%::loottable::%loop-value-3%::chances} is set:
set {cblockname::%loop-value-1%::loottable::%loop-value-3%::chances} to {_chances}
if {_chances} is smaller than 101:
chance of {_chances}:
drop {cblockname::%loop-value-1%::loottable::%loop-value-3%}
stop
else:
drop {cblockname::%loop-value-1%::loottable::%loop-value-3%}
stop
stop
else:
drop {cblockname::%loop-value-1%::loottable::%loop-value-3%}
stop
I got no idea on how do i optimize my code and why the break block part isnt working. If you need explanations about my code ask me
Someone gave advices on how i should upgrade my code
"1. You're overusing contains, which can cause a lot of lag. Use indices where possible.
Eg: set {cblockname::%arg-1%} to true instead of add arg-1 to {cblockname::*} (you should also use set instead of add where possible)
2. Locations work great as unique identifiers, no need for random numbers.
Eg: set {cblockname::%{_2name}%::%location of event-block%} to location of event-block
3. chances are 0 to 1 without a % sign, and 0 - 100 with a percent sign.
4. loop indices if you're using indices, or use loop-index."
i got no ideas on how can i apply this on the code, and i got no idea if it will fix the issue in break block, any help will be appreciated
permission: op
trigger:
if {cblockname::*} contains arg-1:
message colored "&6&lBlock already created! Block given instead." to player
give player glowing player's held item named colored "%arg-1% - [CUSTOM BLOCK]"
stop
else:
add arg-1 to {cblockname::*}
give player glowing player's held item named colored "%arg-1% - [CUSTOM BLOCK]"
message colored "&a&lDone!" to player
on block place:
if name of event-player's held item contains "- [CUSTOM BLOCK]":
set {_name} to name of event-player's held item
loop {cblockname::*}:
if {_name} contains loop-value:
set {_2name} to loop-value
set {_random} to a random integer between 1 and 10000000000
if {cblockname::*} contains {_2name}:
set {cblockname::%{_2name}%::%{_random}%} to position of event-block
#if {cblockname::%{_2name}%::%{_random}%} is position of event-block:
#message colored "&6Debug: Block placed at %{cblockname::%{_2name}%::%{_random}%}%." to player
command /removeblock <text>:
permission: op
usage: /removeblock <name>
trigger:
remove arg-1 from {cblockname::*}
message colored "&a&lDone!&r&a Cleared %arg-1%." to player
command /blocklist:
permission: op
trigger:
message colored "&a&l----------------------------" to player
loop {cblockname::*}:
message colored "- %loop-value%"
message colored "&a&l----------------------------" to player
command /loottable <text> <text> <number> [<number>]:
permission: op
usage: /loottable <add/remove> <name> <id> (held item NOT IN COMMAND) (amount NOT IN COMMAND) [chance]
trigger:
if arg-1 is "add":
if arg-4 is set:
set {cblockname::%arg-2%::loottable::%arg-3%::chances} to arg-4
set {cblockname::%arg-2%::loottable::%arg-3%} to player's held item
message colored "&a&lDone!&r&a Added %player's held item%&a to the loot table!." to player
stop
else:
set {cblockname::%arg-2%::loottable::%arg-3%} to player's held item
message colored "&a&lDone!&r&a Added %player's held item%&a to the loot table!." to player
if arg-1 is "remove":
message colored "&a&lDone!&r&a Removed %{cblockname::%arg-2%::loottable::%arg-3%}%&a to the loot table!." to player
remove arg-3 from {cblockname::%arg-2%::loottable::*}
on break:
loop {cblockname::*}:
loop {cblockname::%loop-value%::*}:
if {cblockname::%loop-value-1%::%loop-value-2%} is position of event-block:
message "tits" to player
loop {cblockname::%loop-value-1%::loottable::*}:
clear drops
if {cblockname::%loop-value-1%::loottable::%loop-value-3%::chances} is set:
set {cblockname::%loop-value-1%::loottable::%loop-value-3%::chances} to {_chances}
if {_chances} is smaller than 101:
chance of {_chances}:
drop {cblockname::%loop-value-1%::loottable::%loop-value-3%}
stop
else:
drop {cblockname::%loop-value-1%::loottable::%loop-value-3%}
stop
stop
else:
drop {cblockname::%loop-value-1%::loottable::%loop-value-3%}
stop
I got no idea on how do i optimize my code and why the break block part isnt working. If you need explanations about my code ask me
Someone gave advices on how i should upgrade my code
"1. You're overusing contains, which can cause a lot of lag. Use indices where possible.
Eg: set {cblockname::%arg-1%} to true instead of add arg-1 to {cblockname::*} (you should also use set instead of add where possible)
2. Locations work great as unique identifiers, no need for random numbers.
Eg: set {cblockname::%{_2name}%::%location of event-block%} to location of event-block
3. chances are 0 to 1 without a % sign, and 0 - 100 with a percent sign.
4. loop indices if you're using indices, or use loop-index."
i got no ideas on how can i apply this on the code, and i got no idea if it will fix the issue in break block, any help will be appreciated