Skip to content

Commit

Permalink
Minor Fixes
Browse files Browse the repository at this point in the history
Fixed Kitty lifecycle. Kittens that grow up now use the adult Kitty behaviour.

Kitty no longer becomes angry from going into water.

Fixed rotation for prey inside Crocodile's mouth while it is doing it's spin attack, this also resulted in the spin attack being faster than before.

Cleaned up some of the Crocodile render code.

Retweaked horse speeds so that no horse is slower than the slowest possible vanilla Minecraft horse.

/mocspawn error messages for invalid entity type now indicate that that type is specifically invalid for that entity

Improve accuracy of fire placement for Nightmare horse fire trail.
  • Loading branch information
Rozmir-Rohi committed Dec 20, 2024
1 parent 3e1153c commit 40f4193
Show file tree
Hide file tree
Showing 14 changed files with 252 additions and 218 deletions.
22 changes: 14 additions & 8 deletions src/main/java/drzhark/mocreatures/MoCTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -1351,18 +1351,24 @@ public static boolean allowedBlock(int ID)
* player.getCommandSenderName() as the owner of the entity, and name the entity.
*
* @param entityPlayer
* @param creature
* @param mocreature
* @return
*/
public static boolean tameWithName(EntityPlayer entityPlayer, IMoCTameable creature)
public static boolean tameWithName(EntityPlayer entityPlayer, IMoCTameable mocreature)
{
if (entityPlayer == null || creature == null)
if (entityPlayer == null || mocreature == null)
{
return false;
}

//if the player interacting with creature is not the owner of the pet
if (creature.getOwnerName().length() > 0 && !(creature.getOwnerName().equals(entityPlayer.getCommandSenderName())) && MoCreatures.instance.mapData != null)
if (
mocreature.getOwnerName().length() > 0
&& !(mocreature.getOwnerName().equals(entityPlayer.getCommandSenderName()))
&& !(
mocreature.getOwnerName().equals("NoOwner") //allows creatures spawned with /mocspawn command to be tamed by any player
)
&& MoCreatures.instance.mapData != null)
{
return false;
}
Expand All @@ -1372,7 +1378,7 @@ public static boolean tameWithName(EntityPlayer entityPlayer, IMoCTameable creat
int maxNumberOfPetsAllowed = 0;
maxNumberOfPetsAllowed = MoCreatures.proxy.maxTamed;
// only check count for new pets as owners may be changing the name
if (!MoCreatures.instance.mapData.isExistingPet(entityPlayer.getCommandSenderName(), creature))
if (!MoCreatures.instance.mapData.isExistingPet(entityPlayer.getCommandSenderName(), mocreature))
{
int petCount = MoCTools.numberTamedByPlayer(entityPlayer);
if (isThisPlayerAnOP(entityPlayer))
Expand All @@ -1392,9 +1398,9 @@ public static boolean tameWithName(EntityPlayer entityPlayer, IMoCTameable creat
}
}

creature.setOwner(entityPlayer.getCommandSenderName()); // ALWAYS SET OWNER. Required for our new pet save system.
MoCMessageHandler.INSTANCE.sendTo(new MoCMessageNameGUI(((Entity) creature).getEntityId()), (EntityPlayerMP)entityPlayer);
creature.setTamed(true);
mocreature.setOwner(entityPlayer.getCommandSenderName()); // ALWAYS SET OWNER. Required for our new pet save system.
MoCMessageHandler.INSTANCE.sendTo(new MoCMessageNameGUI(((Entity) mocreature).getEntityId()), (EntityPlayerMP)entityPlayer);
mocreature.setTamed(true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f
boolean flapwings = (entityhorse.wingFlapCounter != 0);
boolean isShuffling = (entityhorse.shuffleCounter > 0);
boolean saddled = entityhorse.getIsRideable();
boolean wings = (entityhorse.isFlyer() && !entityhorse.isGhost() && type < 45);
boolean wings = (entityhorse.isFlyer() && !entityhorse.isGhostHorse() && type < 45);
//boolean chested = entityhorse.getChestedHorse();
boolean eating = entityhorse.getEating();
boolean ramming = ((entityhorse.sprintCounter > 0 && entityhorse.sprintCounter < 150) && entityhorse.isUnicorned() && (entityhorse.riddenByEntity != null));
boolean ramming = ((entityhorse.sprintCounter > 0 && entityhorse.sprintCounter < 150) && entityhorse.doesHaveHorn() && (entityhorse.riddenByEntity != null));
//boolean flyer = entityhorse.isFlyer();
boolean standing = (entityhorse.standCounter != 0);
boolean openMouth = (entityhorse.mouthCounter != 0);
Expand All @@ -378,13 +378,13 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f


boolean rider = (entityhorse.riddenByEntity != null);
boolean floating = (entityhorse.isGhost() || (entityhorse.isFlyer() && entityhorse.isOnAir()));
boolean floating = (entityhorse.isGhostHorse() || (entityhorse.isFlyer() && entityhorse.isOnAir()));
// || (entityhorse.riddenByEntity == null && !entityhorse.onGround)
// || (entityhorse.riddenByEntity != null && !entityhorse.riddenByEntity.onGround));

setRotationAngles(f, f1, f2, f3, f4, f5, eating, ramming, rider, floating, standing, saddled, moveTail, wings, flapwings, isShuffling, type);

if (!entityhorse.isGhost() && vanishingInt == 0)
if (!entityhorse.isGhostHorse() && vanishingInt == 0)
{
if (saddled)
{
Expand Down Expand Up @@ -451,7 +451,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f
Leg4B.render(f5);
Leg4C.render(f5);

if (entityhorse.isUnicorned())
if (entityhorse.doesHaveHorn())
{
Unicorn.render(f5);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class MoCRenderCrocodile extends RenderLiving {
public MoCRenderCrocodile(MoCModelCrocodile modelBase, float f)
{
super(modelBase, f);
croc = modelBase;
modelCrocodile = modelBase;
}

@Override
Expand All @@ -40,98 +40,40 @@ public void doRender(EntityLiving entityLiving, double x, double y, double z, fl
@Override
protected void preRenderCallback(EntityLivingBase entityLiving, float f)
{
MoCEntityCrocodile entitycrocodile = (MoCEntityCrocodile) entityLiving;
croc.biteProgress = entitycrocodile.biteProgress;
croc.swimming = entitycrocodile.isSwimming();
croc.resting = entitycrocodile.getIsResting();
if (entitycrocodile.isSpinning() && entitycrocodile.riddenByEntity instanceof EntityPlayer)
{
spinCrocWithPlayer(entitycrocodile, (EntityPlayer) entitycrocodile.riddenByEntity);
}

if (entitycrocodile.isSpinning() && !(entitycrocodile.riddenByEntity instanceof EntityPlayer))
MoCEntityCrocodile entityCrocodile = (MoCEntityCrocodile) entityLiving;
modelCrocodile.biteProgress = entityCrocodile.biteProgress;
modelCrocodile.swimming = entityCrocodile.isSwimming();
modelCrocodile.resting = entityCrocodile.getIsResting();

if (entityCrocodile.isSpinning() && entityCrocodile.riddenByEntity instanceof EntityLivingBase)
{
spinCrocWithCreature(entitycrocodile, (EntityLiving) entitycrocodile.riddenByEntity);
spinCrocodileAndTheEntityInsideItsMouth(entityCrocodile, (EntityLivingBase) entityCrocodile.riddenByEntity);
}

stretch(entitycrocodile);
if (entitycrocodile.getIsResting())
stretch(entityCrocodile);
if (entityCrocodile.getIsResting())
{
if (!entitycrocodile.isInsideOfMaterial(Material.water))
if (!entityCrocodile.isInsideOfMaterial(Material.water))
{
adjustHeight(entitycrocodile, 0.2F);
adjustHeight(entityCrocodile, 0.2F);
}
else
{
//adjustHeight(entitycrocodile, 0.1F);
//adjustHeight(entityCrocodile, 0.1F);
}

}
/* if(!entitycrocodile.getIsAdult())
{
}
*/
}

protected void rotateAnimal(MoCEntityCrocodile entitycrocodile)
{

//float f = entitycrocodile.swingProgress *10F *entitycrocodile.getFlipDirection();
//float f2 = entitycrocodile.swingProgress /30 *entitycrocodile.getFlipDirection();
//GL11.glRotatef(180F + f, 0.0F, 0.0F, -1.0F);
//GL11.glTranslatef(0.0F-f2, 0.5F, 0.0F);
}

protected void adjustHeight(EntityLiving entityLiving, float FHeight)
{
GL11.glTranslatef(0.0F, FHeight, 0.0F);
}

protected void spinCrocWithCreature(MoCEntityCrocodile croc, EntityLiving prey)
{
int intSpin = croc.spinInt;

int direction = 1;
if (intSpin > 40)
{
intSpin -= 40;
direction = -1;
}
int intEndSpin = intSpin;
if (intSpin >= 20)
{
intEndSpin = (20 - (intSpin - 20));
}
if (intEndSpin == 0)
{
intEndSpin = 1;
}
float f3 = (((intEndSpin) - 1.0F) / 20F) * 1.6F;
f3 = MathHelper.sqrt_float(f3);
if (f3 > 1.0F)
{
f3 = 1.0F;
}
f3 *= direction;
GL11.glRotatef(f3 * 90F, 0.0F, 0.0F, 1.0F);

if (prey != null)
{
prey.deathTime = intEndSpin;
}
}

protected void spinCrocWithPlayer(MoCEntityCrocodile croc, EntityPlayer prey)
protected void spinCrocodileAndTheEntityInsideItsMouth(MoCEntityCrocodile entityCrocodile, EntityLivingBase entityLivingBasePreyInsideMouth)
{
int intSpin = croc.spinInt;
int intSpin = entityCrocodile.spinInt;

int direction = 1;
if (intSpin > 40)
{
intSpin -= 40;
direction = -1;
}
int intEndSpin = intSpin;
if (intSpin >= 20)
{
Expand All @@ -141,28 +83,29 @@ protected void spinCrocWithPlayer(MoCEntityCrocodile croc, EntityPlayer prey)
{
intEndSpin = 1;
}
float f3 = (((intEndSpin) - 1.0F) / 20F) * 1.6F;
f3 = MathHelper.sqrt_float(f3);
if (f3 > 1.0F)

float rotationFactor = (((intEndSpin) - 1.0F) / 20F) * 1.6F;
rotationFactor = MathHelper.sqrt_float(rotationFactor);

if (rotationFactor > 1.0F)
{
f3 = 1.0F;
rotationFactor = 1.0F;
}
f3 *= direction;
GL11.glRotatef(f3 * 90F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(rotationFactor * 90F, 0.0F, 0.0F, 1.0F);

if (prey != null)
if (entityLivingBasePreyInsideMouth != null)
{
prey.deathTime = intEndSpin;
entityLivingBasePreyInsideMouth.deathTime = intEndSpin; //this rotates the whole model of the prey by using deathTime
}
}


protected void stretch(MoCEntityCrocodile entitycrocodile)
protected void stretch(MoCEntityCrocodile entityCrocodile)
{
float f = entitycrocodile.getMoCAge() * 0.01F;
float f = entityCrocodile.getMoCAge() * 0.01F;
GL11.glScalef(f, f, f);
}

public MoCModelCrocodile croc;
public MoCModelCrocodile modelCrocodile;

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void preRenderCallback(EntityLivingBase entityLiving, float f)
{
stretch(entityhorse);
}
if (entityhorse.isGhost())
if (entityhorse.isGhostHorse())
{
adjustHeight(entityhorse, -0.3F + (entityhorse.ghostHorseTransparencyFloat() / 5F));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ else if (entityType.equalsIgnoreCase("wyvern"))
|| (entityType.equalsIgnoreCase("wyvern") && (type < 1 || type > 12))
)
{
iCommandSender.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "ERROR:" + EnumChatFormatting.WHITE + "The spawn type " + type + " is not a valid type."));
iCommandSender.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "ERROR:" + EnumChatFormatting.WHITE + "The spawn type " + type + " for " + entityType + " is not a valid type."));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ && getIsTamed()
&& getOwnerName() != null
&& !(
getOwnerName().equals("")
|| getOwnerName().equals("NoOwner") //allows creatures spawned with /mocspawn command to be tamed by any player
)
&& !entityPlayer.getCommandSenderName().equals(getOwnerName())
&& !MoCTools.isThisPlayerAnOP((entityPlayer))
Expand Down
Loading

0 comments on commit 40f4193

Please sign in to comment.