Backport swet changes.

This commit is contained in:
bconlon 2020-12-30 22:45:17 -08:00
parent 6b1d56bc79
commit fece29925c
4 changed files with 496 additions and 477 deletions

View File

@ -7,6 +7,7 @@ import net.minecraft.client.model.ModelSlime;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@ -17,22 +18,29 @@ public class SwetRenderer extends RenderLiving {
private static final ResourceLocation TEXTURE_GOLDEN = Aether.locate("textures/entities/swet/swet_golden.png");
public SwetRenderer() {
public SwetRenderer()
{
super(new ModelSlime(16), 0.3F);
this.setRenderPassModel(new ModelSlime(0));
}
protected int renderEyeGlow(EntitySwet entity, int pass, float particleTicks) {
if (entity.isInvisible()) {
protected int shouldRenderPass(EntitySwet entity, int pass, float particleTicks)
{
if (entity.isInvisible())
{
return 0;
} else if (pass == 0) {
}
else if (pass == 0)
{
this.setRenderPassModel(new ModelSlime(0));
GL11.glEnable(GL11.GL_NORMALIZE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
return 1;
} else {
if (pass == 1) {
}
else
{
if (pass == 1)
{
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@ -41,44 +49,35 @@ public class SwetRenderer extends RenderLiving {
}
}
protected void setupAnimation(EntitySwet swet, float f) {
float f2 = 1.0F;
float f1 = 1.0F;
float f3 = 1.5F;
protected void preRenderCallback(EntitySwet swet, float f)
{
float f1 = swet.swetHeight; //height
float f2 = swet.swetWidth; //width
float f3 = 1.5F; //scale
if (!swet.onGround && swet.worldObj.isRemote) {
if (swet.motionY > 0.85D) {
f1 = 1.425F;
f2 = 0.575F;
} else if (swet.motionY < -0.85D) {
f1 = 0.575F;
f2 = 1.425F;
} else {
float f4 = (float) swet.motionY * 0.5F;
f1 += f4;
f2 -= f4;
}
}
if (swet.riddenByEntity != null) {
f3 = 1.5F + (swet.riddenByEntity.width + swet.riddenByEntity.height) * 2.0F;
if(swet.riddenByEntity != null)
{
f3 = 1.5F + (swet.riddenByEntity.width + swet.riddenByEntity.height) * 0.75F;
}
GL11.glScalef(f2 * f3, f1 * f3, f2 * f3);
}
@Override
protected int shouldRenderPass(EntityLivingBase entity, int pass, float particleTicks) {
return this.renderEyeGlow((EntitySwet) entity, pass, particleTicks);
protected void preRenderCallback(EntityLivingBase p_77041_1_, float p_77041_2_)
{
this.preRenderCallback((EntitySwet)p_77041_1_, p_77041_2_);
}
@Override
protected void preRenderCallback(EntityLivingBase swet, float f) {
this.setupAnimation((EntitySwet) swet, f);
protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_)
{
return this.shouldRenderPass((EntitySwet)p_77032_1_, p_77032_2_, p_77032_3_);
}
@Override
public ResourceLocation getEntityTexture(Entity swet) {
return ((EntitySwet) swet).getSwetType() == EnumSwetType.BLUE ? TEXTURE_BLUE : TEXTURE_GOLDEN;
public ResourceLocation getEntityTexture(Entity swet)
{
return ((EntitySwet) swet).getType() == EnumSwetType.BLUE ? TEXTURE_BLUE : TEXTURE_GOLDEN;
}
}

View File

@ -1,154 +1,126 @@
package com.gildedgames.the_aether.entities.passive.mountable;
import java.util.List;
import com.gildedgames.the_aether.api.AetherAPI;
import com.gildedgames.the_aether.api.player.IPlayerAether;
import com.gildedgames.the_aether.blocks.BlocksAether;
import com.gildedgames.the_aether.entities.hostile.swet.EnumSwetType;
import net.minecraft.command.IEntitySelector;
import com.gildedgames.the_aether.items.ItemsAether;
import com.gildedgames.the_aether.network.AetherNetwork;
import com.gildedgames.the_aether.network.packets.PacketSwetJump;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import com.gildedgames.the_aether.blocks.BlocksAether;
import com.gildedgames.the_aether.entities.util.EntityMountable;
import com.gildedgames.the_aether.items.ItemsAether;
import com.gildedgames.the_aether.player.PlayerAether;
public class EntitySwet extends EntityMountable {
public class EntitySwet extends EntityMountable
{
public boolean wasOnGround;
public boolean midJump;
public int jumpTimer;
private int slimeJumpDelay = 0;
public float swetHeight;
public float swetWidth;
public int ticker;
private int jumpDelay;
public int flutter;
private int jumps = 0;
private float chosenDegrees;
public int hops;
public boolean kickoff;
public EntitySwet(World world) {
public EntitySwet(World world)
{
super(world);
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(25);
this.setHealth(25);
this.setSwetType(this.rand.nextInt(2));
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.5F);
this.setSize(0.8F, 0.8F);
this.setPosition(this.posX, this.posY, this.posZ);
this.hops = 0;
this.flutter = 0;
this.ticker = 0;
this.slimeJumpDelay = this.rand.nextInt(20) + 10;
this.swetHeight = 1.0F;
this.swetWidth = 1.0F;
}
@Override
public void entityInit() {
super.entityInit();
this.dataWatcher.addObject(20, new Byte((byte) 0));
this.dataWatcher.addObject(21, new Byte((byte) this.rand.nextInt(EnumSwetType.values().length)));
}
@Override
public void updateRidden() {
super.updateRidden();
if (this.riddenByEntity != null && this.kickoff) {
this.riddenByEntity.mountEntity(null);
this.kickoff = false;
}
}
@Override
public boolean getCanSpawnHere()
public void entityInit()
{
return this.rand.nextInt(10) == 0 && super.getCanSpawnHere();
super.entityInit();
this.dataWatcher.addObject(21, (byte) this.rand.nextInt(EnumSwetType.values().length));
}
@Override
public void onUpdate() {
super.onUpdate();
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.5D);
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(25.0D);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(25.0D);
this.setHealth(25.0F);
}
if (this.getAttackTarget() != null) {
for (int i = 0; i < 3; i++) {
double d = (float) this.posX + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.3F;
double d1 = (float) this.posY + this.height;
double d2 = (float) this.posZ + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.3F;
@Override
protected void collideWithEntity(Entity entityIn)
{
super.collideWithEntity(entityIn);
this.worldObj.spawnParticle("splash", d, d1 - 0.25D, d2, 0.0D, 0.0D, 0.0D);
}
}
if (!this.hasPrey())
{
if (entityIn instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entityIn;
if (this.riddenByEntity == null && !this.isFriendly()) {
List<?> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.5D, 0.75D, 0.5D), new IEntitySelector() {
@Override
public boolean isEntityApplicable(Entity entity) {
return !(entity instanceof EntitySwet) && entity instanceof EntityLivingBase && entity.ridingEntity == null;
if (this.getAttackTarget() != null)
{
if (this.getAttackTarget() == player)
{
if (!player.capabilities.isCreativeMode)
{
this.capturePrey((EntityPlayer) entityIn);
}
}
}
});
for (int j = 0; j < list.size() && this.riddenByEntity == null; ++j) {
EntityLivingBase entity = (EntityLivingBase) list.get(j);
this.capturePrey(entity);
}
}
if (this.handleWaterMovement()) {
this.dissolve();
}
}
@Override
protected boolean canDespawn() {
return !this.isFriendly();
}
@Override
public void fall(float distance) {
if (!this.isFriendly()) {
super.fall(distance);
if (this.hops >= 3 && this.getHealth() >= 0) {
this.dissolve();
}
}
}
@Override
public void knockBack(Entity entity, float damage, double distanceX, double distanceZ) {
if (this.riddenByEntity != entity) {
super.knockBack(entity, damage, distanceX, distanceZ);
public boolean interact(EntityPlayer player)
{
if (!this.worldObj.isRemote)
{
if (!this.hasPrey() && this.isPlayerFriendly(player))
{
this.capturePrey(player);
}
}
return true;
}
@Override
public void onEntityUpdate()
{
super.onEntityUpdate();
if (this.getAttackTarget() instanceof EntityPlayer)
{
if (this.isPlayerFriendly((EntityPlayer) this.getAttackTarget()) || this.isFriendly())
{
this.setAttackTarget(null);
}
}
}
public void dissolve() {
for (int i = 0; i < 50; i++) {
float f = this.rand.nextFloat() * 3.141593F * 2.0F;
float f1 = this.rand.nextFloat() * 0.5F + 0.25F;
float f2 = MathHelper.sin(f) * f1;
float f3 = MathHelper.cos(f) * f1;
this.worldObj.spawnParticle("splash", this.posX + (double) f2, this.boundingBox.minY + 1.25D, this.posZ + (double) f3, (double) f2 * 1.5D + this.motionX, 4D, (double) f3 * 1.5D + this.motionZ);
}
this.setDead();
}
public void capturePrey(Entity entity) {
this.splorch();
public void capturePrey(EntityPlayer entity)
{
this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.attack", 0.5F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F, false);
this.prevPosX = this.posX = entity.posX;
this.prevPosY = this.posY = entity.posY + 0.0099999997764825821D;
this.prevPosY = this.posY = entity.posY + 0.01;
this.prevPosZ = this.posZ = entity.posZ;
this.prevRotationYaw = this.rotationYaw = entity.rotationYaw;
this.prevRotationPitch = this.rotationPitch = entity.rotationPitch;
@ -164,405 +136,396 @@ public class EntitySwet extends EntityMountable {
this.rotationYaw = this.rand.nextFloat() * 360F;
}
@Override
public boolean attackEntityFrom(DamageSource damageSource, float i) {
Entity entity = damageSource.getEntity();
if (this.hops == 3 && entity == null && this.getHealth() > 1) {
this.setHealth(1);
public void onUpdate()
{
if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL)
{
this.isDead = true;
}
boolean flag = super.attackEntityFrom(damageSource, i);
if (this.handleWaterMovement())
{
this.dissolveSwet();
}
if (flag && this.riddenByEntity != null && (this.riddenByEntity instanceof EntityLivingBase)) {
EntityLivingBase rider = (EntityLivingBase) this.riddenByEntity;
super.onUpdate();
if (entity != null && rider == entity) {
if (this.rand.nextInt(3) == 0) {
this.kickoff = true;
}
} else {
rider.attackEntityFrom(DamageSource.causeMobDamage(this), i);
if (!this.hasPrey())
{
for (int i = 0; i < 5; i++)
{
double d = (float) this.posX + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.3F;
double d1 = (float) this.posY + this.height;
double d2 = (float) this.posZ + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.3F;
this.worldObj.spawnParticle("splash", d, d1 - 0.25D, d2, 0.0D, 0.0D, 0.0D);
}
}
if (this.getHealth() <= 0) {
this.kickoff = true;
if (this.onGround && !this.wasOnGround)
{
this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.slime.small", 0.5F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F, false);
}
if (!this.worldObj.isRemote)
{
this.midJump = !this.onGround;
AetherNetwork.sendToAll(new PacketSwetJump(this.getEntityId(), !this.onGround));
}
if (this.worldObj.isRemote)
{
if (this.midJump)
{
this.jumpTimer++;
}
else
{
this.jumpTimer = 0;
}
if (this.onGround)
{
this.swetHeight = this.swetHeight < 1.0F ? this.swetHeight += 0.25F : 1.0F;
this.swetWidth = this.swetWidth > 1.0F ? this.swetWidth -= 0.25F : 1.0F;
}
else
{
this.swetHeight = 1.425F;
this.swetWidth = 0.875F;
if (this.getJumpTimer() > 3)
{
float scale = Math.min(this.getJumpTimer(), 10);
this.swetHeight -= 0.05F * scale;
this.swetWidth += 0.05F * scale;
}
}
}
if (flag && this.getHealth() <= 0) {
this.dissolve();
} else if (flag && (entity instanceof EntityLivingBase)) {
EntityLivingBase entityliving = (EntityLivingBase) entity;
if (entityliving.getHealth() > 0 && (this.riddenByEntity == null || this.riddenByEntity != null && entityliving != this.riddenByEntity)) {
this.setAttackTarget((EntityLivingBase) entity);
this.kickoff = true;
}
}
if (this.isFriendly()) {
this.setAttackTarget(null);
}
return flag;
this.wasOnGround = this.onGround;
}
@Override
public void updateEntityActionState() {
super.updateEntityActionState();
this.entityAge++;
public void moveEntityWithHeading(float strafe, float forward)
{
if (this.hasPrey())
{
if (this.isFriendly())
{
EntityPlayer rider = (EntityPlayer) this.riddenByEntity;
IPlayerAether aetherRider = AetherAPI.get(rider);
if (this.isFriendly() && this.riddenByEntity != null) {
return;
}
if (this.getAttackTarget() == null && this.riddenByEntity == null && this.getHealth() > 0) {
if (this.onGround && this.slimeJumpDelay-- <= 0) {
this.slimeJumpDelay = this.getJumpDelay();
this.isJumping = true;
this.motionY = 0.34999999403953552D;
this.playSound("mob.slime.small", 1.0F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F);
this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F;
this.moveForward = 16.0F;
} else {
this.isJumping = false;
if (this.onGround) {
this.moveStrafing = this.moveForward = 0.0F;
if (aetherRider.isJumping() && this.onGround)
{
this.jump();
this.onGround = false;
this.motionY = 1.0f;
}
}
}
if (!this.onGround && this.isJumping) {
super.moveEntityWithHeading(strafe, forward);
}
@Override
protected void updateEntityActionState()
{
this.despawnEntity();
EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 25.0D);
if (entityplayer != null)
{
if (entityplayer.isEntityAlive() && !entityplayer.capabilities.disableDamage)
{
if (!this.isPlayerFriendly(entityplayer) && !this.isFriendly() && !this.hasPrey())
{
this.setAttackTarget(entityplayer);
this.faceEntity(entityplayer, 10.0F, 20.0F);
}
}
}
if (this.onGround && this.jumpDelay-- <= 0)
{
this.jumpDelay = this.getJumpDelay();
if (entityplayer != null)
{
this.jumpDelay /= 3;
}
this.isJumping = true;
this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F);
this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F;
this.moveForward = 1.0F;
}
else
{
this.isJumping = false;
}
if (this.getAttackTarget() != null && this.riddenByEntity == null && this.getHealth() > 0) {
float f = MathHelper.wrapAngleTo180_float(20.0F);
if (f > 20.0F) {
f = 10.0F;
}
if (f < -20.0F) {
f = -210.0F;
}
this.rotationYaw = f + this.getAttackTarget().rotationYaw + 214.0F;
//this.faceEntity(this.getAttackTarget(), 10F, 20F);
if (this.onGround && this.slimeJumpDelay-- <= 0) {
this.slimeJumpDelay = this.getJumpDelay();
this.isJumping = true;
this.motionY = 0.34999999403953552D;
this.playSound("mob.slime.small", 1.0F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F);
this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F;
this.moveForward = 16.0F;
} else {
this.isJumping = false;
if (this.onGround) {
this.moveStrafing = this.moveForward = 0.0F;
}
if (this.onGround)
{
this.moveStrafing = this.moveForward = 0.0F;
}
}
if (this.getAttackTarget() != null && this.getAttackTarget().isDead) {
this.setAttackTarget(null);
}
if (this.hasPrey() && this.riddenByEntity instanceof EntityPlayer && !this.isPlayerFriendly((EntityPlayer) this.riddenByEntity))
{
if (this.jumps <= 3)
{
if (this.onGround)
{
this.playSound("mob.slime.small", 1.0F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F);
if (!this.onGround && this.motionY < 0.05000000074505806D && this.flutter > 0) {
this.motionY += 0.070000000298023224D;
this.flutter--;
}
if (this.ticker < 4) {
this.ticker++;
} else {
if (this.onGround && this.riddenByEntity == null && this.hops != 0 && this.hops != 3) {
this.hops = 0;
}
this.chosenDegrees = (float)this.rand.nextInt(360);
if (this.getAttackTarget() == null && this.riddenByEntity == null) {
Entity entity = this.getPrey();
if (entity != null) {
this.setAttackTarget((EntityLivingBase) entity);
}
} else if (this.getAttackTarget() != null && this.riddenByEntity == null) {
if (this.getDistanceToEntity(this.getAttackTarget()) <= 9F) {
if (this.onGround && this.canEntityBeSeen(this.getAttackTarget())) {
this.splotch();
this.flutter = 10;
this.isJumping = true;
this.moveForward = 16.0F;
this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F;
this.rotationYaw += 5F * (this.rand.nextFloat() - this.rand.nextFloat());
if (this.jumps == 0)
{
this.motionY += 0.64999999403953552D;
}
else if (this.jumps == 1)
{
this.motionY += 0.74999998807907104D;
}
else if (this.jumps == 2)
{
this.motionY += 1.55D;
}
else
{
if (this.riddenByEntity instanceof EntityPlayer)
{
((EntityPlayer) this.riddenByEntity).dismountEntity(this);
}
this.dissolveSwet();
}
if (!this.midJump)
{
this.jumps++;
}
} else {
this.setAttackTarget(null);
this.isJumping = false;
this.moveStrafing = this.moveForward = 0.0F;
}
} else if (this.riddenByEntity != null && this.riddenByEntity != null && this.onGround) {
if (this.hops == 0) {
this.splotch();
this.onGround = false;
this.motionY = 0.34999999403953552D;
this.moveForward = 0.8F;
this.hops = 1;
this.flutter = 5;
this.rotationYaw += 20F * (this.rand.nextFloat() - this.rand.nextFloat());
} else if (this.hops == 1) {
this.splotch();
this.onGround = false;
this.motionY = 0.44999998807907104D;
this.moveForward = 0.9F;
this.hops = 2;
this.flutter = 5;
this.rotationYaw += 20F * (this.rand.nextFloat() - this.rand.nextFloat());
} else if (this.hops == 2) {
this.splotch();
this.onGround = false;
this.motionY = 1.25D;
this.moveForward = 1.25F;
this.hops = 3;
this.flutter = 5;
this.rotationYaw += 20F * (this.rand.nextFloat() - this.rand.nextFloat());
if (!this.wasOnGround)
{
if (this.getJumpTimer() < 6)
{
if (this.jumps == 1)
{
this.moveXY(0.0F, 0.2F, this.chosenDegrees);
}
else if (this.jumps == 2)
{
this.moveXY(0.0F, 0.3F, this.chosenDegrees);
}
else if (this.jumps == 3)
{
this.moveXY(0.0F, 0.6F, this.chosenDegrees);
}
}
}
}
this.ticker = 0;
}
if (this.onGround && this.hops >= 3) {
this.dissolve();
}
}
protected int getJumpDelay() {
return this.rand.nextInt(20) + 10;
public void moveXY(float strafe, float forward, float rotation)
{
float f = strafe * strafe + forward * forward;
f = MathHelper.sqrt_float(f);
if (f < 1.0F) f = 1.0F;
strafe = strafe * f;
forward = forward * f;
float f1 = MathHelper.sin(rotation * 0.017453292F);
float f2 = MathHelper.cos(rotation * 0.017453292F);
this.motionX += (strafe * f2 - forward * f1);
this.motionZ += (forward * f2 + strafe * f1);
}
public void moveEntityWithHeading(float par1, float par2) {
EntityPlayer rider = this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer ? (EntityPlayer) this.riddenByEntity : null;
if (rider != null) {
PlayerAether aetherRider = PlayerAether.get(rider);
if (aetherRider == null) {
return;
}
this.setFriendly(aetherRider.getAccessoryInventory().wearingAccessory(new ItemStack(ItemsAether.swet_cape)) ? true : false);
if (this.isFriendly()) {
this.prevRotationYaw = this.rotationYaw = rider.rotationYaw;
this.rotationPitch = rider.rotationPitch * 0.5F;
this.setRotation(this.rotationYaw, this.rotationPitch);
this.rotationYawHead = this.renderYawOffset = this.rotationYaw;
if (this.onGround && this.slimeJumpDelay-- <= 0) {
par1 = rider.moveStrafing * 2F;
par2 = rider.moveForward * 2;
if (par1 != 0.0f || par2 != 0.0f) {
this.jump();
this.onGround = false;
this.motionY = 0.7f;
this.slimeJumpDelay = this.rand.nextInt(4);
}
if (aetherRider.isJumping()) {
this.jump();
this.onGround = false;
this.motionY = 1.0f;
this.slimeJumpDelay = this.rand.nextInt(15);
}
int rotate = MathHelper.floor_double(rider.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
double x = Math.cos(this.getLookVec().xCoord);
double z = Math.cos(this.getLookVec().zCoord);
if (par2 > 0.0F) {
this.motionX = this.getLookVec().xCoord / 2;
this.motionZ = this.getLookVec().zCoord / 2;
}
if (par2 < 0.0F) {
this.motionX = -this.getLookVec().xCoord / 2;
this.motionZ = -this.getLookVec().zCoord / 2;
}
if (par1 > 0.0F) {
if (rotate <= 1) {
this.motionX = x / 2;
this.motionZ = z / 2;
} else {
this.motionX = -x / 2;
this.motionZ = -z / 2;
}
}
if (par1 < 0.0F) {
if (rotate <= 1) {
this.motionX = +-x / 2;
this.motionZ = +-z / 2;
} else {
this.motionX = +x / 2;
this.motionZ = +z / 2;
}
}
} else if (this.onGround) {
return;
}
if (par2 <= 0.0F) {
par2 *= 0.25F;
this.field_110285_bP = 0;
}
this.stepHeight = 1.0F;
this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;
if (!this.worldObj.isRemote) {
this.setAIMoveSpeed((float) this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
super.moveEntityWithHeading(par1, par2);
}
} else {
this.stepHeight = 0.5F;
this.jumpMovementFactor = 0.02F;
super.moveEntityWithHeading(this.moveForward, this.moveStrafing);
}
} else {
this.stepHeight = 0.5F;
this.jumpMovementFactor = 0.02F;
super.moveEntityWithHeading(this.moveForward, this.moveStrafing);
@Override
public void fall(float distance)
{
if (!this.isFriendly())
{
super.fall(distance);
}
}
@Override
protected void jump() {
super.jump();
this.playSound("mob.slime.small", 1.0F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F);
protected void jump()
{
this.motionY = 0.41999998688697815D;
this.isAirBorne = true;
}
public void setSwetType(int id) {
this.dataWatcher.updateObject(21, (byte) id);
public int getJumpTimer()
{
return this.jumpTimer;
}
public EnumSwetType getSwetType() {
public int getJumpDelay()
{
if (this.isFriendly())
{
return 2;
}
else
{
return this.rand.nextInt(20) + 10;
}
}
@Override
public int getVerticalFaceSpeed()
{
return 0;
}
@Override
public void knockBack(Entity entityIn, float strength, double xRatio, double zRatio)
{
if (!this.hasPrey())
{
super.knockBack(entityIn, strength, xRatio, zRatio);
}
}
public boolean hasPrey()
{
return this.riddenByEntity != null;
}
public boolean isPlayerFriendly(EntityPlayer player)
{
IPlayerAether iPlayerAether = AetherAPI.get(player);
return iPlayerAether.getAccessoryInventory().wearingAccessory(new ItemStack(ItemsAether.swet_cape));
}
public boolean isFriendly()
{
return this.hasPrey() && this.riddenByEntity instanceof EntityPlayer && isPlayerFriendly((EntityPlayer) this.riddenByEntity);
}
public void dissolveSwet()
{
for (int i = 0; i < 50; i++)
{
float f = this.rand.nextFloat() * 3.141593F * 2.0F;
float f1 = this.rand.nextFloat() * 0.5F + 0.25F;
float f2 = MathHelper.sin(f) * f1;
float f3 = MathHelper.cos(f) * f1;
this.worldObj.spawnParticle("splash", this.posX + (double) f2, this.boundingBox.minY + 1.25D, this.posZ + (double) f3, (double) f2 * 1.5D + this.motionX, 4D, (double) f3 * 1.5D + this.motionZ);
}
if (this.getDeathSound() != null) this.playSound(this.getDeathSound(), this.getSoundVolume(), this.getSoundPitch());
this.setDead();
}
@Override
public float getEyeHeight()
{
return 0.625F * this.height;
}
@Override
protected void dropFewItems(boolean recentlyHit, int lootLevel)
{
int count = this.rand.nextInt(2);
if (lootLevel > 0)
{
count += this.rand.nextInt(lootLevel + 1);
}
if (this.getType() == EnumSwetType.GOLDEN)
{
this.entityDropItem(new ItemStack(Blocks.glowstone, count), 1.0F);
}
else
{
this.entityDropItem(new ItemStack(BlocksAether.aercloud, count, 1), 1.0F);
this.entityDropItem(new ItemStack(ItemsAether.swet_ball, count), 1.0F);
}
}
@Override
protected float getSoundVolume()
{
return 0.6F;
}
@Override
public EntityAgeable createChild(EntityAgeable entityageable)
{
return null;
}
protected String getJumpSound()
{
return "mob.slime.small";
}
@Override
protected String getHurtSound()
{
return "mob.slime.small";
}
@Override
protected String getDeathSound()
{
return "mob.slime.small";
}
public EnumSwetType getType()
{
int id = this.dataWatcher.getWatchableObjectByte(21);
return EnumSwetType.get(id);
}
public void setFriendly(boolean friendly) {
this.dataWatcher.updateObject(20, (byte) (friendly ? 1 : 0));
}
public boolean isFriendly() {
return this.dataWatcher.getWatchableObjectByte(20) == (byte) 1;
}
public void splorch() {
this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.attack", 0.5F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F, false);
}
public void splotch() {
this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.slime.small", 0.5F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F, false);
public void setType(int id)
{
this.dataWatcher.updateObject(21, (byte) id);
}
@Override
protected String getHurtSound() {
return "mob.slime.small";
public boolean getCanSpawnHere()
{
return this.rand.nextInt(10) == 0 && super.getCanSpawnHere();
}
@Override
protected String getDeathSound() {
return "mob.slime.small";
public int getMaxSpawnedInChunk()
{
return 3;
}
@Override
public void applyEntityCollision(Entity entity) {
if (this.hops == 0 && !this.isFriendly() && this.riddenByEntity == null && this.getAttackTarget() != null && entity != null && entity == this.getAttackTarget() && (entity.ridingEntity == null || !(entity.ridingEntity instanceof EntitySwet))) {
this.capturePrey(entity);
}
super.applyEntityCollision(entity);
public boolean canDespawn()
{
return this.isFriendly();
}
@Override
public boolean interact(EntityPlayer player) {
if (!this.worldObj.isRemote && this.isFriendly()) {
if (this.riddenByEntity == null) {
this.capturePrey(player);
} else if (this.riddenByEntity == player) {
player.mountEntity(null);
}
}
return super.interact(player);
}
protected Entity getPrey() {
List<?> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(6D, 6D, 6D));
for (int i = 0; i < list.size(); i++) {
Entity entity = (Entity) list.get(i);
if ((entity instanceof EntityLivingBase) && !(entity instanceof EntitySwet) && (this.isFriendly() ? !(entity instanceof EntityPlayer) : !(entity instanceof EntityMob))) {
return entity;
}
}
return null;
}
@Override
protected void dropFewItems(boolean recentlyHit, int lootLevel) {
int count = this.rand.nextInt(3);
if (lootLevel > 0) {
count += this.rand.nextInt(lootLevel + 1);
}
this.entityDropItem(new ItemStack(this.getSwetType().getId() == 0 ? BlocksAether.aercloud : Blocks.glowstone, count, this.getSwetType().getId() == 0 ? 1 : 0), 1.0F);
this.entityDropItem(new ItemStack(ItemsAether.swet_ball, count), 1.0F);
}
@Override
public EntityAgeable createChild(EntityAgeable entityageable) {
return null;
}
@Override
public void writeEntityToNBT(NBTTagCompound compound) {
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
compound.setShort("Hops", (short) this.hops);
compound.setShort("Flutter", (short) this.flutter);
compound.setBoolean("isFriendly", this.isFriendly());
compound.setInteger("swetType", this.getSwetType().getId());
compound.setInteger("SwetType", this.getType().getId());
}
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
public void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
this.hops = compound.getShort("Hops");
this.flutter = compound.getShort("Flutter");
this.setFriendly(compound.getBoolean("isFriendly"));
this.setSwetType(compound.getInteger("swetType"));
this.setType(compound.getInteger("SwetType"));
}
}

View File

@ -54,6 +54,8 @@ public class AetherNetwork {
INSTANCE.registerMessage(PacketPortalItem.class, PacketPortalItem.class, discriminant++, Side.CLIENT);
INSTANCE.registerMessage(PacketCheckKey.class, PacketCheckKey.class, discriminant++, Side.SERVER);
INSTANCE.registerMessage(PacketSwetJump.class, PacketSwetJump.class, discriminant++, Side.CLIENT);
}
public static void sendToAll(IMessage message) {

View File

@ -0,0 +1,55 @@
package com.gildedgames.the_aether.network.packets;
import com.gildedgames.the_aether.entities.passive.mountable.EntitySwet;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
public class PacketSwetJump extends AetherPacket<PacketSwetJump>
{
public int id;
public boolean bool;
public PacketSwetJump()
{
}
public PacketSwetJump(int entity, boolean bool)
{
this.id = entity;
this.bool = bool;
}
@Override
public void fromBytes(ByteBuf buf)
{
this.id = buf.readInt();
this.bool = buf.readBoolean();
}
@Override
public void toBytes(ByteBuf buf)
{
buf.writeInt(this.id);
buf.writeBoolean(this.bool);
}
@Override
public void handleClient(PacketSwetJump message, EntityPlayer player)
{
if (player != null && player.worldObj != null) {
Entity entity = player.worldObj.getEntityByID(message.id);
if (entity instanceof EntitySwet) {
((EntitySwet) entity).midJump = message.bool;
}
}
}
@Override
public void handleServer(PacketSwetJump message, EntityPlayer player)
{
}
}