ScriptVars.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package me.km.snuviscript;
  2. import me.hammerle.snuviscript.code.Script;
  3. import me.km.utils.Location;
  4. import net.minecraft.block.BlockState;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.player.PlayerEntity;
  7. import net.minecraft.util.math.BlockPos;
  8. import net.minecraft.world.IWorld;
  9. public class ScriptVars {
  10. @SuppressWarnings("")
  11. public static void setBlockVars(Script sc, IWorld w, BlockPos pos, BlockState state) {
  12. sc.setVar("block_loc", new Location(w, pos));
  13. sc.setVar("block_type", state.getBlock().getRegistryName().toString());
  14. sc.setVar("block", state.getBlock());
  15. }
  16. @SuppressWarnings("")
  17. public static void setBlockVars(Script sc, IWorld w, BlockPos pos) {
  18. BlockState state = w.getBlockState(pos);
  19. sc.setVar("block_loc", new Location(w, pos));
  20. sc.setVar("block_type", state.getBlock().getRegistryName().toString());
  21. sc.setVar("block", state.getBlock());
  22. }
  23. public static void setPlayerVars(Script sc, PlayerEntity p) {
  24. sc.setVar("player", p);
  25. sc.setVar("player_name", p == null ? null : p.getName().getFormattedText());
  26. }
  27. public static void setSecPlayer(Script sc, PlayerEntity p) {
  28. if(p != null) {
  29. sc.setVar("sec_player", p);
  30. sc.setVar("sec_player_name", p.getName().getFormattedText());
  31. }
  32. }
  33. public static void setEntityVars(Script sc, Entity ent) {
  34. sc.setVar("entity", ent);
  35. }
  36. }