Search in sources :

Example 1 with EndermiteAccessor

use of org.spongepowered.common.accessor.world.entity.monster.EndermiteAccessor 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;
    });
}
Also used : Endermite(net.minecraft.world.entity.monster.Endermite) Endermite(net.minecraft.world.entity.monster.Endermite) Keys(org.spongepowered.api.data.Keys) DataProviderRegistrator(org.spongepowered.common.data.provider.DataProviderRegistrator) SpongeTicks(org.spongepowered.common.util.SpongeTicks) EndermiteAccessor(org.spongepowered.common.accessor.world.entity.monster.EndermiteAccessor) EndermiteAccessor(org.spongepowered.common.accessor.world.entity.monster.EndermiteAccessor) SpongeTicks(org.spongepowered.common.util.SpongeTicks)

Aggregations

Endermite (net.minecraft.world.entity.monster.Endermite)1 Keys (org.spongepowered.api.data.Keys)1 EndermiteAccessor (org.spongepowered.common.accessor.world.entity.monster.EndermiteAccessor)1 DataProviderRegistrator (org.spongepowered.common.data.provider.DataProviderRegistrator)1 SpongeTicks (org.spongepowered.common.util.SpongeTicks)1