diff --git a/src/defaults.yml b/src/defaults.yml index c54aa25..faa75c4 100644 --- a/src/defaults.yml +++ b/src/defaults.yml @@ -1,5 +1,6 @@ disableEnderPortalCreation: true enderDragonDropsEgg: true +azurenWorldName: azuren preventNaturalSpawning: - spawn preventSpawning: diff --git a/src/no/runsafe/entitycontrol/Config.java b/src/no/runsafe/entitycontrol/Config.java new file mode 100644 index 0000000..680a1e7 --- /dev/null +++ b/src/no/runsafe/entitycontrol/Config.java @@ -0,0 +1,24 @@ +package no.runsafe.entitycontrol; + +import no.runsafe.framework.api.IConfiguration; +import no.runsafe.framework.api.event.plugin.IConfigurationChanged; + +import java.util.ArrayList; +import java.util.List; + +public class Config implements IConfigurationChanged +{ + @Override + public void OnConfigurationChanged(IConfiguration configuration) + { + disableEnderPortalCreation = configuration.getConfigValueAsBoolean("disableEnderPortalCreation"); + enderDragonDropsEgg = configuration.getConfigValueAsBoolean("enderDragonDropsEgg"); + azurenWorldName = configuration.getConfigValueAsString("azurenWorldName"); + spawnBlockerWorlds = configuration.getConfigValueAsList("preventNaturalSpawning"); + } + + public static boolean disableEnderPortalCreation; + public static boolean enderDragonDropsEgg; + public static String azurenWorldName; + public static List spawnBlockerWorlds = new ArrayList<>(0); +} diff --git a/src/no/runsafe/entitycontrol/EntityDeath.java b/src/no/runsafe/entitycontrol/EntityDeath.java index bc43747..0b54001 100644 --- a/src/no/runsafe/entitycontrol/EntityDeath.java +++ b/src/no/runsafe/entitycontrol/EntityDeath.java @@ -9,16 +9,15 @@ public class EntityDeath implements IEntityDeathEvent { - public EntityDeath(Options options) + public EntityDeath() { - this.options = options; } @Override public void OnEntityDeath(RunsafeEntityDeathEvent event) { RunsafeEntity entity = event.getEntity(); - if (entity.getEntityType() == LivingEntity.EnderDragon && this.options.enderDragonDropsEgg()) + if (entity.getEntityType() == LivingEntity.EnderDragon && Config.enderDragonDropsEgg) { ILocation location = entity.getLocation(); if (location != null) @@ -27,6 +26,4 @@ public void OnEntityDeath(RunsafeEntityDeathEvent event) } } } - - private final Options options; } diff --git a/src/no/runsafe/entitycontrol/EntityPortalCreation.java b/src/no/runsafe/entitycontrol/EntityPortalCreation.java index cef281e..a482ec7 100644 --- a/src/no/runsafe/entitycontrol/EntityPortalCreation.java +++ b/src/no/runsafe/entitycontrol/EntityPortalCreation.java @@ -6,17 +6,14 @@ public class EntityPortalCreation implements IEntityCreatePortalEvent { - public EntityPortalCreation(Options options) + public EntityPortalCreation() { - this.options = options; } @Override public void OnEntityCreatePortal(RunsafeEntityCreatePortalEvent event) { - if (event.getEntity().getEntityType() == LivingEntity.EnderDragon && this.options.disableEnderPortalCreation()) + if (event.getEntity().getEntityType() == LivingEntity.EnderDragon && Config.disableEnderPortalCreation) event.cancel(); } - - private final Options options; } diff --git a/src/no/runsafe/entitycontrol/Options.java b/src/no/runsafe/entitycontrol/Options.java deleted file mode 100644 index 9e1fa95..0000000 --- a/src/no/runsafe/entitycontrol/Options.java +++ /dev/null @@ -1,27 +0,0 @@ -package no.runsafe.entitycontrol; - -import no.runsafe.framework.api.IConfiguration; -import no.runsafe.framework.api.event.plugin.IConfigurationChanged; - -public class Options implements IConfigurationChanged -{ - public boolean disableEnderPortalCreation() - { - return this.disableEnderPortalCreation; - } - - public boolean enderDragonDropsEgg() - { - return this.enderDragonDropsEgg; - } - - @Override - public void OnConfigurationChanged(IConfiguration configuration) - { - this.disableEnderPortalCreation = configuration.getConfigValueAsBoolean("disableEnderPortalCreation"); - this.enderDragonDropsEgg = configuration.getConfigValueAsBoolean("enderDragonDropsEgg"); - } - - private boolean disableEnderPortalCreation; - private boolean enderDragonDropsEgg; -} diff --git a/src/no/runsafe/entitycontrol/Plugin.java b/src/no/runsafe/entitycontrol/Plugin.java index f221d5a..c35ce67 100644 --- a/src/no/runsafe/entitycontrol/Plugin.java +++ b/src/no/runsafe/entitycontrol/Plugin.java @@ -4,23 +4,30 @@ import no.runsafe.entitycontrol.pets.CompanionHandler; import no.runsafe.entitycontrol.pets.commands.CreateEgg; import no.runsafe.entitycontrol.pets.commands.SpawnCompanion; +import no.runsafe.entitycontrol.shulker.AzurenShulker; import no.runsafe.entitycontrol.slime.SlimeAnywhere; +import no.runsafe.entitycontrol.witherBoss.WitherOverwrite; import no.runsafe.framework.RunsafeConfigurablePlugin; import no.runsafe.framework.api.command.Command; +import no.runsafe.framework.api.log.IDebug; import no.runsafe.framework.features.Commands; import no.runsafe.framework.features.Database; import no.runsafe.framework.features.Events; public class Plugin extends RunsafeConfigurablePlugin { + public static IDebug Debugger; + @Override protected void pluginSetup() { + Debugger = getComponent(IDebug.class); + addComponent(Commands.class); addComponent(Events.class); addComponent(Database.class); - this.addComponent(Options.class); + this.addComponent(Config.class); this.addComponent(EntityPortalCreation.class); this.addComponent(EntityDeath.class); @@ -35,7 +42,9 @@ protected void pluginSetup() companionCommand.addSubCommand(getInstance(SpawnCompanion.class)); companionCommand.addSubCommand(getInstance(CreateEgg.class)); + addComponent(AzurenShulker.class); addComponent(SlimeAnywhere.class); + addComponent(WitherOverwrite.class); addComponent(SpawnBlocker.class); } diff --git a/src/no/runsafe/entitycontrol/SpawnBlocker.java b/src/no/runsafe/entitycontrol/SpawnBlocker.java index eec331a..c3ff55f 100644 --- a/src/no/runsafe/entitycontrol/SpawnBlocker.java +++ b/src/no/runsafe/entitycontrol/SpawnBlocker.java @@ -1,30 +1,17 @@ package no.runsafe.entitycontrol; import net.minecraft.server.v1_12_R1.Entity; -import no.runsafe.framework.api.IConfiguration; import no.runsafe.framework.api.ILocation; import no.runsafe.framework.api.event.entity.INaturalSpawn; -import no.runsafe.framework.api.event.plugin.IConfigurationChanged; import no.runsafe.framework.internal.wrapper.ObjectUnwrapper; import no.runsafe.framework.minecraft.entity.RunsafeEntity; -import java.util.ArrayList; -import java.util.List; - -public class SpawnBlocker implements INaturalSpawn, IConfigurationChanged +public class SpawnBlocker implements INaturalSpawn { @Override public boolean OnNaturalSpawn(RunsafeEntity entity, ILocation location) { Entity rawEntity = ObjectUnwrapper.getMinecraft(entity); - return !(rawEntity != null && worlds.contains(location.getWorld().getName())); - } - - @Override - public void OnConfigurationChanged(IConfiguration configuration) - { - worlds = configuration.getConfigValueAsList("preventNaturalSpawning"); + return !(rawEntity != null && Config.spawnBlockerWorlds.contains(location.getWorld().getName())); } - - private List worlds = new ArrayList<>(0); } diff --git a/src/no/runsafe/entitycontrol/shulker/AzurenShulker.java b/src/no/runsafe/entitycontrol/shulker/AzurenShulker.java new file mode 100644 index 0000000..7d99d6a --- /dev/null +++ b/src/no/runsafe/entitycontrol/shulker/AzurenShulker.java @@ -0,0 +1,13 @@ +package no.runsafe.entitycontrol.shulker; + +import no.runsafe.framework.api.event.IServerReady; +import no.runsafe.framework.tools.nms.EntityRegister; + +public class AzurenShulker implements IServerReady +{ + @Override + public void OnServerReady() + { + EntityRegister.registerOverrideEntity(EntityAzurenShulker.class, "Shulker", 69); + } +} diff --git a/src/no/runsafe/entitycontrol/shulker/EntityAzurenShulker.java b/src/no/runsafe/entitycontrol/shulker/EntityAzurenShulker.java new file mode 100644 index 0000000..c43c6c1 --- /dev/null +++ b/src/no/runsafe/entitycontrol/shulker/EntityAzurenShulker.java @@ -0,0 +1,37 @@ +package no.runsafe.entitycontrol.shulker; + +import net.minecraft.server.v1_12_R1.*; +import no.runsafe.entitycontrol.Config; +import no.runsafe.entitycontrol.Plugin; +import no.runsafe.framework.tools.reflection.ReflectionHelper; + +import java.util.logging.Level; + +public class EntityAzurenShulker extends EntityShulker +{ + public EntityAzurenShulker(World world) + { + super(world); + //by -> shulker colour + ReflectionHelper.setField(this, "by", EnumColor.BLACK); + this.persistent = false; + Plugin.Debugger.outputDebugToConsole("Spawning in Azuren Shulker", Level.FINE); + } + + @Override + public boolean canSpawn() + { + Plugin.Debugger.outputDebugToConsole("Attemping to spawn azuren shukler in world: " + world.getWorldData().getName(), Level.FINE); + + return world.getDifficulty() != EnumDifficulty.PEACEFUL + && world.getWorldData().getName().equals(Config.azurenWorldName) + && random.nextInt(100) == 0; + } + + @Override + protected void dropDeathLoot(boolean flag, int i) + { + Plugin.Debugger.outputDebugToConsole("Running death loot for azuren shulker.", Level.FINE); + a(Items.COOKIE, 3); + } +} diff --git a/src/no/runsafe/entitycontrol/witherBoss/RunsafeWitherBoss.java b/src/no/runsafe/entitycontrol/witherBoss/RunsafeWitherBoss.java new file mode 100644 index 0000000..22b8b60 --- /dev/null +++ b/src/no/runsafe/entitycontrol/witherBoss/RunsafeWitherBoss.java @@ -0,0 +1,40 @@ +package no.runsafe.entitycontrol.witherBoss; + +import com.google.common.base.Predicate; +import net.minecraft.server.v1_12_R1.*; +import no.runsafe.framework.tools.reflection.ReflectionHelper; + +public class RunsafeWitherBoss extends EntityWither +{ + public RunsafeWitherBoss(World world) + { + super(world); + } + + @Override + protected void r() + { + /* + this.goalSelector.a(0, (dm() > 0)); + this.goalSelector.a(2, new PathfinderGoalArrowAttack(this, 1.0F, 40, 20.0F)); + this.goalSelector.a(5, new PathfinderGoalRandomStrollLand(this, 1.0F)); + this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false, new Class[0])); + this.targetSelector.a( + 2, new PathfinderGoalNearestAttackableTarget(this, EntityInsentient.class, 0, false, false, + (Predicate) ReflectionHelper.getObjectField(this, "bH")) + ); + */ + } + + @Override + public void n() + { + } + + @Override + public void M() + { + } +} diff --git a/src/no/runsafe/entitycontrol/witherBoss/WitherOverwrite.java b/src/no/runsafe/entitycontrol/witherBoss/WitherOverwrite.java new file mode 100644 index 0000000..28822df --- /dev/null +++ b/src/no/runsafe/entitycontrol/witherBoss/WitherOverwrite.java @@ -0,0 +1,13 @@ +package no.runsafe.entitycontrol.witherBoss; + +import no.runsafe.framework.api.event.IServerReady; +import no.runsafe.framework.tools.nms.EntityRegister; + +public class WitherOverwrite implements IServerReady +{ + @Override + public void OnServerReady() + { + EntityRegister.registerOverrideEntity(RunsafeWitherBoss.class, "Slime", 64); + } +}