Skip to content

Commit

Permalink
egg_lay_time mech & tag bundle (#2562)
Browse files Browse the repository at this point in the history
* Adds egg lay time!!!!!!!!!!!!!!

* Update PaperModule.java
  • Loading branch information
heypr committed Nov 14, 2023
1 parent bb58ca5 commit ffa1964
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Expand Up @@ -100,6 +100,7 @@ public static void init() {
PropertyParser.registerProperty(EntityCarryingEgg.class, EntityTag.class);
PropertyParser.registerProperty(EntityDrinkingPotion.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) {
PropertyParser.registerProperty(EntityEggLayTime.class, EntityTag.class);
PropertyParser.registerProperty(EntityFriction.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityLeftHanded.class, EntityTag.class);
Expand Down
@@ -0,0 +1,44 @@
package com.denizenscript.denizen.paper.properties;

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.properties.entity.EntityProperty;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.entity.Chicken;

public class EntityEggLayTime extends EntityProperty<ElementTag> {

// <--[property]
// @object EntityTag
// @name egg_lay_time
// @input ElementTag(Number)
// @plugin Paper
// @description
// If the entity is a chicken, controls the number of ticks until it lays an egg.
// -->

public static boolean describes(EntityTag entity) {
return entity.getBukkitEntity() instanceof Chicken;
}

@Override
public ElementTag getPropertyValue() {
return new ElementTag(as(Chicken.class).getEggLayTime());
}

@Override
public String getPropertyId() {
return "egg_lay_time";
}

@Override
public void setPropertyValue(ElementTag param, Mechanism mechanism) {
if (mechanism.requireInteger()) {
as(Chicken.class).setEggLayTime(param.asInt());
}
}

public static void register() {
autoRegister("egg_lay_time", EntityEggLayTime.class, ElementTag.class, false);
}
}

0 comments on commit ffa1964

Please sign in to comment.