Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
disableEnderPortalCreation: true
enderDragonDropsEgg: true
azurenWorldName: azuren
preventNaturalSpawning:
- spawn
preventSpawning:
Expand Down
24 changes: 24 additions & 0 deletions src/no/runsafe/entitycontrol/Config.java
Original file line number Diff line number Diff line change
@@ -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<String> spawnBlockerWorlds = new ArrayList<>(0);
}
7 changes: 2 additions & 5 deletions src/no/runsafe/entitycontrol/EntityDeath.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -27,6 +26,4 @@ public void OnEntityDeath(RunsafeEntityDeathEvent event)
}
}
}

private final Options options;
}
7 changes: 2 additions & 5 deletions src/no/runsafe/entitycontrol/EntityPortalCreation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
27 changes: 0 additions & 27 deletions src/no/runsafe/entitycontrol/Options.java

This file was deleted.

11 changes: 10 additions & 1 deletion src/no/runsafe/entitycontrol/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand Down
17 changes: 2 additions & 15 deletions src/no/runsafe/entitycontrol/SpawnBlocker.java
Original file line number Diff line number Diff line change
@@ -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<String> worlds = new ArrayList<>(0);
}
13 changes: 13 additions & 0 deletions src/no/runsafe/entitycontrol/shulker/AzurenShulker.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
37 changes: 37 additions & 0 deletions src/no/runsafe/entitycontrol/shulker/EntityAzurenShulker.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
40 changes: 40 additions & 0 deletions src/no/runsafe/entitycontrol/witherBoss/RunsafeWitherBoss.java
Original file line number Diff line number Diff line change
@@ -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()
{
}
}
13 changes: 13 additions & 0 deletions src/no/runsafe/entitycontrol/witherBoss/WitherOverwrite.java
Original file line number Diff line number Diff line change
@@ -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);
}
}