Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. @Hook(at = @At(point = InjectionPoint.METHOD_CALL, target = "readFromNBT"),returnCondition = ReturnCondition.ALWAYS)
  2. public static void readFromNBT(TileEntityStructure tyu,NBTTagCompound compound)
  3. {
  4.  
  5. // tyu.readFromNBT(compound);
  6.  
  7. tyu.setName(compound.getString("name"));
  8. // tyu.author = compound.getString("author");
  9. tyu.setMetadata(compound.getString("metadata"));
  10. int i = MathHelper.clamp(compound.getInteger("posX"), -128, 128);
  11. int j = MathHelper.clamp(compound.getInteger("posY"), -128, 128);
  12. int k = MathHelper.clamp(compound.getInteger("posZ"), -128, 128);
  13. tyu.setPosition(new BlockPos(i, j, k));
  14. int l = MathHelper.clamp(compound.getInteger("sizeX"), 0, 128);
  15. int i1 = MathHelper.clamp(compound.getInteger("sizeY"), 0, 128);
  16. int j1 = MathHelper.clamp(compound.getInteger("sizeZ"), 0, 128);
  17. tyu.setSize(new BlockPos(l, i1, j1));
  18.  
  19. try
  20. {
  21. tyu.setRotation(Rotation.valueOf(compound.getString("rotation")));
  22. }
  23. catch (IllegalArgumentException var11)
  24. {
  25. tyu.setRotation(Rotation.NONE);
  26. }
  27.  
  28. try
  29. {
  30. tyu.setMirror(Mirror.valueOf(compound.getString("mirror")));
  31. }
  32. catch (IllegalArgumentException var10)
  33. {
  34. tyu.setMirror(Mirror.NONE);
  35. }
  36.  
  37. try
  38. {
  39. tyu.setMode(TileEntityStructure.Mode.valueOf(compound.getString("mode")));
  40. }
  41. catch (IllegalArgumentException var9)
  42. {
  43. tyu.setMode(TileEntityStructure.Mode.DATA);
  44. }
  45.  
  46. // tyu.ignoreEntities = compound.getBoolean("ignoreEntities");
  47. tyu.setPowered(compound.getBoolean("powered"));
  48. tyu.setShowAir(compound.getBoolean("showair"));
  49. tyu.setShowBoundingBox(compound.getBoolean("showboundingbox"));
  50.  
  51. if (compound.hasKey("integrity"))
  52. {
  53. tyu.setIntegrity(compound.getFloat("integrity"));
  54. }
  55. else
  56. {
  57. tyu.setIntegrity(1.0F);
  58. }
  59.  
  60. tyu.setSeed(compound.getLong("seed"));
  61.  
  62.  
  63. if (tyu.getWorld() != null)
  64. {
  65. BlockPos blockpos = tyu.getPos();
  66. IBlockState iblockstate = tyu.getWorld().getBlockState(blockpos);
  67.  
  68. if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK)
  69. {
  70. tyu.getWorld().setBlockState(blockpos, iblockstate.withProperty(BlockStructure.MODE, tyu.getMode()), 2);
  71. }
  72. }
  73. }
  74. @Hook(injectOnExit=true,returnCondition = ReturnCondition.ALWAYS)
  75. public static void writeToNBT(TileEntityStructure tyu,NBTTagCompound compound)
  76. {
  77. System.out.println("write " + tyu.getStructureSize());
  78. }
  79.  
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement