From 9b5e5a871c6b79c80ba047ba671ade2e335efb58 Mon Sep 17 00:00:00 2001 From: Electroblob <35599699+Electroblob77@users.noreply.github.com> Date: Sun, 3 Jun 2018 22:22:18 +0100 Subject: [PATCH] Add dimension whitelist option for evil wizard spawning and restrict numbers to 1 per chunk, closes #26 --- src/main/java/electroblob/wizardry/Settings.java | 8 ++++++++ .../wizardry/entity/living/EntityEvilWizard.java | 15 +++++++++++++++ .../resources/assets/ebwizardry/lang/en_gb.lang | 2 ++ .../resources/assets/ebwizardry/lang/en_us.lang | 2 ++ 4 files changed, 27 insertions(+) diff --git a/src/main/java/electroblob/wizardry/Settings.java b/src/main/java/electroblob/wizardry/Settings.java index e8238e74..06dcfaf2 100644 --- a/src/main/java/electroblob/wizardry/Settings.java +++ b/src/main/java/electroblob/wizardry/Settings.java @@ -121,6 +121,8 @@ public final class Settings { public double playerDamageScale = 1.0f; /** [Server-only] Global damage scaling factor for all npc magic damage. */ public double npcDamageScale = 1.0f; + /** [Server-only] List of dimension ids in which evil wizards can spawn. */ + public int[] evilWizardDimensions = {0}; // Commands (these don't need synchronising since typing a command always queries the server). /** @@ -506,6 +508,12 @@ public final class Settings { // Converts all strings in the list to a ResourceLocation. mindControlTargetsBlacklist = Arrays.stream(property.getStringList()).map(s -> new ResourceLocation(s.toLowerCase(Locale.ROOT).trim())).toArray(ResourceLocation[]::new); propOrder.add(property.getName()); + + property = config.get(Configuration.CATEGORY_GENERAL, "evilWizardDimensions", new int[]{0}, + "List of dimension ids in which evil wizards can spawn."); + property.setLanguageKey("config." + Wizardry.MODID + ".evil_wizard_dimensions"); + property.setRequiresMcRestart(true); + evilWizardDimensions = property.getIntList(); propOrder.add(property.getName()); config.setCategoryPropertyOrder(Configuration.CATEGORY_GENERAL, propOrder); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java b/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java index 674fc3e0..d4789bb6 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java @@ -265,6 +265,21 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity (NBTTagInt tag) -> Spell.get(tag.getInt())); this.hasTower = nbt.getBoolean("hasTower"); } + + @Override + public int getMaxSpawnedInChunk(){ + return 1; + } + + @Override + public boolean getCanSpawnHere(){ + // Evil wizards can only spawn in the specified dimensions + for(int id : Wizardry.settings.evilWizardDimensions){ + if(this.dimension == id) return super.getCanSpawnHere(); + } + + return false; + } @Override protected boolean canDespawn(){ diff --git a/src/main/resources/assets/ebwizardry/lang/en_gb.lang b/src/main/resources/assets/ebwizardry/lang/en_gb.lang index 376817d1..e33cc646 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_gb.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_gb.lang @@ -698,6 +698,7 @@ config.ebwizardry.discoverspell_command_name=Discover Spell Command Name config.ebwizardry.ally_command_name=Set Ally Command Name config.ebwizardry.allies_command_name=View Allies Command Name config.ebwizardry.mind_control_targets_blacklist=Mind Control Targets Blacklist +config.ebwizardry.evil_wizard_dimensions=Evil Wizard Dimensions config.ebwizardry.mobs_immune_to_fire=Mobs Immune To Fire config.ebwizardry.mobs_immune_to_ice=Mobs Immune To Ice @@ -733,6 +734,7 @@ config.ebwizardry.discoverspell_command_name.tooltip=The name of the /discoversp config.ebwizardry.ally_command_name.tooltip=The name of the /ally command. This is what you type directly after the /; for example if this was set to 'magic' then instead of typing /ally you would type /magic instead. config.ebwizardry.allies_command_name.tooltip=The name of the /allies command. This is what you type directly after the /; for example if this was set to 'magic' then instead of typing /allies you would type /magic instead. config.ebwizardry.mind_control_targets_blacklist.tooltip=List of names of entities which cannot be mind controlled, in addition to the defaults. Add creatures to this list if allowing them to be mind-controlled causes problems or could be exploited. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. ebwizardry:wizard). +config.ebwizardry.evil_wizard_dimensions.tooltip=List of dimension ids in which evil wizards can spawn. config.ebwizardry.mobs_immune_to_fire.tooltip=List of names of entities that are immune to fire, in addition to the defaults. Add mod creatures to this list if you want them to be immune to fire magic and they aren't already. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. ebwizardry.wizard). config.ebwizardry.mobs_immune_to_ice.tooltip=List of names of entities that are immune to ice, in addition to the defaults. Add mod creatures to this list if you want them to be immune to ice magic and they aren't already. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. ebwizardry.wizard). diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang index f781df6a..ed2139e6 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_us.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang @@ -698,6 +698,7 @@ config.ebwizardry.discoverspell_command_name=Discover Spell Command Name config.ebwizardry.ally_command_name=Set Ally Command Name config.ebwizardry.allies_command_name=View Allies Command Name config.ebwizardry.mind_control_targets_blacklist=Mind Control Targets Blacklist +config.ebwizardry.evil_wizard_dimensions=Evil Wizard Dimensions config.ebwizardry.mobs_immune_to_fire=Mobs Immune To Fire config.ebwizardry.mobs_immune_to_ice=Mobs Immune To Ice @@ -733,6 +734,7 @@ config.ebwizardry.discoverspell_command_name.tooltip=The name of the /discoversp config.ebwizardry.ally_command_name.tooltip=The name of the /ally command. This is what you type directly after the /; for example if this was set to 'magic' then instead of typing /ally you would type /magic instead. config.ebwizardry.allies_command_name.tooltip=The name of the /allies command. This is what you type directly after the /; for example if this was set to 'magic' then instead of typing /allies you would type /magic instead. config.ebwizardry.mind_control_targets_blacklist.tooltip=List of names of entities which cannot be mind controlled, in addition to the defaults. Add creatures to this list if allowing them to be mind-controlled causes problems or could be exploited. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. ebwizardry:wizard). +config.ebwizardry.evil_wizard_dimensions.tooltip=List of dimension ids in which evil wizards can spawn. config.ebwizardry.mobs_immune_to_fire.tooltip=List of names of entities that are immune to fire, in addition to the defaults. Add mod creatures to this list if you want them to be immune to fire magic and they aren't already. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. ebwizardry.wizard). config.ebwizardry.mobs_immune_to_ice.tooltip=List of names of entities that are immune to ice, in addition to the defaults. Add mod creatures to this list if you want them to be immune to ice magic and they aren't already. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. ebwizardry.wizard).