use of org.spongepowered.common.util.SpongeTicks in project SpongeCommon by SpongePowered.
the class PaintingData method register.
// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator.asMutable(Painting.class).create(Keys.ART_TYPE).get(h -> (ArtType) h.motive).setAnd((h, v) -> {
if (!h.level.isClientSide) {
final Motive oldArt = h.motive;
h.motive = (Motive) v;
((HangingEntityAccessor) h).invoker$setDirection(h.getDirection());
if (!h.survives()) {
h.motive = oldArt;
((HangingEntityAccessor) h).invoker$setDirection(h.getDirection());
return false;
}
final ChunkMapAccessor chunkManager = (ChunkMapAccessor) ((ServerLevel) h.level).getChunkSource().chunkMap;
final ChunkMap_TrackedEntityAccessor paintingTracker = chunkManager.accessor$entityMap().get(h.getId());
if (paintingTracker == null) {
return true;
}
final List<ServerPlayer> players = new ArrayList<>();
for (final ServerPlayer player : paintingTracker.accessor$seenBy()) {
final ClientboundRemoveEntitiesPacket packet = new ClientboundRemoveEntitiesPacket(h.getId());
player.connection.send(packet);
players.add(player);
}
for (final ServerPlayer player : players) {
SpongeCommon.serverScheduler().submit(Task.builder().plugin(Launch.instance().commonPlugin()).delay(new SpongeTicks(SpongeGameConfigs.getForWorld(h.level).get().entity.painting.respawnDelay)).execute(() -> {
final ClientboundAddPaintingPacket packet = new ClientboundAddPaintingPacket(h);
player.connection.send(packet);
}).build());
}
return true;
}
return true;
});
}
use of org.spongepowered.common.util.SpongeTicks in project SpongeCommon by SpongePowered.
the class EndermiteData method register.
// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator.asMutable(Endermite.class).create(Keys.DESPAWN_DELAY).get(h -> {
if (h.isPersistenceRequired()) {
return null;
}
return new SpongeTicks(((EndermiteAccessor) h).accessor$life());
}).setAnd((h, v) -> {
if (h.isPersistenceRequired()) {
return false;
}
final int ticks = (int) v.ticks();
if (ticks < 0 || ticks > EndermiteData.DESPAWN_DELAY_MAX) {
return false;
}
((EndermiteAccessor) h).accessor$life(ticks);
return true;
});
}
use of org.spongepowered.common.util.SpongeTicks in project SpongeCommon by SpongePowered.
the class SpongeRangedAttackAgainstAgentGoalBuilder method reset.
@Override
public RangedAttackAgainstAgentGoal.Builder reset() {
// I'ma use Snowmen defaults. I like Snowmen.
this.maxSpeed = 1.25D;
this.delayBetweenAttacks = new SpongeTicks(20);
this.attackRadius = 10.0f;
return this;
}
Aggregations