use of net.minecraft.entity.player.EntityPlayer in project BetterStorage by copygirl.
the class BackpackHandler method onEntityInteract.
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
if (event.entity.worldObj.isRemote || !(event.entity instanceof EntityPlayerMP) || !(event.target instanceof EntityLivingBase) || (((EntityPlayerMP) event.entity).playerNetServerHandler == null) || ((event.target instanceof EntityPlayer) && !BetterStorage.globalConfig.getBoolean(GlobalConfig.enableBackpackInteraction)))
return;
EntityPlayerMP player = (EntityPlayerMP) event.entity;
EntityLivingBase target = (EntityLivingBase) event.target;
if (ItemBackpack.openBackpack(player, target))
player.swingItem();
}
use of net.minecraft.entity.player.EntityPlayer in project BetterStorage by copygirl.
the class ChannelHandler method sendToAllAround.
public void sendToAllAround(IMessage message, World world, double x, double y, double z, double distance, EntityPlayer except) {
for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) {
if (player == except)
continue;
double dx = x - player.posX;
double dy = y - player.posY;
double dz = z - player.posZ;
if ((dx * dx + dy * dy + dz * dz) < (distance * distance))
sendTo(message, player);
}
}
use of net.minecraft.entity.player.EntityPlayer in project Guide-API by TeamAmeriFrance.
the class EventHandler method onPlayerJoinWorld.
@SubscribeEvent
public void onPlayerJoinWorld(EntityJoinWorldEvent event) {
if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
NBTTagCompound tag = getModTag(player, GuideMod.ID);
if (ConfigHandler.canSpawnWithBooks) {
for (Book book : GuideAPI.getBooks().values()) {
if (book.isSpawnWithBook() && !tag.getBoolean("hasInitial" + book.getTitle())) {
ItemHandlerHelper.giveItemToPlayer(player, GuideAPI.getStackFromBook(book));
tag.setBoolean("hasInitial" + book.getTitle(), true);
}
}
}
}
}
use of net.minecraft.entity.player.EntityPlayer in project Witchworks by Um-Mitternacht.
the class ItemTaglock method getVictim.
public Optional<EntityLivingBase> getVictim(ItemStack stack, World world) {
UUID uuid = NBTHelper.getUniqueID(stack, TAGLOCK_ENTITY);
for (Entity entity : world.loadedEntityList) {
if (entity instanceof EntityLivingBase && entity.getUniqueID().equals(uuid)) {
return Optional.of((EntityLivingBase) entity);
}
}
EntityPlayer victim = world.getPlayerEntityByUUID(uuid);
return Optional.ofNullable(victim);
}
use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EventsCommon method onRightClickBlock.
@SubscribeEvent()
public void onRightClickBlock(RightClickBlock event) {
if (!event.getWorld().isRemote) {
ItemStack stack = event.getItemStack();
if (stack != null && stack.getItem() instanceof ItemNameTag) {
BlockPos posAt = event.getPos();
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
if (wrapper != null) {
wrapper.setCustomNameTag(stack.getDisplayName());
--stack.stackSize;
event.setCanceled(true);
}
}
}
}
Aggregations