Skip to content

Commit

Permalink
1.8.9 (1.3.3) Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Silentine committed Apr 3, 2016
1 parent ac41052 commit 5be5e54
Show file tree
Hide file tree
Showing 71 changed files with 536 additions and 143 deletions.
197 changes: 197 additions & 0 deletions src/main/java/gaia/entity/EntityMobAssist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package gaia.entity;

import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.IMob;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;

/**
* This is a direct copy of EntityMob which is used by assist mobs to not trigger the warning message when using a bed.
* No additional changes have been aside from the class name and this message.
*/
public abstract class EntityMobAssist extends EntityCreature implements IMob
{
public EntityMobAssist(World worldIn)
{
super(worldIn);
this.experienceValue = 5;
}

/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
this.updateArmSwingProgress();
float f = this.getBrightness(1.0F);

if (f > 0.5F)
{
this.entityAge += 2;
}

super.onLivingUpdate();
}

/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();

if (!this.worldObj.isRemote && this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)
{
this.setDead();
}
}

protected String getSwimSound()
{
return "game.hostile.swim";
}

protected String getSplashSound()
{
return "game.hostile.swim.splash";
}

/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isEntityInvulnerable(source))
{
return false;
}
else if (super.attackEntityFrom(source, amount))
{
Entity entity = source.getEntity();
return this.riddenByEntity != entity && this.ridingEntity != entity ? true : true;
}
else
{
return false;
}
}

/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "game.hostile.hurt";
}

/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "game.hostile.die";
}

protected String getFallSoundString(int damageValue)
{
return damageValue > 4 ? "game.hostile.hurt.fall.big" : "game.hostile.hurt.fall.small";
}

public boolean attackEntityAsMob(Entity entityIn)
{
float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
int i = 0;

if (entityIn instanceof EntityLivingBase)
{
f += EnchantmentHelper.func_152377_a(this.getHeldItem(), ((EntityLivingBase)entityIn).getCreatureAttribute());
i += EnchantmentHelper.getKnockbackModifier(this);
}

boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

if (flag)
{
if (i > 0)
{
entityIn.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F));
this.motionX *= 0.6D;
this.motionZ *= 0.6D;
}

int j = EnchantmentHelper.getFireAspectModifier(this);

if (j > 0)
{
entityIn.setFire(j * 4);
}

this.applyEnchantments(this, entityIn);
}

return flag;
}

public float getBlockPathWeight(BlockPos pos)
{
return 0.5F - this.worldObj.getLightBrightness(pos);
}

/**
* Checks to make sure the light is not too bright where the mob is spawning
*/
protected boolean isValidLightLevel()
{
BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);

if (this.worldObj.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32))
{
return false;
}
else
{
int i = this.worldObj.getLightFromNeighbors(blockpos);

if (this.worldObj.isThundering())
{
int j = this.worldObj.getSkylightSubtracted();
this.worldObj.setSkylightSubtracted(10);
i = this.worldObj.getLightFromNeighbors(blockpos);
this.worldObj.setSkylightSubtracted(j);
}

return i <= this.rand.nextInt(8);
}
}

/**
* Checks if the entity's current position is a valid location to spawn this entity.
*/
public boolean getCanSpawnHere()
{
return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && this.isValidLightLevel() && super.getCanSpawnHere();
}

protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}

/**
* Entity won't drop items or experience points if this returns false
*/
protected boolean canDropLoot()
{
return true;
}
}
55 changes: 55 additions & 0 deletions src/main/java/gaia/entity/EntityMobAssistBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package gaia.entity;

import gaia.ConfigGaia;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

//This is a direct copy of EntityMobBase
public abstract class EntityMobAssistBase extends EntityMobAssist {

public EntityMobAssistBase(World par1World) {
super(par1World);
}

public boolean attackEntityAsMob(Entity par1Entity) {
if (super.attackEntityAsMob(par1Entity)) {
if (ConfigGaia.BaseDamage) {
((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(Potion.harm.id, 2, 0));
}
return true;
} else {
return false;
}
}

public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1iEntityLivingData) {
return null;
}

/**
* Used to adjust the motionY when a mob is hit.
*/
public void knockBack(Entity par1Entity, float par2, double par3, double par5, double par6) {
if (this.rand.nextDouble() >= this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) {
this.isAirBorne = true;
float f1 = MathHelper.sqrt_double(par3 * par3 + par5 * par5);
float f2 = 0.4F;
this.motionX /= 2.0D;
this.motionY /= 2.0D;
this.motionZ /= 2.0D;
this.motionX -= par3 / (double)f1 * (double)f2;
this.motionY += (double)f2;
this.motionZ -= par5 / (double)f1 * (double)f2;
if (this.motionY > par6) {
this.motionY = par6;
}
}
}
}
46 changes: 46 additions & 0 deletions src/main/java/gaia/entity/EntityMobAssistDay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package gaia.entity;

import java.util.Set;

import com.google.common.collect.Sets;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

//This is a direct copy of EntityMobDay
public abstract class EntityMobAssistDay extends EntityMobAssistBase {

static Set<Block> spawnBlocks = Sets.newHashSet(new Block[] {
Blocks.grass,
Blocks.dirt,
Blocks.gravel,
Blocks.sand,
Blocks.snow_layer
});

public EntityMobAssistDay(World par1World) {
super(par1World);
}

public boolean getCanSpawnHere() {
if (this.worldObj.isDaytime()) {
float f = this.getBrightness(1.0F);
if (f > 0.5F && this.worldObj.canSeeSky(this.getPosition())) {

int i = MathHelper.floor_double(this.posX);
int j = MathHelper.floor_double(this.getEntityBoundingBox().minY);
int k = MathHelper.floor_double(this.posZ);
BlockPos blockpos = new BlockPos(i, j, k);
Block var1 = this.worldObj.getBlockState(blockpos.down()).getBlock();

return spawnBlocks.contains(var1)&& !this.worldObj.isAnyLiquid(this.getEntityBoundingBox());
}
}

return false;
}
}
3 changes: 3 additions & 0 deletions src/main/java/gaia/entity/EntityMobBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1iEntityLivingData)
return null;
}

/**
* Used to adjust the motionY when a mob is hit.
*/
public void knockBack(Entity par1Entity, float par2, double par3, double par5, double par6) {
if (this.rand.nextDouble() >= this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) {
this.isAirBorne = true;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/gaia/entity/EntityMobDay.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public EntityMobDay(World par1World) {
}

public boolean getCanSpawnHere() {

if (this.worldObj.isDaytime()) {
float f = this.getBrightness(1.0F);
if (f > 0.5F && this.worldObj.canSeeSky(this.getPosition())) {

int i = MathHelper.floor_double(this.posX);
int j = MathHelper.floor_double(this.getEntityBoundingBox().minY);
int k = MathHelper.floor_double(this.posZ);
int j = MathHelper.floor_double(this.getEntityBoundingBox().minY);
int k = MathHelper.floor_double(this.posZ);
BlockPos blockpos = new BlockPos(i, j, k);
Block var1 = this.worldObj.getBlockState(blockpos.down()).getBlock();

return spawnBlocks.contains(var1)&& !this.worldObj.isAnyLiquid(this.getEntityBoundingBox());
}}
}
}

return false;
}
}

/** Legacy code below this point **/
/*
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/gaia/entity/monster/EntityGaiaAnubis.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,7 @@ protected void dropFewItems(boolean par1, int par2) {
this.dropItem(var6, 1);
}
}

if (par1 && (this.rand.nextInt(4) == 0 || this.rand.nextInt(1 + par2) > 0)) {
this.dropItem(GaiaItem.FoodNetherWart, 1);
}


//Shards
int var11 = this.rand.nextInt(3) + 1;

Expand All @@ -192,13 +188,6 @@ protected void dropFewItems(boolean par1, int par2) {
if (par1 && (this.rand.nextInt(4) == 0 || this.rand.nextInt(1) > 0)) {
this.entityDropItem(new ItemStack(GaiaItem.Shard, 1, 3), 0.0F);
}

//MiscShards
int var13 = this.rand.nextInt(2) + 1;

for (int var14 = 0; var14 < var13; ++var14) {
this.entityDropItem(new ItemStack(GaiaItem.ShardMisc, 1, 1), 0.0F);
}
}

protected void addRandomDrop() {
Expand Down
Loading

0 comments on commit 5be5e54

Please sign in to comment.