use of net.glowstone.entity.objects.GlowPainting in project Glowstone by GlowstoneMC.
the class ItemPainting method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
Location center = target.getRelative(face).getLocation();
GlowPainting painting = new GlowPainting(center, face);
for (Key key : ART_BY_SIZE.keySet()) {
List<Art> arts = ART_BY_SIZE.get(key);
painting.setArtInternal(arts.get(0));
if (!painting.isObstructed()) {
int i = ThreadLocalRandom.current().nextInt(0, arts.size());
painting.setArtInternal(arts.get(i));
return;
}
}
player.playSound(center, Sound.ENTITY_PAINTING_PLACE, SoundCategory.NEUTRAL, 1.0f, 1.0f);
}
use of net.glowstone.entity.objects.GlowPainting 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