Files
CustomNPC-Plus/src/main/java/noppes/npcs/blocks/BlockWaypoint.java
T

54 lines
2.1 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.blocks;
import kamkeel.npcs.network.PacketHandler;
2025-01-30 13:54:55 -05:00
import kamkeel.npcs.network.packets.data.gui.GuiWaypointPacket;
2018-09-13 12:03:28 -04:00
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.blocks.tiles.TileWaypoint;
import noppes.npcs.constants.EnumGuiType;
2025-03-12 20:12:01 -04:00
public class BlockWaypoint extends BlockContainer {
2018-09-13 12:03:28 -04:00
2025-03-12 20:12:01 -04:00
public BlockWaypoint() {
2018-09-13 12:03:28 -04:00
super(Material.iron);
this.setCreativeTab(CustomItems.tab);
2025-03-12 20:12:01 -04:00
}
2018-09-13 12:03:28 -04:00
2024-02-19 19:14:51 -05:00
@Override
2025-03-12 20:12:01 -04:00
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (par1World.isRemote)
return false;
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_WAYPOINT)) {
TileEntity tile = par1World.getTileEntity(i, j, k);
NBTTagCompound compound = new NBTTagCompound();
tile.writeToNBT(compound);
PacketHandler.Instance.sendToPlayer(new GuiWaypointPacket(compound), (EntityPlayerMP) player);
return true;
}
return false;
2018-09-13 12:03:28 -04:00
}
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
@Override
2025-03-12 20:12:01 -04:00
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item) {
if (entityliving instanceof EntityPlayer && world.isRemote) {
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Waypoint, (EntityPlayer) entityliving);
}
2018-09-13 12:03:28 -04:00
}
2024-02-19 19:14:51 -05:00
2025-03-12 20:12:01 -04:00
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileWaypoint();
}
2018-09-13 12:03:28 -04:00
}