mirror of
https://github.com/ACGaming/Spackenmobs
synced 2024-05-19 11:54:25 +02:00
Jens dances and minor changes
This commit is contained in:
parent
75c2dfbd62
commit
373ab78823
|
@ -0,0 +1,87 @@
|
|||
package mod.acgaming.spackenmobs.entities;
|
||||
|
||||
import net.minecraft.block.BlockJukebox;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
// Thanks to Akrivus!
|
||||
public class EntityAIDance extends EntityAIBase
|
||||
{
|
||||
private final EntityJens jens;
|
||||
|
||||
private final int searchRadius;
|
||||
|
||||
private int lastDanceMoveTime = 0;
|
||||
|
||||
private int danceStage = 0;
|
||||
|
||||
public EntityAIDance(EntityJens jens, int searchRadius)
|
||||
{
|
||||
this.jens = jens;
|
||||
this.searchRadius = searchRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
this.lastDanceMoveTime = 0;
|
||||
this.danceStage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContinueExecuting()
|
||||
{
|
||||
return shouldExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
for (int x = -this.searchRadius; x <= this.searchRadius; x++)
|
||||
{
|
||||
for (int y = -2; y <= 2; y++)
|
||||
{
|
||||
for (int z = -this.searchRadius; z <= this.searchRadius; z++)
|
||||
{
|
||||
if (this.jens.world.getBlockState(this.jens.getPosition().add(x, y, z)).getBlock() == Blocks.JUKEBOX
|
||||
&& ((Boolean) this.jens.world.getBlockState(this.jens.getPosition().add(x, y, z)).getValue((IProperty) BlockJukebox.HAS_RECORD)).booleanValue())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
this.danceStage = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
if (this.lastDanceMoveTime <= 0)
|
||||
{
|
||||
switch (this.danceStage)
|
||||
{
|
||||
case 1:
|
||||
this.danceStage = this.jens.world.rand.nextBoolean() ? 1 : 2;
|
||||
this.jens.motionY = 0.42D;
|
||||
break;
|
||||
case 2:
|
||||
this.jens.setSneaking(true);
|
||||
this.jens.motionY = -3.0D;
|
||||
this.danceStage = 3;
|
||||
break;
|
||||
case 3:
|
||||
this.danceStage = this.jens.world.rand.nextBoolean() ? 1 : 2;
|
||||
this.jens.setSneaking(false);
|
||||
break;
|
||||
}
|
||||
this.lastDanceMoveTime = this.jens.world.rand.nextInt(10) + 5;
|
||||
}
|
||||
this.lastDanceMoveTime--;
|
||||
}
|
||||
}
|
|
@ -2,8 +2,6 @@ package mod.acgaming.spackenmobs.entities;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mod.acgaming.spackenmobs.misc.ModConfigs;
|
||||
|
@ -40,7 +38,6 @@ import net.minecraft.util.EnumParticleTypes;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.datafix.DataFixer;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -81,27 +78,10 @@ public class EntityJens extends EntityPig
|
|||
protected void applyEntityAttributes()
|
||||
{
|
||||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean boost()
|
||||
{
|
||||
if (this.boosting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.boosting = true;
|
||||
this.boostTime = 0;
|
||||
this.totalBoostTime = this.getRNG().nextInt(841) + 140;
|
||||
this.getDataManager().set(BOOST_TIME, Integer.valueOf(this.totalBoostTime));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSteered()
|
||||
{
|
||||
|
@ -162,13 +142,6 @@ public class EntityJens extends EntityPig
|
|||
return ModSoundEvents.ENTITY_JENS_AMBIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity getControllingPassenger()
|
||||
{
|
||||
return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getDeathSound()
|
||||
{
|
||||
|
@ -187,17 +160,12 @@ public class EntityJens extends EntityPig
|
|||
return ModLootTableList.ENTITIES_JENS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSaddled()
|
||||
{
|
||||
return this.dataManager.get(SADDLED).booleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initEntityAI()
|
||||
{
|
||||
this.tasks.addTask(0, new EntityAISwimming(this));
|
||||
this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
|
||||
this.tasks.addTask(2, new EntityAIDance(this, ModConfigs.Jens_search_distance));
|
||||
this.tasks.addTask(2, new EntityAIEatDroppedFish(this));
|
||||
this.tasks.addTask(3, new EntityAIMate(this, 1.0D));
|
||||
this.tasks.addTask(4, new EntityAITempt(this, 1.2D, false, TEMPTATION_ITEMS));
|
||||
|
@ -219,33 +187,6 @@ public class EntityJens extends EntityPig
|
|||
return FISH_ITEMS.contains(stack.getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDataManagerChange(DataParameter<?> key)
|
||||
{
|
||||
if (BOOST_TIME.equals(key) && this.world.isRemote)
|
||||
{
|
||||
this.boosting = true;
|
||||
this.boostTime = 0;
|
||||
this.totalBoostTime = this.dataManager.get(BOOST_TIME).intValue();
|
||||
}
|
||||
|
||||
super.notifyDataManagerChange(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource cause)
|
||||
{
|
||||
super.onDeath(cause);
|
||||
|
||||
if (!this.world.isRemote)
|
||||
{
|
||||
if (this.getSaddled())
|
||||
{
|
||||
this.dropItem(Items.SADDLE, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLivingUpdate()
|
||||
{
|
||||
|
@ -308,6 +249,7 @@ public class EntityJens extends EntityPig
|
|||
{
|
||||
itemstack.interactWithEntity(player, this, hand);
|
||||
this.setCustomNameTag("Reitbarer Jens");
|
||||
this.setAlwaysRenderNameTag(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -330,80 +272,6 @@ public class EntityJens extends EntityPig
|
|||
this.digestTime = compound.getInteger("DigestTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaddled(boolean saddled)
|
||||
{
|
||||
if (saddled)
|
||||
{
|
||||
this.dataManager.set(SADDLED, Boolean.valueOf(true));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dataManager.set(SADDLED, Boolean.valueOf(false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void travel(float strafe, float vertical, float forward)
|
||||
{
|
||||
Entity entity = this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
|
||||
|
||||
if (this.isBeingRidden() && this.canBeSteered())
|
||||
{
|
||||
this.rotationYaw = entity.rotationYaw;
|
||||
this.prevRotationYaw = this.rotationYaw;
|
||||
this.rotationPitch = entity.rotationPitch * 0.5F;
|
||||
this.setRotation(this.rotationYaw, this.rotationPitch);
|
||||
this.renderYawOffset = this.rotationYaw;
|
||||
this.rotationYawHead = this.rotationYaw;
|
||||
this.stepHeight = 1.0F;
|
||||
this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;
|
||||
|
||||
if (this.boosting && this.boostTime++ > this.totalBoostTime)
|
||||
{
|
||||
this.boosting = false;
|
||||
}
|
||||
|
||||
if (this.canPassengerSteer())
|
||||
{
|
||||
float f = (float) this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() * 0.225F;
|
||||
|
||||
if (this.boosting)
|
||||
{
|
||||
f += f * 1.15F * MathHelper.sin((float) this.boostTime / (float) this.totalBoostTime * (float) Math.PI);
|
||||
}
|
||||
|
||||
this.setAIMoveSpeed(f);
|
||||
super.travel(0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.motionX = 0.0D;
|
||||
this.motionY = 0.0D;
|
||||
this.motionZ = 0.0D;
|
||||
}
|
||||
|
||||
this.prevLimbSwingAmount = this.limbSwingAmount;
|
||||
double d1 = this.posX - this.prevPosX;
|
||||
double d0 = this.posZ - this.prevPosZ;
|
||||
float f1 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F;
|
||||
|
||||
if (f1 > 1.0F)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
}
|
||||
|
||||
this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
|
||||
this.limbSwing += this.limbSwingAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stepHeight = 0.5F;
|
||||
this.jumpMovementFactor = 0.02F;
|
||||
super.travel(strafe, vertical, forward);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound compound)
|
||||
{
|
||||
|
|
|
@ -2,15 +2,27 @@ package mod.acgaming.spackenmobs.events;
|
|||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import mod.acgaming.spackenmobs.entities.EntityDrachenlord;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
|
||||
public class TauntDrachenlordEvent
|
||||
{
|
||||
public static AxisAlignedBB getBoundingBox(double x, double y, double z, int hRadius, int vRadius)
|
||||
{
|
||||
return new AxisAlignedBB(x - hRadius, y - vRadius, z - hRadius, x + hRadius, y + vRadius, z + hRadius);
|
||||
}
|
||||
|
||||
public static void makeAngry(EntityPlayer player, EntityDrachenlord drache)
|
||||
{
|
||||
drache.attackEntityFrom(DamageSource.causePlayerDamage(player), 0);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyPress(KeyInputEvent event, EntityPlayer player, World world, int x, int y, int z)
|
||||
public void onKeyPress(KeyInputEvent event, EntityDrachenlord drache, EntityPlayer player)
|
||||
{
|
||||
final int aggroRange = 64;
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_J))
|
||||
|
|
|
@ -115,6 +115,6 @@ public class ModConfigs
|
|||
public static int WolfMZTE_max = 4;
|
||||
@Name("Time in seconds Jens needs to digest:")
|
||||
public static int Jens_digest_time = 120;
|
||||
@Name("Maximum distance in blocks Jens can search for fish:")
|
||||
public static double Jens_search_distance = 10.0;
|
||||
@Name("Maximum distance in blocks Jens can search:")
|
||||
public static int Jens_search_distance = 10;
|
||||
}
|
Loading…
Reference in a new issue