(){
+ this.targetSelector = entity -> {
- public boolean apply(Entity entity){
+ // If the target is valid and not invisible...
+ if(entity != null && !entity.isInvisible()
+ && WizardryUtilities.isValidTarget(EntityWizard.this, entity)){
- // If the target is valid and not invisible...
- if(entity != null && !entity.isInvisible()
- && WizardryUtilities.isValidTarget(EntityWizard.this, entity)){
-
- // ... and is a mob, a summoned creature ...
- if((entity instanceof IMob || entity instanceof ISummonedCreature
- // ... or in the whitelist ...
- || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist)
- .contains(EntityList.getKey(entity.getClass())))
- // ... and isn't in the blacklist ...
- && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist)
- .contains(EntityList.getKey(entity.getClass()))){
- // ... it can be attacked.
- return true;
- }
+ // ... and is a mob, a summoned creature ...
+ if((entity instanceof IMob || entity instanceof ISummonedCreature
+ // ... or in the whitelist ...
+ || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist)
+ .contains(EntityList.getKey(entity.getClass())))
+ // ... and isn't in the blacklist ...
+ && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist)
+ .contains(EntityList.getKey(entity.getClass()))){
+ // ... it can be attacked.
+ return true;
}
-
- return false;
}
+
+ return false;
};
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
diff --git a/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java b/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java
index a3bbfcee..b510dc9c 100644
--- a/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java
+++ b/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java
@@ -157,7 +157,7 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData {
* Called by the client when it receives a Entity spawn packet. Data should be read out of the stream in the same
* way as it was written. Implementors must call super when overriding.
*
- * @param additionalData The packet data stream
+ * @param buffer The packet data stream
*/
@Override
default void readSpawnData(ByteBuf buffer){
@@ -241,11 +241,11 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData {
* to do something when a successful attack is made. This was added because the event-based damage source system can
* cause parts of attackEntityAsMob not to fire, since attackEntityFrom is intercepted and canceled.
*
- * Usage examples: {@link EntitySliverfishMinion} uses this to summon more silverfish if the target is killed,
+ * Usage examples: {@link EntitySilverfishMinion} uses this to summon more silverfish if the target is killed,
* {@link EntitySkeletonMinion} and {@link EntitySpiderMinion} use this to add potion effects to the target.
*/
default void onSuccessfulAttack(EntityLivingBase target){
- };
+ }
// Delegates
diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java
index d0bfcf28..50c5e648 100644
--- a/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java
+++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java
@@ -34,8 +34,7 @@ public class EntityFirebolt extends EntityMagicProjectile {
if(world.isRemote){
for(int i = 0; i < 8; i++){
world.spawnParticle(EnumParticleTypes.LAVA, this.posX + rand.nextFloat() - 0.5,
- this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0,
- 0);
+ this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0);
}
}
diff --git a/src/main/java/electroblob/wizardry/item/IWorkbenchItem.java b/src/main/java/electroblob/wizardry/item/IWorkbenchItem.java
index 22af5327..704bebec 100644
--- a/src/main/java/electroblob/wizardry/item/IWorkbenchItem.java
+++ b/src/main/java/electroblob/wizardry/item/IWorkbenchItem.java
@@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
/**
* Items that implement this interface may be placed in the central slot of the arcane workbench as long as
- * {@link IWorkbenchItem#canPlace(ItemStack)} returns true.The number of spell book slots displayed is also specified
+ * {@link IWorkbenchItem#canPlace(ItemStack)} returns true. The number of spell book slots displayed is also specified
* using {@link IWorkbenchItem#getSpellSlotCount(ItemStack)}.
*
* Items that implement this interface define what happens if they are in the central slot of the arcane workbench and
diff --git a/src/main/java/electroblob/wizardry/item/ItemWand.java b/src/main/java/electroblob/wizardry/item/ItemWand.java
index d772ad55..950a5a5d 100644
--- a/src/main/java/electroblob/wizardry/item/ItemWand.java
+++ b/src/main/java/electroblob/wizardry/item/ItemWand.java
@@ -52,7 +52,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
* written the {@link WandHelper} class. I strongly recommend you use it for interacting with wand items wherever
* possible.
*
- * It's unikely that anything in this class will be of much use externally, but should you wish to use it for whatever
+ * It's unlikely that anything in this class will be of much use externally, but should you wish to use it for whatever
* reason (perhaps if you extend it), it works as follows:
*
* - onItemRightClick is where non-continuous spells are cast, and it sets the item in use for continuous spells
diff --git a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java
index 898576b5..c3d42872 100644
--- a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java
+++ b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java
@@ -37,9 +37,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@Mod.EventBusSubscriber
public class ItemWizardArmour extends ItemArmor implements IWorkbenchItem {
- //VanillaCopy, ItemArmor has this set to private for some reason.
+ // VanillaCopy, ItemArmor has this set to private for some reason.
public static final UUID[] ARMOR_MODIFIERS = new UUID[] {UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
- //Damage reduction values that used to be in WizardryItems.SILK [feet, legs, chest, head]
+ // Damage reduction values that used to be in WizardryItems.SILK [feet, legs, chest, head]
private static int[] reductions = new int[]{2, 4, 5, 2};
public Element element;
diff --git a/src/main/java/electroblob/wizardry/potion/PotionDecay.java b/src/main/java/electroblob/wizardry/potion/PotionDecay.java
index db22ee7e..91a6c854 100644
--- a/src/main/java/electroblob/wizardry/potion/PotionDecay.java
+++ b/src/main/java/electroblob/wizardry/potion/PotionDecay.java
@@ -34,11 +34,11 @@ public class PotionDecay extends Potion {
}
@Override
- public boolean isReady(int p_76397_1_, int p_76397_2_){
+ public boolean isReady(int duration, int amplifier){
// Copied from the vanilla wither effect. It does the timing stuff. 25 is the number of ticks between hits at
// amplifier 0
- int k = 25 >> p_76397_2_;
- return k > 0 ? p_76397_1_ % k == 0 : true;
+ int k = 25 >> amplifier;
+ return k > 0 ? duration % k == 0 : true;
}
@Override
diff --git a/src/main/java/electroblob/wizardry/registry/Spells.java b/src/main/java/electroblob/wizardry/registry/Spells.java
index 64abadc4..eb775f1e 100644
--- a/src/main/java/electroblob/wizardry/registry/Spells.java
+++ b/src/main/java/electroblob/wizardry/registry/Spells.java
@@ -54,7 +54,8 @@ import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.RegistryBuilder;
/**
- * Class responsible for defining, storing and registering all of wizardry's spells.
+ * Class responsible for defining, storing and registering all of wizardry's spells. Use this to access individual
+ * spell instances, similar to the {@code Blocks} and {@code Items} classes.
*
* @author Electroblob
* @since Wizardry 2.1
@@ -75,7 +76,8 @@ public final class Spells {
public static void createRegistry(RegistryEvent.NewRegistry event){
// Beats me why we need both of these. Surely the type parameter means it already knows?
- RegistryBuilder builder = new RegistryBuilder();
+ // EDIT: It's probably because of type erasure, thinking about it.
+ RegistryBuilder builder = new RegistryBuilder<>();
builder.setType(Spell.class);
builder.setName(new ResourceLocation(Wizardry.MODID, "spells"));
builder.setIDRange(0, 5000); // Is there any penalty for using a larger number?
diff --git a/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java b/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java
index 3fcb2495..a88bff23 100644
--- a/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java
+++ b/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java
@@ -26,13 +26,6 @@ import net.minecraftforge.registries.IForgeRegistry;
@Mod.EventBusSubscriber
public final class WizardryBlocks {
- // I get registry events, they make sense - even I doubted myself with when to do various things in the load
- // process,
- // so I can see why the folks at Forge wanted to save us having to think about it.
- // What I do not understand is why you would use @ObjectHolder for your own blocks and items. What's the point in
- // making your code longer and more complicated, when you can just define the blocks as constants and register them
- // later?
-
// Found a very nice way of registering things using arrays, which might make @ObjectHolder actually useful.
// http://www.minecraftforge.net/forum/topic/49497-1112-is-using-registryevent-this-way-ok/
diff --git a/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java b/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java
index 09288bb2..2c3ba970 100644
--- a/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java
+++ b/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java
@@ -17,12 +17,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public final class WizardryEnchantments {
- // At the moment these enchantments generate on books in dungeon chests due to a bad bit of code
- // (EnchantRandomly:50).
+ // At the moment these enchantments generate on books in dungeon chests due to a bad bit of code (EnchantRandomly:49).
// No idea how to fix this because I have no way of hooking into that code... removing the enchantments from the
// registry works, but breaks everything else!
- // TODO: For the time being, a dynamic solution will have to do, i.e. intercept the book when it is generated and
+ // For the time being, a dynamic solution will have to do, i.e. intercept the book when it is generated and
// reassign its enchantment.
// All of these have custom classes, so the unlocalised name (referred to simply as 'name' for enchantments) is
diff --git a/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java b/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java
index 62f863f4..6b150adc 100644
--- a/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java
+++ b/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java
@@ -1,74 +1,18 @@
package electroblob.wizardry.registry;
-import java.util.List;
-
import com.google.common.collect.Lists;
-
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.entity.EntityArc;
import electroblob.wizardry.entity.EntityMeteor;
import electroblob.wizardry.entity.EntityShield;
-import electroblob.wizardry.entity.construct.EntityArrowRain;
-import electroblob.wizardry.entity.construct.EntityBlackHole;
-import electroblob.wizardry.entity.construct.EntityBlizzard;
-import electroblob.wizardry.entity.construct.EntityBubble;
-import electroblob.wizardry.entity.construct.EntityDecay;
-import electroblob.wizardry.entity.construct.EntityEarthquake;
-import electroblob.wizardry.entity.construct.EntityFireRing;
-import electroblob.wizardry.entity.construct.EntityFireSigil;
-import electroblob.wizardry.entity.construct.EntityForcefield;
-import electroblob.wizardry.entity.construct.EntityFrostSigil;
-import electroblob.wizardry.entity.construct.EntityHailstorm;
-import electroblob.wizardry.entity.construct.EntityHammer;
-import electroblob.wizardry.entity.construct.EntityHealAura;
-import electroblob.wizardry.entity.construct.EntityIceSpike;
-import electroblob.wizardry.entity.construct.EntityLightningPulse;
-import electroblob.wizardry.entity.construct.EntityLightningSigil;
-import electroblob.wizardry.entity.construct.EntityTornado;
-import electroblob.wizardry.entity.living.EntityBlazeMinion;
-import electroblob.wizardry.entity.living.EntityDecoy;
-import electroblob.wizardry.entity.living.EntityEvilWizard;
-import electroblob.wizardry.entity.living.EntityIceGiant;
-import electroblob.wizardry.entity.living.EntityIceWraith;
-import electroblob.wizardry.entity.living.EntityLightningWraith;
-import electroblob.wizardry.entity.living.EntityMagicSlime;
-import electroblob.wizardry.entity.living.EntityPhoenix;
-import electroblob.wizardry.entity.living.EntityShadowWraith;
-import electroblob.wizardry.entity.living.EntitySilverfishMinion;
-import electroblob.wizardry.entity.living.EntitySkeletonMinion;
-import electroblob.wizardry.entity.living.EntitySpiderMinion;
-import electroblob.wizardry.entity.living.EntitySpiritHorse;
-import electroblob.wizardry.entity.living.EntitySpiritWolf;
-import electroblob.wizardry.entity.living.EntityStormElemental;
-import electroblob.wizardry.entity.living.EntityWitherSkeletonMinion;
-import electroblob.wizardry.entity.living.EntityWizard;
-import electroblob.wizardry.entity.living.EntityZombieMinion;
-import electroblob.wizardry.entity.projectile.EntityDarknessOrb;
-import electroblob.wizardry.entity.projectile.EntityDart;
-import electroblob.wizardry.entity.projectile.EntityFirebolt;
-import electroblob.wizardry.entity.projectile.EntityFirebomb;
-import electroblob.wizardry.entity.projectile.EntityForceArrow;
-import electroblob.wizardry.entity.projectile.EntityForceOrb;
-import electroblob.wizardry.entity.projectile.EntityIceCharge;
-import electroblob.wizardry.entity.projectile.EntityIceLance;
-import electroblob.wizardry.entity.projectile.EntityIceShard;
-import electroblob.wizardry.entity.projectile.EntityLightningArrow;
-import electroblob.wizardry.entity.projectile.EntityLightningDisc;
-import electroblob.wizardry.entity.projectile.EntityMagicMissile;
-import electroblob.wizardry.entity.projectile.EntityPoisonBomb;
-import electroblob.wizardry.entity.projectile.EntitySmokeBomb;
-import electroblob.wizardry.entity.projectile.EntitySpark;
-import electroblob.wizardry.entity.projectile.EntitySparkBomb;
-import electroblob.wizardry.entity.projectile.EntityThunderbolt;
+import electroblob.wizardry.entity.construct.*;
+import electroblob.wizardry.entity.living.*;
+import electroblob.wizardry.entity.projectile.*;
import electroblob.wizardry.loot.RandomSpell;
import electroblob.wizardry.loot.WizardSpell;
-import electroblob.wizardry.tileentity.TileEntityArcaneWorkbench;
-import electroblob.wizardry.tileentity.TileEntityMagicLight;
-import electroblob.wizardry.tileentity.TileEntityPlayerSave;
-import electroblob.wizardry.tileentity.TileEntityStatue;
-import electroblob.wizardry.tileentity.TileEntityTimer;
+import electroblob.wizardry.tileentity.*;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
@@ -91,6 +35,8 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import net.minecraftforge.registries.IForgeRegistry;
+import java.util.List;
+
/**
* Class responsible for registering all the things that don't have (or need) instances: entities, loot tables, recipes,
* etc.
@@ -101,13 +47,11 @@ import net.minecraftforge.registries.IForgeRegistry;
@Mod.EventBusSubscriber
public final class WizardryRegistry {
- // NOTE: In 1.12, recipes have a registry (they can still stay here though since we don't keep references to them)
-
/** Called from the preInit method in the main mod class to register the custom dungeon loot. */
public static void registerLoot(){
/* Loot tables work as follows: Minecraft goes through each pool in turn. For each pool, it does a certain
- * number or rolls, which can either be set to always be one number or a random number from a range. Each roll,
+ * number of rolls, which can either be set to always be one number or a random number from a range. Each roll,
* it generates one stack of a single random entry in that pool, weighted according to the weights of the
* entries. Functions allow properties of that stack (stack size, damage, nbt) to be set, and even allow it to
* be replaced dynamically with a completely different item (though there's very little point in doing that as
@@ -246,7 +190,7 @@ public final class WizardryRegistry {
/** Now only deals with the dynamic crafting recipes and the smelting recipes. */
@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register event){
-
+
IForgeRegistry registry = event.getRegistry();
FurnaceRecipes.instance().addSmeltingRecipeForBlock(WizardryBlocks.crystal_ore, new ItemStack(WizardryItems.magic_crystal), 0.5f);
diff --git a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java
index 5b50eb61..e472c4c5 100644
--- a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java
+++ b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java
@@ -8,8 +8,7 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
/**
- * Class responsible for defining, storing and registering all of wizardry's sound events. For some reason, these worked
- * in the beta versions despite not being registered...
+ * Class responsible for defining, storing and registering all of wizardry's sound events.
*
* @author Electroblob
* @since Wizardry 2.1
diff --git a/src/main/java/electroblob/wizardry/spell/Light.java b/src/main/java/electroblob/wizardry/spell/Light.java
index b97cf15b..76b5fb9b 100644
--- a/src/main/java/electroblob/wizardry/spell/Light.java
+++ b/src/main/java/electroblob/wizardry/spell/Light.java
@@ -59,7 +59,6 @@ public class Light extends Spell {
BlockPos pos = new BlockPos(x, y, z);
if(world.isAirBlock(pos)){
- // world.playSound(x, y, z, "sound.ambient.cave.cave", 1.0f, 1.5f, false);
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.magic_light.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
diff --git a/src/main/java/electroblob/wizardry/spell/Spell.java b/src/main/java/electroblob/wizardry/spell/Spell.java
index b7b1a930..20484baf 100644
--- a/src/main/java/electroblob/wizardry/spell/Spell.java
+++ b/src/main/java/electroblob/wizardry/spell/Spell.java
@@ -272,7 +272,7 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C
return modID;
}
- /** Returns the ResourceLocation for this spell's icon. */
+ /** Returns the {@code ResourceLocation} for this spell's icon. */
public final ResourceLocation getIcon(){
return icon;
}
@@ -368,7 +368,7 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C
/**
* Returns the total number of registered spells, excluding the 'None' spell. Returns the same number that would be
- * returned by Spell.getSpells(Spell.allSpells).size(), but this method is more efficient.
+ * returned by {@code Spell.getSpells(Spell.allSpells).size()}, but this method is more efficient.
*/
public static int getTotalSpellCount(){
return registry.getValuesCollection().size() - 1;
diff --git a/src/main/java/electroblob/wizardry/spell/SpellConstruct.java b/src/main/java/electroblob/wizardry/spell/SpellConstruct.java
index bd3b4ad5..dce473e5 100644
--- a/src/main/java/electroblob/wizardry/spell/SpellConstruct.java
+++ b/src/main/java/electroblob/wizardry/spell/SpellConstruct.java
@@ -40,7 +40,7 @@ import net.minecraft.world.World;
*/
public class SpellConstruct extends Spell {
- /** A factory that creates projectile entities. */
+ /** A factory that creates construct entities. */
protected final Function constructFactory;
/** The base lifetime of the construct created by this spell, or -1 if the construct does not despawn. */
protected final int baseDuration;
diff --git a/src/main/java/electroblob/wizardry/spell/SpellRay.java b/src/main/java/electroblob/wizardry/spell/SpellRay.java
index 41c65e52..0ac28b72 100644
--- a/src/main/java/electroblob/wizardry/spell/SpellRay.java
+++ b/src/main/java/electroblob/wizardry/spell/SpellRay.java
@@ -276,6 +276,10 @@ public abstract class SpellRay extends Spell {
spawnParticle(world, x, y, z, velocity.x, velocity.y, velocity.z);
}
}
+ // The exact behaviour of the returned values of the following three methods can be a little confusing. Normally,
+ // either onEntityHit or onBlockHit (or both) will return true when the spell succeeded in hitting the block or
+ // entity, and false if not (note that those two methods are mutually exclusive). If false is returned, onMiss will
+ // be called - onMiss will never be called if either of the other methods returns true.
/**
* Called when the spell hits an entity. Will never be called if ignoreEntities is true.
diff --git a/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java b/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java
index 523f9b7a..8bd2d63f 100644
--- a/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java
+++ b/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java
@@ -26,10 +26,8 @@ public class ContainerArcaneWorkbench extends Container {
/** The arcane workbench tile entity associated with this container. */
public TileEntityArcaneWorkbench tileentity;
- public static final ResourceLocation EMPTY_SLOT_CRYSTAL = new ResourceLocation(Wizardry.MODID,
- "gui/empty_slot_crystal");
- public static final ResourceLocation EMPTY_SLOT_UPGRADE = new ResourceLocation(Wizardry.MODID,
- "gui/empty_slot_upgrade");
+ public static final ResourceLocation EMPTY_SLOT_CRYSTAL = new ResourceLocation(Wizardry.MODID, "gui/empty_slot_crystal");
+ public static final ResourceLocation EMPTY_SLOT_UPGRADE = new ResourceLocation(Wizardry.MODID, "gui/empty_slot_upgrade");
public static final int CRYSTAL_SLOT = 8;
public static final int CENTRE_SLOT = 9;
@@ -260,7 +258,7 @@ public class ContainerArcaneWorkbench extends Container {
if(((IWorkbenchItem)centre.getStack().getItem())
.onApplyButtonPressed(player, centre, this.getSlot(CRYSTAL_SLOT), this.getSlot(UPGRADE_SLOT), spellBooks)){
- // TODO: Sound and possibly animation for spell binding
+ // Probably don't need to do anything here, unless we're going to use packets to control the animation
}
}
}
diff --git a/src/main/java/electroblob/wizardry/util/SpellModifiers.java b/src/main/java/electroblob/wizardry/util/SpellModifiers.java
index 59155a29..a8ee1e91 100644
--- a/src/main/java/electroblob/wizardry/util/SpellModifiers.java
+++ b/src/main/java/electroblob/wizardry/util/SpellModifiers.java
@@ -26,8 +26,8 @@ import net.minecraftforge.fml.common.network.ByteBufUtils;
* that not all wand upgrades affect spells). SpellModifiers objects are mutable, so you can simply change the
* values they contain to modify the spell.
*
- * To use a SpellModifiers object within the Spell.cast methods, simply retrieve the desired multiplier
- * using {@link SpellModifiers#get(Item)} for wand upgrades, or {@link SpellModifiers#get(String)} if the multiplier is
+ * To use a SpellModifiers object within the Spell.cast methods, simply retrieve the desired modifier
+ * using {@link SpellModifiers#get(Item)} for wand upgrades, or {@link SpellModifiers#get(String)} if the modifier is
* not from a wand upgrade.
*
* @author Electroblob
@@ -139,6 +139,9 @@ public final class SpellModifiers {
buf.writeFloat(entry.getValue());
}
}
+
+ // These two don't use the Map <-> NBT methods in WizardryUtilities because it's better to use the strings as keys
+ // themselves rather than storing them separately.
/**
* Creates a new SpellModifiers object from the given NBTTagCompound. The NBTTagCompound should have 1 or more float
diff --git a/src/main/java/electroblob/wizardry/util/WizardryUtilities.java b/src/main/java/electroblob/wizardry/util/WizardryUtilities.java
index d8381f99..a00bfbc3 100644
--- a/src/main/java/electroblob/wizardry/util/WizardryUtilities.java
+++ b/src/main/java/electroblob/wizardry/util/WizardryUtilities.java
@@ -80,17 +80,15 @@ import net.minecraftforge.fml.relauncher.SideOnly;
*/
public final class WizardryUtilities {
- /**
- * Constant which is simply an array of the four armour slots. (Could've sworn this exists somewhere in vanilla, but
- * I can't find it anywhere...)
- */
+ /** Constant which is simply an array of the four armour slots. (Could've sworn this exists somewhere in vanilla,
+ * but I can't find it anywhere...) */
public static final EntityEquipmentSlot[] ARMOUR_SLOTS;
/** Changed to a constant in wizardry 2.1, since this is a lot more efficient. */
private static final DataParameter POWERED;
- static{
+ static {
// The list of slots needs to be mutable.
- List slots = new ArrayList(
+ List slots = new ArrayList<>(
Arrays.asList(EntityEquipmentSlot.values()));
slots.removeIf(slot -> slot.getSlotType() != Type.ARMOR);
ARMOUR_SLOTS = slots.toArray(new EntityEquipmentSlot[0]);
@@ -146,13 +144,11 @@ public final class WizardryUtilities {
/**
* Returns whether the block at the given coordinates is unbreakable in survival mode. In vanilla this is true for
- * bedrock and end portal frame, for example. This is a shortcut for
- * world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f. Not much of a shortcut any more, since block ids
- * have been phased out.
+ * bedrock and end portal frame, for example. This is a shortcut for:
+ * {@code world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f}
*/
public static boolean isBlockUnbreakable(World world, BlockPos pos){
- return world.isAirBlock(new BlockPos(pos)) ? false
- : world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f;
+ return !world.isAirBlock(new BlockPos(pos)) && world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f;
}
/**
@@ -160,11 +156,9 @@ public final class WizardryUtilities {
* Liquids and other blocks that cannot be built on top of do not count, but stuff like signs does. (Technically any
* block is allowed to be the floor according to the code, but seeing as it searches upwards and non-solid blocks
* usually need a supporting block, the floor is likely to always be solid).
- *
- * @param world
- * @param x The x coordinate to search in
- * @param y The y coordinate to search from
- * @param z The z coordinate to search in
+ *
+ * @param world The world to search in
+ * @param pos The coordinates to search from
* @param range The maximum distance from the given y coordinate to search.
* @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the
* floor as would be seen in the debug screen when the player is standing on it.
@@ -189,10 +183,8 @@ public final class WizardryUtilities {
* Finds the nearest floor level to the given y coord within the range specified at the given x and z coords. Only
* works if the block above the floor is actually air and the floor is solid or a liquid.
*
- * @param world
- * @param x The x coordinate to search in
- * @param y The y coordinate to search from
- * @param z The z coordinate to search in
+ * @param world The world to search in
+ * @param pos The coordinates to search from
* @param range The maximum distance from the given y coordinate to search.
* @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the
* floor as would be seen in the debug screen when the player is standing on it.
@@ -216,11 +208,9 @@ public final class WizardryUtilities {
/**
* Finds the nearest floor level to the given y coord within the range specified at the given x and z coords.
* Everything that is not air is treated as floor, even stuff that can't be walked on.
- *
- * @param world
- * @param x The x coordinate to search in
- * @param y The y coordinate to search from
- * @param z The z coordinate to search in
+ *
+ * @param world The world to search in
+ * @param pos The coordinates to search from
* @param range The maximum distance from the given y coordinate to search.
* @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the
* floor as would be seen in the debug screen when the player is standing on it.
@@ -300,7 +290,7 @@ public final class WizardryUtilities {
/**
* Gets the blockstate of the block the specified entity is standing on. Uses
- * {@link MathHelper#floor_double(double)} because casting to int will not return the correct coordinate when x or z
+ * {@link MathHelper#floor(double)} because casting to int will not return the correct coordinate when x or z
* is negative.
*/
public static IBlockState getBlockEntityIsStandingOn(Entity entity){
@@ -331,7 +321,7 @@ public final class WizardryUtilities {
* this does not exclude any entities; if any specific entities are to be excluded this must be checked when
* iterating through the list.
*
- * @see {@link WizardryUtilities#getEntitiesWithinRadius(double, double, double, double, World)}
+ * @see WizardryUtilities#getEntitiesWithinRadius(double, double, double, double, World)
* @param radius The search radius
* @param x The x coordinate to search around
* @param y The y coordinate to search around
@@ -396,12 +386,11 @@ public final class WizardryUtilities {
/**
* Returns the entity riding the given entity, or null if there is none. Allows for neater code now that entities
- * have a list of passengers, because it is necessary to check that the list is not null or empty first.
+ * have a list of passengers, because it is necessary to check that the list is not empty first.
*/
@Nullable
public static Entity getRider(Entity entity){
- return entity.getPassengers() != null && !entity.getPassengers().isEmpty() ? entity.getPassengers().get(0)
- : null;
+ return !entity.getPassengers().isEmpty() ? entity.getPassengers().get(0) : null;
}
/**
@@ -542,8 +531,8 @@ public final class WizardryUtilities {
/**
* Turns the given creeper into a charged creeper. In 1.10, this requires reflection since the DataManager keys are
- * private. (You could call {@link EntityCreeper#onStruckByLightning(...)} and then heal it and extinguish
- * it, but that's a bit awkward.)
+ * private. (You could call {@link EntityCreeper#onStruckByLightning(EntityLightningBolt)} and then heal it
+ * and extinguish it, but that's a bit awkward, and it'll trigger events and stuff...)
*/
// The reflection here only gets done once to initialise the POWERED field, so it's not a performance issue at all.
public static void chargeCreeper(EntityCreeper creeper){
@@ -578,7 +567,7 @@ public final class WizardryUtilities {
* Helper method which performs a ray trace for blocks and entities from an entity's eye position in the direction
* they are looking, over a specified range, using {@link WizardryUtilities#rayTrace(World, Vec3d, Vec3d, float,
* boolean, Class, Predicate)}. Aim assist is zero, the entity type is simply {@code Entity} (all entities), and the
- * filter removes the given entity and allows all others.
+ * filter removes the given entity and any dying entities and allows all others.
*
* @param world The world in which to perform the ray trace.
* @param entity The entity from which to perform the ray trace. The ray trace will start from this entity's eye