Guest User

Untitled

a guest
Mar 23rd, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.97 KB | None | 0 0
  1. package net.jivalon.giantdiamond.procedures;
  2.  
  3. /* imports omitted */
  4.  
  5. public class GiantOakWoodBlockAddedProcedure {
  6.  
  7. public static void executeProcedure(Map<String, Object> dependencies) {
  8. if (dependencies.get("world") == null) {
  9. if (!dependencies.containsKey("world"))
  10. GiantDiamondMod.LOGGER.warn("Failed to load dependency world for procedure GiantOakWoodBlockAdded!");
  11. return;
  12. }
  13. if (dependencies.get("x") == null) {
  14. if (!dependencies.containsKey("x"))
  15. GiantDiamondMod.LOGGER.warn("Failed to load dependency x for procedure GiantOakWoodBlockAdded!");
  16. return;
  17. }
  18. if (dependencies.get("y") == null) {
  19. if (!dependencies.containsKey("y"))
  20. GiantDiamondMod.LOGGER.warn("Failed to load dependency y for procedure GiantOakWoodBlockAdded!");
  21. return;
  22. }
  23. if (dependencies.get("z") == null) {
  24. if (!dependencies.containsKey("z"))
  25. GiantDiamondMod.LOGGER.warn("Failed to load dependency z for procedure GiantOakWoodBlockAdded!");
  26. return;
  27. }
  28.  
  29. IWorld world = (IWorld) dependencies.get("world");
  30. double x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
  31. double y = dependencies.get("y") instanceof Integer ? (int) dependencies.get("y") : (double) dependencies.get("y");
  32. double z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
  33.  
  34. if ((new Object() {
  35. public Direction getDirection(BlockPos pos) {
  36. try {
  37. BlockState _bs = world.getBlockState(pos);
  38. DirectionProperty property = (DirectionProperty) _bs.getBlock().getStateContainer().getProperty("facing");
  39. if (property != null)
  40. return _bs.get(property);
  41. return Direction.getFacingFromAxisDirection(
  42. _bs.get((EnumProperty<Direction.Axis>) _bs.getBlock().getStateContainer().getProperty("axis")),
  43. Direction.AxisDirection.POSITIVE);
  44. } catch (Exception e) {
  45. return Direction.NORTH;
  46. }
  47. }
  48. }.getDirection(new BlockPos((int) x, (int) y, (int) z))) == Direction.NORTH) {
  49. if (world instanceof ServerWorld) {
  50. Template template = ((ServerWorld) world).getStructureTemplateManager()
  51. .getTemplateDefaulted(new ResourceLocation("giant_diamond", "bridge"));
  52.  
  53. if (template != null) {
  54. template.func_237144_a_(
  55. (ServerWorld) world, new BlockPos((int) (x - 1), (int) y, (int) z), new PlacementSettings()
  56. .setRotation(Rotation.COUNTERCLOCKWISE_90).setMirror(Mirror.NONE).setChunk(null).setIgnoreEntities(false),
  57. ((World) world).rand);
  58. }
  59. }
  60. }
  61. if ((new Object() {
  62. public Direction getDirection(BlockPos pos) {
  63. try {
  64. BlockState _bs = world.getBlockState(pos);
  65. DirectionProperty property = (DirectionProperty) _bs.getBlock().getStateContainer().getProperty("facing");
  66. if (property != null)
  67. return _bs.get(property);
  68. return Direction.getFacingFromAxisDirection(
  69. _bs.get((EnumProperty<Direction.Axis>) _bs.getBlock().getStateContainer().getProperty("axis")),
  70. Direction.AxisDirection.POSITIVE);
  71. } catch (Exception e) {
  72. return Direction.NORTH;
  73. }
  74. }
  75. }.getDirection(new BlockPos((int) x, (int) y, (int) z))) == Direction.SOUTH) {
  76. if (world instanceof ServerWorld) {
  77. Template template = ((ServerWorld) world).getStructureTemplateManager()
  78. .getTemplateDefaulted(new ResourceLocation("giant_diamond", "bridge"));
  79.  
  80. if (template != null) {
  81. template.func_237144_a_((ServerWorld) world, new BlockPos((int) (x + 1), (int) y, (int) z),
  82. new PlacementSettings().setRotation(Rotation.CLOCKWISE_90).setMirror(Mirror.NONE).setChunk(null).setIgnoreEntities(false),
  83. ((World) world).rand);
  84. }
  85. }
  86. }
  87. if ((new Object() {
  88. public Direction getDirection(BlockPos pos) {
  89. try {
  90. BlockState _bs = world.getBlockState(pos);
  91. DirectionProperty property = (DirectionProperty) _bs.getBlock().getStateContainer().getProperty("facing");
  92. if (property != null)
  93. return _bs.get(property);
  94. return Direction.getFacingFromAxisDirection(
  95. _bs.get((EnumProperty<Direction.Axis>) _bs.getBlock().getStateContainer().getProperty("axis")),
  96. Direction.AxisDirection.POSITIVE);
  97. } catch (Exception e) {
  98. return Direction.NORTH;
  99. }
  100. }
  101. }.getDirection(new BlockPos((int) x, (int) y, (int) z))) == Direction.WEST) {
  102. if (world instanceof ServerWorld) {
  103. Template template = ((ServerWorld) world).getStructureTemplateManager()
  104. .getTemplateDefaulted(new ResourceLocation("giant_diamond", "bridge"));
  105.  
  106. if (template != null) {
  107. template.func_237144_a_(
  108. (ServerWorld) world, new BlockPos((int) x, (int) y, (int) (z + 1)), new PlacementSettings()
  109. .setRotation(Rotation.CLOCKWISE_180).setMirror(Mirror.NONE).setChunk(null).setIgnoreEntities(false),
  110. ((World) world).rand);
  111. }
  112. }
  113. }
  114. if ((new Object() {
  115. public Direction getDirection(BlockPos pos) {
  116. try {
  117. BlockState _bs = world.getBlockState(pos);
  118. DirectionProperty property = (DirectionProperty) _bs.getBlock().getStateContainer().getProperty("facing");
  119. if (property != null)
  120. return _bs.get(property);
  121. return Direction.getFacingFromAxisDirection(
  122. _bs.get((EnumProperty<Direction.Axis>) _bs.getBlock().getStateContainer().getProperty("axis")),
  123. Direction.AxisDirection.POSITIVE);
  124. } catch (Exception e) {
  125. return Direction.NORTH;
  126. }
  127. }
  128. }.getDirection(new BlockPos((int) x, (int) y, (int) z))) == Direction.EAST) {
  129. if (world instanceof ServerWorld) {
  130. Template template = ((ServerWorld) world).getStructureTemplateManager()
  131. .getTemplateDefaulted(new ResourceLocation("giant_diamond", "bridge"));
  132.  
  133. if (template != null) {
  134. template.func_237144_a_((ServerWorld) world, new BlockPos((int) x, (int) y, (int) (z - 1)),
  135. new PlacementSettings().setRotation(Rotation.NONE).setMirror(Mirror.NONE).setChunk(null).setIgnoreEntities(false),
  136. ((World) world).rand);
  137. }
  138. }
  139. }
  140. }
  141.  
  142. }
Advertisement
Add Comment
Please, Sign In to add comment