Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. package com.zombiekiller753.portability.nms.v1_7_R4;
  2.  
  3. import net.minecraft.server.v1_7_R4.Block;
  4. import net.minecraft.server.v1_7_R4.Blocks;
  5. import net.minecraft.server.v1_7_R4.EntityHuman;
  6. import net.minecraft.server.v1_7_R4.EntityPlayer;
  7. import net.minecraft.server.v1_7_R4.TileEntityFurnace;
  8.  
  9. import org.bukkit.block.Furnace;
  10. import org.bukkit.configuration.file.FileConfiguration;
  11. import org.bukkit.craftbukkit.v1_7_R4.block.CraftFurnace;
  12. import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
  13. import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.inventory.InventoryHolder;
  16. import org.bukkit.inventory.ItemStack;
  17.  
  18. import com.zombiekiller753.portability.nms.AbstractFurnace;
  19. import com.zombiekiller753.portability.utils.ReflectionUtil;
  20.  
  21. public class PortableFurnace extends TileEntityFurnace implements AbstractFurnace {
  22. private EntityPlayer owningPlayer;
  23. private int id;
  24.  
  25. public PortableFurnace(Player p, int i) {
  26. EntityPlayer player = ((CraftPlayer) p).getHandle();
  27. this.owningPlayer = player;
  28. this.world = player.world;
  29. this.id = i;
  30. try {
  31. ReflectionUtil.setSuperValue(this, "o", "PortableFurnace #" + i);
  32. } catch (Exception e) {
  33. e.printStackTrace();
  34. }
  35. }
  36.  
  37. public boolean a(EntityHuman entityhuman) {
  38. return true;
  39. }
  40.  
  41. public int p() {
  42. return 0;
  43. }
  44.  
  45. public Block q() {
  46. return Blocks.FURNACE;
  47. }
  48.  
  49. public InventoryHolder getOwner() {
  50. Furnace furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0));
  51. try {
  52. ReflectionUtil.setValue(furnace, "furnace", this);
  53. } catch (Exception e) {
  54. e.printStackTrace();
  55. }
  56. return furnace;
  57. }
  58.  
  59. public void open() {
  60. owningPlayer.openFurnace(this);
  61. }
  62.  
  63. public int getId() {
  64. return id;
  65. }
  66.  
  67. public void tick() {
  68. this.h();
  69. }
  70.  
  71. public void save(int id, FileConfiguration config) {
  72. for (int j = 0; j < 3; j++) {
  73. config.set("furnace." + id + "." + j, this.getItemStack(j));
  74. }
  75. config.set("furnace." + id + ".burntime", this.burnTime);
  76. config.set("furnace." + id + ".cooktime", this.cookTime);
  77. }
  78.  
  79. public void load(int id, FileConfiguration config) {
  80. for (int j = 0; j < 3; j++) {
  81. this.setItemStack(j, config.getItemStack("furnace." + id + "." + j, null));
  82. }
  83. this.burnTime = config.getInt("furnace." + id + ".burntime");
  84. this.cookTime = config.getInt("furnace." + id + ".cooktime");
  85. }
  86.  
  87. public void setItemStack(int i, ItemStack itemstack) {
  88. this.setItem(i, CraftItemStack.asNMSCopy(itemstack));
  89. }
  90.  
  91. public ItemStack getItemStack(int i) {
  92. return CraftItemStack.asBukkitCopy(this.getItem(i));
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement