Skip to content

Commit

Permalink
creeper
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 10, 2024
1 parent 7377077 commit f1b341a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import xyz.nifeather.morph.backends.server.renderer.network.registries.ValueIndex;
import xyz.nifeather.morph.misc.disguiseProperty.DisguiseProperties;
import xyz.nifeather.morph.misc.disguiseProperty.SingleProperty;
import xyz.nifeather.morph.misc.disguiseProperty.values.CreeperProperties;

public class CreeperWatcher extends LivingEntityWatcher
{
Expand All @@ -20,6 +23,20 @@ protected void initRegistry()
register(ValueIndex.CREEPER);
}

@Override
protected <X> void onPropertyWrite(SingleProperty<X> property, X value)
{
var properties = DisguiseProperties.INSTANCE.getOrThrow(CreeperProperties.class);

if (property.equals(properties.CHARGED))
{
var isCharged = Boolean.TRUE.equals(value);
this.writePersistent(ValueIndex.CREEPER.IS_CHARGED_CREEPER, isCharged);
}

super.onPropertyWrite(property, value);
}

@Override
public void mergeFromCompound(CompoundTag nbt)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public DisguiseProperties()
register(EntityType.VILLAGER, new VillagerProperties());
register(EntityType.ZOMBIE_VILLAGER, new VillagerProperties());
register(EntityType.ARMOR_STAND, new ArmorStandProperties());
register(EntityType.CREEPER, new CreeperProperties());
}

public void register(EntityType type, AbstractProperties properties)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package xyz.nifeather.morph.misc.disguiseProperty.values;

import xyz.nifeather.morph.misc.disguiseProperty.SingleProperty;

public class CreeperProperties extends AbstractProperties
{
public final SingleProperty<Boolean> CHARGED = getSingle("charged", false).withRandom(false, false, false, true);

public CreeperProperties()
{
registerSingle(CHARGED);
}
}

0 comments on commit f1b341a

Please sign in to comment.