Split up and reorganise WizardryUtilities

This commit is contained in:
Electroblob77
2020-06-13 23:29:01 +01:00
parent 57e96458d5
commit 238b9d04bb
189 changed files with 1724 additions and 1731 deletions
@@ -369,7 +369,7 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity
Element element = this.getElement();
// Adds armour.
for(EntityEquipmentSlot slot : WizardryUtilities.ARMOUR_SLOTS){
for(EntityEquipmentSlot slot : InventoryUtils.ARMOUR_SLOTS){
this.setItemStackToSlot(slot, new ItemStack(WizardryItems.getArmour(element, slot)));
}
@@ -4,8 +4,8 @@ import electroblob.wizardry.client.DrawingUtils;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.BlockUtils;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
@@ -161,7 +161,7 @@ public class EntityPhoenix extends EntitySummonedCreature implements ISpellCaste
public void onLivingUpdate(){
// Makes the phoenix hover.
Integer floorLevel = WizardryUtilities.getNearestFloor(world, new BlockPos(this), 4);
Integer floorLevel = BlockUtils.getNearestFloor(world, new BlockPos(this), 4);
if(floorLevel == null || this.posY - floorLevel > 3){
this.motionY = -0.1;
@@ -1,7 +1,7 @@
package electroblob.wizardry.entity.living;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.util.WizardryUtilities.Operations;
import electroblob.wizardry.util.EntityUtils;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
@@ -73,7 +73,7 @@ public class EntitySkeletonMinion extends AbstractSkeleton implements ISummonedC
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata){
// Can't call super, so the code from the next level up (EntityLiving) had to be copied as well.
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
.applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, Operations.MULTIPLY_FLAT));
.applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, EntityUtils.Operations.MULTIPLY_FLAT));
if(this.rand.nextFloat() < 0.05F){
this.setLeftHanded(true);
@@ -1,9 +1,9 @@
package electroblob.wizardry.entity.living;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.WizardryUtilities.Operations;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
@@ -67,7 +67,7 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre
// Can't call super, so the code from the next level up (EntityLiving) had to be copied as well.
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
.applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, Operations.MULTIPLY_FLAT));
.applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, EntityUtils.Operations.MULTIPLY_FLAT));
if(this.rand.nextFloat() < 0.05F){
this.setLeftHanded(true);
@@ -3,9 +3,9 @@ package electroblob.wizardry.entity.living;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.item.ISpellCastingItem;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
@@ -124,7 +124,7 @@ public class EntitySpiritHorse extends EntityHorse {
private EntityLivingBase getOwner(){
// I think the DataManager stores any objects, so it now stores the UUID instead of its string representation.
Entity owner = WizardryUtilities.getEntityByUUID(world, this.getOwnerUniqueId());
Entity owner = EntityUtils.getEntityByUUID(world, this.getOwnerUniqueId());
if(owner instanceof EntityLivingBase){
return (EntityLivingBase)owner;
@@ -1,7 +1,7 @@
package electroblob.wizardry.entity.living;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.util.WizardryUtilities.Operations;
import electroblob.wizardry.util.EntityUtils;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
@@ -75,7 +75,7 @@ public class EntityWitherSkeletonMinion extends EntityWitherSkeleton implements
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata){
// Can't call super, so the code from the next level up (EntityLiving) had to be copied as well.
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
.applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, Operations.MULTIPLY_FLAT));
.applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, EntityUtils.Operations.MULTIPLY_FLAT));
if(this.rand.nextFloat() < 0.05F){
this.setLeftHanded(true);
@@ -469,7 +469,7 @@ public class EntityWizard extends EntityCreature implements INpc, IMerchant, ISp
if(!world.isRemote && !this.getCustomer().isCreative() && Wizardry.settings.discoveryMode){
// Sound and text only happen server-side, in survival, with discovery mode on
WizardryUtilities.playSoundAtPlayer(this.getCustomer(), WizardrySounds.MISC_DISCOVER_SPELL, 1.25f, 1);
EntityUtils.playSoundAtPlayer(this.getCustomer(), WizardrySounds.MISC_DISCOVER_SPELL, 1.25f, 1);
this.getCustomer().sendMessage(new TextComponentTranslation("spell.discover",
spell.getNameForTranslationFormatted()));
}
@@ -673,7 +673,7 @@ public class EntityWizard extends EntityCreature implements INpc, IMerchant, ISp
}else if(randomiser < 8){
return new ItemStack(WizardryItems.arcane_tome, 1, 1);
}else if(randomiser < 10){
EntityEquipmentSlot slot = WizardryUtilities.ARMOUR_SLOTS[rand.nextInt(WizardryUtilities.ARMOUR_SLOTS.length)];
EntityEquipmentSlot slot = InventoryUtils.ARMOUR_SLOTS[rand.nextInt(InventoryUtils.ARMOUR_SLOTS.length)];
if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0){
// This means it is more likely for armour sold to be of the same element as the wizard if the
// wizard has an element.
@@ -755,7 +755,7 @@ public class EntityWizard extends EntityCreature implements INpc, IMerchant, ISp
Element element = this.getElement();
// Adds armour.
for(EntityEquipmentSlot slot : WizardryUtilities.ARMOUR_SLOTS){
for(EntityEquipmentSlot slot : InventoryUtils.ARMOUR_SLOTS){
this.setItemStackToSlot(slot, new ItemStack(WizardryItems.getArmour(element, slot)));
}
@@ -888,7 +888,7 @@ public class EntityWizard extends EntityCreature implements INpc, IMerchant, ISp
// Makes wizards angry if a player breaks a block in their tower
if(!(event.getPlayer() instanceof FakePlayer)){
List<EntityWizard> wizards = WizardryUtilities.getEntitiesWithinRadius(64, event.getPos().getX(),
List<EntityWizard> wizards = EntityUtils.getEntitiesWithinRadius(64, event.getPos().getX(),
event.getPos().getY(), event.getPos().getZ(), event.getWorld(), EntityWizard.class);
if(!wizards.isEmpty()){
@@ -2,8 +2,8 @@ package electroblob.wizardry.entity.living;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.world.EnumDifficulty;
import javax.annotation.Nonnull;
@@ -91,6 +91,6 @@ public interface ISpellCaster {
* skeletons, which are: Easy - 10, Normal - 6, Hard - 2, Peaceful - 10 (rarely used).
*/
default int getAimingError(EnumDifficulty difficulty) {
return WizardryUtilities.getDefaultAimingError(difficulty);
return EntityUtils.getDefaultAimingError(difficulty);
}
}
@@ -118,7 +118,7 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData, IEntityOw
if(this instanceof Entity){ // Bit of a cheat but it saves having yet another method just to get the world
Entity entity = WizardryUtilities.getEntityByUUID(((Entity)this).world, getOwnerId());
Entity entity = EntityUtils.getEntityByUUID(((Entity)this).world, getOwnerId());
if(entity != null && !(entity instanceof EntityLivingBase)){ // Should never happen
Wizardry.logger.warn("{} has a non-living owner!", this);
@@ -395,7 +395,7 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData, IEntityOw
// no summoner.
if(DamageSafetyChecker.attackEntitySafely(event.getEntity(), newSource, event.getAmount(), event.getSource(), false)){
// Uses event.getSource().getTrueSource() as this means the target is knocked back from the minion
WizardryUtilities.applyStandardKnockback(event.getSource().getTrueSource(), event.getEntityLiving());
EntityUtils.applyStandardKnockback(event.getSource().getTrueSource(), event.getEntityLiving());
((ISummonedCreature)event.getSource().getTrueSource()).onSuccessfulAttack(event.getEntityLiving());
// If the target revenge-targeted the summoner, make it revenge-target the minion instead
// (if it didn't revenge-target, do nothing)