Setblock Decorated Pot has a random Pottery Sherd. [2023.4]

Started by Su Su on

Topic category: User side tutorials

Last seen on 14:01, 26. Apr 2024
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Setblock Decorated Pot has a random Pottery Sherd. [2023.4]
Sun, 03/24/2024 - 14:10 (edited)

Hello everyone! my first turtorial

I create local variables type : string

This is how I do it : https://ibb.co/XC4FzwF

and the code : 


{

String decorated_pot = "";
decorated_pot = "" + ForgeRegistries.ITEMS.tags().getTag(ItemTags.create(new ResourceLocation("minecraft:decorated_pot_sherds"))).getRandomElement(RandomSource.create()).orElseGet(() -> Items.AIR);
if (world instanceof ServerLevel _level)
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, y, z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
("setblock ~ ~ ~ minecraft:decorated_pot[cracked=false,facing=north,waterlogged=false]{sherds:[\"" + "" + decorated_pot + "\",\"" + decorated_pot + "\",\"" + decorated_pot + "\",\"" + decorated_pot + "\"]}"));
}
Edited by Su Su on Sun, 03/24/2024 - 14:10