use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.
the class ItemItemFrame method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc) {
GlowItemFrame entity = new GlowItemFrame(player, target.getLocation().getBlock().getRelative(face).getLocation(), face);
List<Message> spawnMessage = entity.createSpawnMessage();
entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(spawnMessage.toArray(new Message[spawnMessage.size()])));
}
use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.
the class ItemFrameStore method createEntity.
public GlowItemFrame createEntity(Location location, CompoundTag compound) {
// item frame will be set by loading code below
int facing = compound.getByte("Facing");
GlowItemFrame itemFrame = new GlowItemFrame(null, location, null);
itemFrame.setFacingDirectionNumber(facing);
return itemFrame;
}
use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.
the class ItemItemFrame method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
GlowItemFrame entity = new GlowItemFrame(player, target.getRelative(face).getLocation(), face);
if (EventFactory.getInstance().callEvent(new HangingPlaceEvent(entity, player, target, face)).isCancelled()) {
return;
}
List<Message> spawnMessage = entity.createSpawnMessage();
entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(spawnMessage.toArray(new Message[spawnMessage.size()])));
}
use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.
the class GlowEntity method pulse.
/**
* Called every game cycle. Subclasses should implement this to implement periodic functionality
* e.g. mob AI.
*/
public void pulse() {
if (!isTicking()) {
return;
}
ticksLived++;
if (fireTicks > 0) {
--fireTicks;
}
metadata.setBit(MetadataIndex.STATUS, StatusFlags.ON_FIRE, fireTicks > 0);
// to dislocate.
if (ticksLived % (30 * 20) == 0) {
if (!(this instanceof GlowItemFrame || this instanceof GlowPainting)) {
teleported = true;
}
}
if (this instanceof GlowLivingEntity && !isDead() && ((GlowLivingEntity) this).hasAI()) {
GlowLivingEntity entity = (GlowLivingEntity) this;
entity.getTaskManager().pulse();
}
followLead();
pulsePhysics();
if (hasMoved()) {
Block currentBlock = location.getBlock();
if (currentBlock.getType() == Material.END_PORTAL) {
EventFactory.getInstance().callEvent(new EntityPortalEnterEvent(this, currentBlock.getLocation()));
if (server.getAllowEnd()) {
Location previousLocation = location.clone();
boolean success;
if (getWorld().getEnvironment() == Environment.THE_END) {
success = teleportToSpawn();
} else {
success = teleportToEnd();
}
if (success) {
EntityPortalExitEvent e = EventFactory.getInstance().callEvent(new EntityPortalExitEvent(this, previousLocation, location.clone(), velocity.clone(), new Vector()));
if (!e.getAfter().equals(velocity)) {
setVelocity(e.getAfter());
}
}
}
}
}
if (leashHolderUniqueId != null && ticksLived < 2) {
Optional<GlowEntity> any = world.getEntityManager().getAll().stream().filter(e -> leashHolderUniqueId.equals(e.getUniqueId())).findAny();
if (!any.isPresent()) {
world.dropItemNaturally(location, new ItemStack(Material.LEAD));
}
setLeashHolder(any.orElse(null));
leashHolderUniqueId = null;
}
}
Aggregations