Skip to content

Commit

Permalink
Add UtilsWrapper.parseBlockState as wrapper for the same method in Ut…
Browse files Browse the repository at this point in the history
…ilsJS
  • Loading branch information
MaxNeedsSnacks committed Jan 26, 2024
1 parent 546bcdb commit cb41cea
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
Expand Down Expand Up @@ -245,4 +247,12 @@ static ParticleOptions particleOptions(Object o) {

return ERROR_PARTICLE;
}

@Info("Parses a block state from the input string. May throw for invalid inputs!")
static BlockState parseBlockState(Object o) {
if (o instanceof BlockState bs) {
return bs;
}
return o == null ? Blocks.AIR.defaultBlockState() : UtilsJS.parseBlockState(o.toString());
}
}

0 comments on commit cb41cea

Please sign in to comment.