Package com.garbagemule.MobArena.repairable

Source Code of com.garbagemule.MobArena.repairable.RepairableAttachable

package com.garbagemule.MobArena.repairable;

import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.material.Attachable;

public class RepairableAttachable extends RepairableBlock
{
    private int x, y, z;
   
    public RepairableAttachable(BlockState state)
    {
        super(state);
       
        BlockState attached;
        if (state.getData() instanceof Attachable)
            attached = state.getBlock().getRelative(((Attachable) state.getData()).getAttachedFace()).getState();
        else
            attached = state.getBlock().getRelative(BlockFace.DOWN).getState();
       
        x = attached.getX();
        y = attached.getY();
        z = attached.getZ();
       
        state.getBlock().setTypeId(1);
    }

    public void repair()
    {
        Block b = getWorld().getBlockAt(x,y,z);
        if (b.getTypeId() == 0)
            b.setTypeId(1);
       
        super.repair();
    }
}
TOP

Related Classes of com.garbagemule.MobArena.repairable.RepairableAttachable

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.