Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.zombiekiller753.portability.nms.v1_7_R4;
- import net.minecraft.server.v1_7_R4.Block;
- import net.minecraft.server.v1_7_R4.Blocks;
- import net.minecraft.server.v1_7_R4.EntityHuman;
- import net.minecraft.server.v1_7_R4.EntityPlayer;
- import net.minecraft.server.v1_7_R4.TileEntityFurnace;
- import org.bukkit.block.Furnace;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.craftbukkit.v1_7_R4.block.CraftFurnace;
- import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
- import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.InventoryHolder;
- import org.bukkit.inventory.ItemStack;
- import com.zombiekiller753.portability.nms.AbstractFurnace;
- import com.zombiekiller753.portability.utils.ReflectionUtil;
- public class PortableFurnace extends TileEntityFurnace implements AbstractFurnace {
- private EntityPlayer owningPlayer;
- private int id;
- public PortableFurnace(Player p, int i) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- this.owningPlayer = player;
- this.world = player.world;
- this.id = i;
- try {
- ReflectionUtil.setSuperValue(this, "o", "PortableFurnace #" + i);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
- public int p() {
- return 0;
- }
- public Block q() {
- return Blocks.FURNACE;
- }
- public InventoryHolder getOwner() {
- Furnace furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0));
- try {
- ReflectionUtil.setValue(furnace, "furnace", this);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return furnace;
- }
- public void open() {
- owningPlayer.openFurnace(this);
- }
- public int getId() {
- return id;
- }
- public void tick() {
- this.h();
- }
- public void save(int id, FileConfiguration config) {
- for (int j = 0; j < 3; j++) {
- config.set("furnace." + id + "." + j, this.getItemStack(j));
- }
- config.set("furnace." + id + ".burntime", this.burnTime);
- config.set("furnace." + id + ".cooktime", this.cookTime);
- }
- public void load(int id, FileConfiguration config) {
- for (int j = 0; j < 3; j++) {
- this.setItemStack(j, config.getItemStack("furnace." + id + "." + j, null));
- }
- this.burnTime = config.getInt("furnace." + id + ".burntime");
- this.cookTime = config.getInt("furnace." + id + ".cooktime");
- }
- public void setItemStack(int i, ItemStack itemstack) {
- this.setItem(i, CraftItemStack.asNMSCopy(itemstack));
- }
- public ItemStack getItemStack(int i) {
- return CraftItemStack.asBukkitCopy(this.getItem(i));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement