That's one heck of a commit you've got there...

I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
Electroblob77
2019-08-18 00:04:18 +01:00
parent 2680d02304
commit f37812be3e
1564 changed files with 47652 additions and 12984 deletions
@@ -1,12 +1,7 @@
package electroblob.wizardry.entity.living;
import java.lang.ref.WeakReference;
import java.util.Calendar;
import java.util.UUID;
import javax.annotation.Nullable;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.util.WizardryUtilities.Operations;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
@@ -14,37 +9,39 @@ import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.AbstractSkeleton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.*;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCreature {
import javax.annotation.Nullable;
import java.util.Calendar;
import java.util.UUID;
// Extends AbstractSkeleton because EntitySkeleton drops skulls, which we don't want
public class EntitySkeletonMinion extends AbstractSkeleton implements ISummonedCreature {
// Field implementations
private int lifetime = 600;
private WeakReference<EntityLivingBase> casterReference;
private int lifetime = -1;
private UUID casterUUID;
// Setter + getter implementations
@Override public int getLifetime(){ return lifetime; }
@Override public void setLifetime(int lifetime){ this.lifetime = lifetime; }
@Override public WeakReference<EntityLivingBase> getCasterReference(){ return casterReference; }
@Override public void setCasterReference(WeakReference<EntityLivingBase> reference){ casterReference = reference; }
@Override public UUID getCasterUUID(){ return casterUUID; }
@Override public void setCasterUUID(UUID uuid){ this.casterUUID = uuid; }
@Override public UUID getOwnerId(){ return casterUUID; }
@Override public void setOwnerId(UUID uuid){ this.casterUUID = uuid; }
/** Creates a new skeleton minion in the given world. */
public EntitySkeletonMinion(World world){
@@ -55,13 +52,13 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre
// EntitySkeleton overrides
// This particular override is pretty standard: let the superclass handle basic AI like swimming, but replace its
// targeting system with one that targets hostile mobs and takes the ADS into account.
// targeting system with one that targets hostile mobs and takes the AllyDesignationSystem into account.
@Override
protected void initEntityAI(){
super.initEntityAI();
this.targetTasks.taskEntries.clear();
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityLivingBase>(this, EntityLivingBase.class,
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityLivingBase.class,
0, false, true, this.getTargetSelector()));
}
@@ -76,7 +73,7 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre
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, 1));
.applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, Operations.MULTIPLY_FLAT));
if(this.rand.nextFloat() < 0.05F){
this.setLeftHanded(true);
@@ -98,6 +95,12 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre
return livingdata;
}
// Since we're extending AbstractSkeleton these aren't set by the superclass like normal
@Override protected SoundEvent getAmbientSound(){ return SoundEvents.ENTITY_SKELETON_AMBIENT; }
@Override protected SoundEvent getHurtSound(DamageSource source){ return SoundEvents.ENTITY_SKELETON_HURT; }
@Override protected SoundEvent getDeathSound(){ return SoundEvents.ENTITY_SKELETON_DEATH; }
@Override protected SoundEvent getStepSound(){ return SoundEvents.ENTITY_SKELETON_STEP; }
// Implementations
@Override
@@ -161,8 +164,16 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre
@Override protected Item getDropItem(){ return null; }
@Override protected ResourceLocation getLootTable(){ return null; }
@Override public boolean canPickUpLoot(){ return false; }
// This vanilla method has nothing to do with the custom despawn() method.
@Override protected boolean canDespawn(){ return false; }
@Override protected boolean canDespawn(){
return getCaster() == null && getOwnerId() == null;
}
@Override
public boolean getCanSpawnHere(){
return this.world.getDifficulty() != EnumDifficulty.PEACEFUL;
}
@Override
public boolean canAttackClass(Class<? extends EntityLivingBase> entityType){
@@ -183,6 +194,6 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre
@Override
public boolean hasCustomName(){
// If this returns true, the renderer will show the nameplate when looking directly at the entity
return Wizardry.settings.showSummonedCreatureNames && getCaster() != null;
return Wizardry.settings.summonedCreatureNames && getCaster() != null;
}
}