Skip to content

Commit

Permalink
Added Dolphin jump and Dolphin jump animation + Organise Imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Rozmir-Rohi committed Dec 15, 2024
1 parent 0c5577c commit be232bf
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 66 deletions.
4 changes: 0 additions & 4 deletions src/main/java/drzhark/mocreatures/MoCEventHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
import drzhark.mocreatures.entity.IMoCTameable;
import drzhark.mocreatures.entity.MoCEntityAquatic;
import drzhark.mocreatures.entity.ambient.MoCEntityBee;
import drzhark.mocreatures.entity.animal.MoCEntityBigCat;
import drzhark.mocreatures.entity.animal.MoCEntityElephant;
import drzhark.mocreatures.entity.animal.MoCEntityHorse;
import drzhark.mocreatures.entity.animal.MoCEntityKitty;
import drzhark.mocreatures.entity.animal.MoCEntityOstrich;
import drzhark.mocreatures.entity.animal.MoCEntityPetScorpion;
import drzhark.mocreatures.entity.animal.MoCEntityTurkey;
import drzhark.mocreatures.entity.monster.MoCEntityScorpion;
import drzhark.mocreatures.entity.witchery_integration.MoCEntityWerewolfVillagerWitchery;
import drzhark.mocreatures.entity.witchery_integration.MoCEntityWerewolfWitchery;
import net.minecraft.block.Block;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/drzhark/mocreatures/MoCTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ public static void slideEntityToXYZ(Entity entity, int x, int y, int z)
}
}

public static float distanceToSurface(Entity entity)
public static float distanceToWaterSurface(Entity entity)
{
int x = MathHelper.floor_double(entity.posX);
int y = MathHelper.floor_double(entity.posY);
Expand All @@ -682,7 +682,7 @@ public static float distanceToSurface(Entity entity)
return 0F;
}

public static int distanceToFloor(Entity entity)
public static int distanceToWaterFloor(Entity entity)
{
int x = MathHelper.floor_double(entity.posX);
int y = MathHelper.floor_double(entity.posY);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/drzhark/mocreatures/MoCreatures.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ public void preInit(FMLPreInitializationEvent event)
FMLCommonHandler.instance().bus().register(new MoCClientTickHandler());
FMLCommonHandler.instance().bus().register(new MoCKeyHandler());
MinecraftForge.EVENT_BUS.register(new MoCClientWitcheryPlayerWolfAndWerewolfReplacement());
//TODO Add Horse Jump Bar
MinecraftForge.EVENT_BUS.register(new MoCRenderHorseJumpBarEvent(Minecraft.getMinecraft()));
}
FMLCommonHandler.instance().bus().register(new MoCPlayerTracker());
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/drzhark/mocreatures/client/MoCCreativeTabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
import java.util.Iterator;
import java.util.List;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import drzhark.mocreatures.MoCTools;
import drzhark.mocreatures.MoCreatures;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;

public class MoCCreativeTabs extends CreativeTabs {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import drzhark.mocreatures.MoCProxy;
import drzhark.mocreatures.MoCreatures;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import drzhark.mocreatures.MoCProxy;
import drzhark.mocreatures.MoCreatures;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import drzhark.mocreatures.MoCProxy;
import drzhark.mocreatures.MoCreatures;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ public void doRender(EntityLiving entityLiving, double x, double y, double z, fl

public void doRender2(EntityLiving entityLiving, double d, double d1, double d2, float f, float f1)
{
MoCEntityDolphin entitydolphin = (MoCEntityDolphin) entityLiving;
super.doRender(entitydolphin, d, d1, d2, f, f1);
if (entitydolphin.shouldRenderName())
MoCEntityDolphin entityDolphin = (MoCEntityDolphin) entityLiving;
super.doRender(entityDolphin, d, d1, d2, f, f1);
if (entityDolphin.shouldRenderName())
{
float f2 = 1.6F;
float f3 = 0.01666667F * f2;
float f4 = entityLiving.getDistanceToEntity(renderManager.livingPlayer);
String s = "";
s = (new StringBuilder()).append(s).append(entitydolphin.getName()).toString();
if ((f4 < 12F) && (s.length() > 0))
float distanceToEntityPlayer = entityLiving.getDistanceToEntity(renderManager.livingPlayer);
String petName = "";
petName = (new StringBuilder()).append(petName).append(entityDolphin.getName()).toString();
if ((distanceToEntityPlayer < 12F) && (petName.length() > 0))
{
FontRenderer fontrenderer = getFontRendererFromRenderManager();
FontRenderer fontRenderer = getFontRendererFromRenderManager();
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.0F, (float) d1 + 0.3F, (float) d2);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
Expand All @@ -134,16 +134,16 @@ public void doRender2(EntityLiving entityLiving, double d, double d1, double d2,
byte byte0 = -50;
GL11.glDisable(3553 /* GL_TEXTURE_2D */);
tessellator.startDrawingQuads();
int i = fontrenderer.getStringWidth(s) / 2;
int stringWidthHalf = fontRenderer.getStringWidth(petName) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
tessellator.addVertex(-i - 1, -1 + byte0, 0.0D);
tessellator.addVertex(-i - 1, 8 + byte0, 0.0D);
tessellator.addVertex(i + 1, 8 + byte0, 0.0D);
tessellator.addVertex(i + 1, -1 + byte0, 0.0D);
tessellator.addVertex(-stringWidthHalf - 1, -1 + byte0, 0.0D);
tessellator.addVertex(-stringWidthHalf - 1, 8 + byte0, 0.0D);
tessellator.addVertex(stringWidthHalf + 1, 8 + byte0, 0.0D);
tessellator.addVertex(stringWidthHalf + 1, -1 + byte0, 0.0D);
if (MoCreatures.proxy.getDisplayPetHealthMode(entityLiving))
{
float f5 = entitydolphin.getHealth();
float f6 = entitydolphin.getMaxHealth();
float f5 = entityDolphin.getHealth();
float f6 = entityDolphin.getMaxHealth();
float f7 = f5 / f6;
float f8 = 40F * f7;
tessellator.setColorRGBA_F(0.7F, 0.0F, 0.0F, 1.0F);
Expand All @@ -159,17 +159,24 @@ public void doRender2(EntityLiving entityLiving, double d, double d1, double d2,
}
tessellator.draw();
GL11.glEnable(3553 /* GL_TEXTURE_2D */);
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, byte0, 0x20ffffff);
fontRenderer.drawString(petName, -fontRenderer.getStringWidth(petName) / 2, byte0, 0x20ffffff);
GL11.glEnable(2929 /* GL_DEPTH_TEST */);
GL11.glDepthMask(true);
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, byte0, -1);
fontRenderer.drawString(petName, -fontRenderer.getStringWidth(petName) / 2, byte0, -1);
GL11.glEnable(2896 /* GL_LIGHTING */);
GL11.glDisable(3042 /* GL_BLEND */);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
}
}

@Override
protected void preRenderCallback(EntityLivingBase entityLivingBase, float par1)
{
super.preRenderCallback(entityLivingBase, par1);
checkIfIsInAirAndApplyRotation((MoCEntityDolphin) entityLivingBase);
}

@Override
protected float handleRotationFloat(EntityLivingBase entityLiving, float f)
Expand All @@ -178,14 +185,22 @@ protected float handleRotationFloat(EntityLivingBase entityLiving, float f)
return entityLiving.ticksExisted + f;
}

protected void stretch(MoCEntityDolphin entitydolphin)
protected void stretch(MoCEntityDolphin entityDolphin)
{
GL11.glScalef(entitydolphin.getMoCAge() * 0.01F, entitydolphin.getMoCAge() * 0.01F, entitydolphin.getMoCAge() * 0.01F);
GL11.glScalef(entityDolphin.getMoCAge() * 0.01F, entityDolphin.getMoCAge() * 0.01F, entityDolphin.getMoCAge() * 0.01F);
}

protected void checkIfIsInAirAndApplyRotation(MoCEntityDolphin entityDolphin)
{
if(!entityDolphin.onGround && entityDolphin.riddenByEntity != null)
{
GL11.glRotatef((float) entityDolphin.getRotationAmount(), -1, 0, 0);
}
}


@Override
protected ResourceLocation getEntityTexture(Entity par1Entity) {
return ((MoCEntityDolphin)par1Entity).getTexture();
protected ResourceLocation getEntityTexture(Entity entity)
{
return ((MoCEntityDolphin)entity).getTexture();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import cpw.mods.fml.relauncher.SideOnly;
import drzhark.mocreatures.MoCProxy;
import drzhark.mocreatures.MoCTools;
import drzhark.mocreatures.MoCreatures;
import drzhark.mocreatures.client.model.MoCModelKittyBed;
import drzhark.mocreatures.client.model.MoCModelKittyBed2;
import drzhark.mocreatures.entity.item.MoCEntityKittyBed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void floatOnWater()
}
motionY += 0.001D;// 0.001

int yDistanceToSurfaceOfWater = (int) MoCTools.distanceToSurface(this);
int yDistanceToSurfaceOfWater = (int) MoCTools.distanceToWaterSurface(this);

if (yDistanceToSurfaceOfWater > 1)
{
Expand Down Expand Up @@ -803,7 +803,7 @@ else if (handleLavaMovement())
}
if (isFlyingAlone())
{
int distY = MoCTools.distanceToFloor(this);
int distY = MoCTools.distanceToWaterFloor(this);
if (distY <= flyingHeight())
{
motionY *= movement;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/drzhark/mocreatures/entity/MoCEntityAnimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public void floatOnWater()
}
motionY += 0.001D;// 0.001

int yDistanceToSurfaceOfWater = (int) MoCTools.distanceToSurface(this);
int yDistanceToSurfaceOfWater = (int) MoCTools.distanceToWaterSurface(this);
if (yDistanceToSurfaceOfWater > 1)
{
motionY += (yDistanceToSurfaceOfWater * 0.07);
Expand Down Expand Up @@ -1217,7 +1217,7 @@ else if (jumpPending && !getIsJumping())
}
if (isFlyingAlone())
{
int yDistanceFromGround = MoCTools.distanceToFloor(this);
int yDistanceFromGround = MoCTools.distanceToWaterFloor(this);
if (yDistanceFromGround <= flyingHeight())
{
motionY *= 0.3 + (acceleration);
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/drzhark/mocreatures/entity/MoCEntityAquatic.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ else if ((riddenByEntity != null) && getIsTamed())
movementSideways = ((EntityLivingBase)riddenByEntity).moveStrafing * 0.5F;
movementForward = ((EntityLivingBase)riddenByEntity).moveForward;

if (jumpPending)
if (jumpPending && isSwimming())
{
motionY += getCustomJump();
jumpPending = false;
Expand All @@ -429,7 +429,7 @@ else if ((riddenByEntity != null) && getIsTamed())
motionY -= 0.3D;
}

if (motionY > 0.01D && !isSwimming())
if (motionY > 0.01D && !isSwimming() && !getIsJumping())
{
motionY = -0.01D;
}
Expand Down Expand Up @@ -551,16 +551,13 @@ protected void jump()

public void moveVerticallyInWater()
{
float yDistanceToSurfaceOfWater = MoCTools.distanceToSurface(this);
float yDistanceToSurfaceOfWater = MoCTools.distanceToWaterSurface(this);

if (riddenByEntity != null)
{
EntityPlayer playerThatIsRidingThisCreature = (EntityPlayer) riddenByEntity;
if (playerThatIsRidingThisCreature.isAirBorne) // TODO TEST
{
motionY += 0.09D;
}
else if (divePending)

if (divePending)
{
motionY = -0.008D;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryLargeChest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import drzhark.mocreatures.entity.MoCEntityTameableAnimal;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;
Expand Down
Loading

0 comments on commit be232bf

Please sign in to comment.