diff options
| author | Onyx <sor1n.iliutza16@gmail.com> | 2015-12-01 20:55:30 +0000 |
|---|---|---|
| committer | Onyx <sor1n.iliutza16@gmail.com> | 2015-12-01 20:55:30 +0000 |
| commit | 01c8701b68986ccfa83e902515716838d6829311 (patch) | |
| tree | b21aa78f4df6ca9bac90e2726221114a41f2294a /src/main/java/darkknight/jewelrycraft/entities | |
| parent | 35da479288f75d6686c64a00e1dc77e7e7fd50e1 (diff) | |
- Fixed all of the bugs mentioned on github
- Added new config options
- Rabbits paw now increases the chance of spawning hearts, rather than
itself spawning some
- Hearts now have a much lower chance to spawn by default
- You can no longer increase your health past 20 hearts (aka double the
default health)
- The guide now also shows the total number of pages on each tab
- A new luck stat has been added to the Curse API
- Cleaned up the code a bit (removed unused methods, imports etc)
- The displayer's info now has a purple solid color background; the text
also has a much closer shadow and now shrinks in height as well as in
width when too big
- I have modified the potion list to use Mithion's code, credits have
been given
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/entities')
5 files changed, 220 insertions, 206 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java b/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java index 6b9561f..06bf7b7 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java @@ -1,15 +1,7 @@ package darkknight.jewelrycraft.entities;
-import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.potion.Potion;
-import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.network.PacketRequestPlayerInfo;
-import darkknight.jewelrycraft.util.PlayerUtils;
-import darkknight.jewelrycraft.util.Variables;
/**
* @author Sorin
diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java b/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java index 84d1ee4..f84a23a 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java @@ -3,6 +3,14 @@ */
package darkknight.jewelrycraft.entities;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.network.PacketSendClientPlayerInfo;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.util.PlayerUtils;
+import darkknight.jewelrycraft.util.Variables;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureAttribute;
@@ -14,133 +22,153 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import darkknight.jewelrycraft.JewelrycraftMod;
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.network.PacketRequestPlayerInfo;
-import darkknight.jewelrycraft.network.PacketSendClientPlayerInfo;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-import darkknight.jewelrycraft.util.PlayerUtils;
-import darkknight.jewelrycraft.util.Variables;
/**
* @author Sorin
*/
-public class EntityHeart extends EntityLiving {
- public EntityHeart(World world) {
- super(world);
- this.setSize(0.4F, 0.4F);
- }
-
- protected void applyEntityAttributes() {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(getQuantity());
- }
-
- @Override
- public void updateEntityActionState() {
- if (ConfigHandler.HEARTS_DESPAWN) ++this.entityAge;
- this.setCanPickUpLoot(true);
- }
-
- public void onLivingUpdate() {
- super.onLivingUpdate();
- if (ConfigHandler.HEARTS_DESPAWN && this.entityAge > ConfigHandler.HEART_DESPAWN_TIME) this.setDead();
- }
-
- protected void collideWithEntity(Entity entity) {
- super.collideWithEntity(entity);
- if (!this.worldObj.isRemote && entity instanceof EntityHeart && getType().equals(((EntityHeart) entity).getType())) {
- setQuantity(getQuantity() + ((EntityHeart) entity).getQuantity());
- entity.setDead();
- }
- }
-
- @Override
- public void onCollideWithPlayer(EntityPlayer player) {
- if (!this.worldObj.isRemote) {
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (playerInfo != null) {
- if (getType() == "Red" && player.getHealth() < player.getMaxHealth()) {
- float healAmount = player.getMaxHealth() - player.getHealth();
- if (getQuantity() > healAmount) {
- player.heal(healAmount);
- this.setQuantity(getQuantity() - healAmount);
- } else {
- player.heal(getQuantity());
- this.setDead();
- }
- } else if (getType().equals("White") && playerInfo.getFloat("WhiteHeart") > 0.1F) {
- playerInfo.setFloat(getType() + "Heart", 0F);
- player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f);
- player.setHealth(player.getHealth() + 2f);
- JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
- this.setDead();
- } else if (!getType().equals("Red") && ((getType().equals("Black") && playerInfo.getFloat("BlackHeart") <= ConfigHandler.MAX_BLACK_HEARTS_PICKUP) || (getType().equals("Blue") && playerInfo.getFloat("BlueHeart") <= ConfigHandler.MAX_BLUE_HEARTS_PICKUP))) {
- if(playerInfo.hasKey(getType() + "Heart")) playerInfo.setFloat(getType() + "Heart", playerInfo.getFloat(getType() + "Heart") + getQuantity());
- else playerInfo.setFloat(getType() + "Heart", getQuantity());
- JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
- this.setDead();
- }
- }
- }
- }
-
+public class EntityHeart extends EntityLiving
+{
+ public EntityHeart(World world)
+ {
+ super(world);
+ this.setSize(0.4F, 0.4F);
+ }
+
+ protected void applyEntityAttributes()
+ {
+ super.applyEntityAttributes();
+ this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(getQuantity());
+ }
+
+ @Override
+ public void updateEntityActionState()
+ {
+ if (ConfigHandler.HEARTS_DESPAWN)
+ ++this.entityAge;
+ this.setCanPickUpLoot(true);
+ }
+
+ public void onLivingUpdate()
+ {
+ super.onLivingUpdate();
+ if (ConfigHandler.HEARTS_DESPAWN && this.entityAge > ConfigHandler.HEART_DESPAWN_TIME)
+ this.setDead();
+ }
+
+ protected void collideWithEntity(Entity entity)
+ {
+ super.collideWithEntity(entity);
+ if (!this.worldObj.isRemote && entity instanceof EntityHeart && getType().equals(((EntityHeart)entity).getType())) {
+ setQuantity(getQuantity() + ((EntityHeart)entity).getQuantity());
+ entity.setDead();
+ }
+ }
+
+ @Override
+ public void onCollideWithPlayer(EntityPlayer player)
+ {
+ if (!this.worldObj.isRemote) {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (playerInfo != null) {
+ if (getType().equals("Red") && player.getHealth() < player.getMaxHealth()) {
+ float healAmount = player.getMaxHealth() - player.getHealth();
+ if (getQuantity() > healAmount) {
+ player.heal(healAmount);
+ this.setQuantity(getQuantity() - healAmount);
+ }else{
+ player.heal(getQuantity());
+ this.setDead();
+ }
+ }else
+ if (getType().equals("White") && playerInfo.getFloat("WhiteHeart") > 0.1F) {
+ playerInfo.setFloat(getType() + "Heart", 0F);
+ if (player.getMaxHealth() < 40F) {
+ player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f);
+ player.setHealth(player.getHealth() + 2f);
+ }
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
+ this.setDead();
+ }else
+ if (!getType().equals("Red") && ((getType().equals("Black") && playerInfo.getFloat("BlackHeart") <= ConfigHandler.MAX_BLACK_HEARTS_PICKUP) || (getType().equals("Blue") && playerInfo.getFloat("BlueHeart") <= ConfigHandler.MAX_BLUE_HEARTS_PICKUP) || getType().equals("White"))) {
+ if (playerInfo.hasKey(getType() + "Heart"))
+ playerInfo.setFloat(getType() + "Heart", playerInfo.getFloat(getType() + "Heart") + getQuantity());
+ else playerInfo.setFloat(getType() + "Heart", getQuantity());
+ JewelrycraftMod.netWrapper.sendTo(new PacketSendClientPlayerInfo(playerInfo), (EntityPlayerMP)player);
+ this.setDead();
+ }
+ }
+ }
+ }
+
public void onDeath(DamageSource source)
{
- super.onDeath(source);
- if(source.getEntity() != null && source.getEntity() instanceof EntityPlayer)
- ((EntityPlayer)source.getEntity()).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".heartKilled."+this.getType())));
+ super.onDeath(source);
+ if (source.getEntity() != null && source.getEntity() instanceof EntityPlayer)
+ ((EntityPlayer)source.getEntity()).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".heartKilled." + this.getType())));
+ }
+
+ @SideOnly (Side.CLIENT)
+ public boolean canRenderOnFire()
+ {
+ return false;
+ }
+
+ protected void entityInit()
+ {
+ super.entityInit();
+ this.dataWatcher.addObject(16, "Red");
+ this.dataWatcher.addObject(17, 2f);
+ }
+
+ public void writeEntityToNBT(NBTTagCompound nbt)
+ {
+ super.writeEntityToNBT(nbt);
+ nbt.setString("Type", getType());
+ nbt.setFloat("Quantity", getQuantity());
+ }
+
+ /**
+ * (abstract) Protected helper method to read subclass entity data from NBT.
+ */
+ public void readEntityFromNBT(NBTTagCompound nbt)
+ {
+ super.readEntityFromNBT(nbt);
+ setType(nbt.getString("Type"));
+ setQuantity(nbt.getFloat("Quantity"));
+ }
+
+ public String getType()
+ {
+ return this.dataWatcher.getWatchableObjectString(16);
+ }
+
+ public void setType(String type)
+ {
+ this.dataWatcher.updateObject(16, type);
+ }
+
+ public Float getQuantity()
+ {
+ return this.dataWatcher.getWatchableObjectFloat(17);
+ }
+
+ public void setQuantity(Float qty)
+ {
+ this.dataWatcher.updateObject(17, qty);
+ }
+
+ public EnumCreatureAttribute getCreatureAttribute()
+ {
+ return JewelrycraftUtil.HEART;
+ }
+
+ public boolean isEntityInvulnerable()
+ {
+ return false;
+ }
+
+ public boolean canPickUpLoot()
+ {
+ return false;
}
-
- @SideOnly(Side.CLIENT)
- public boolean canRenderOnFire() {
- return false;
- }
-
- protected void entityInit() {
- super.entityInit();
- this.dataWatcher.addObject(16, "Red");
- this.dataWatcher.addObject(17, 2f);
- }
-
- public void writeEntityToNBT(NBTTagCompound nbt) {
- super.writeEntityToNBT(nbt);
- nbt.setString("Type", getType());
- nbt.setFloat("Quantity", getQuantity());
- }
-
- /**
- * (abstract) Protected helper method to read subclass entity data from NBT.
- */
- public void readEntityFromNBT(NBTTagCompound nbt) {
- super.readEntityFromNBT(nbt);
- setType(nbt.getString("Type"));
- setQuantity(nbt.getFloat("Quantity"));
- }
-
- public String getType() {
- return this.dataWatcher.getWatchableObjectString(16);
- }
-
- public void setType(String type) {
- this.dataWatcher.updateObject(16, type);
- }
-
- public Float getQuantity() {
- return this.dataWatcher.getWatchableObjectFloat(17);
- }
-
- public void setQuantity(Float qty) {
- this.dataWatcher.updateObject(17, qty);
- }
-
- public EnumCreatureAttribute getCreatureAttribute() {
- return JewelrycraftUtil.HEART;
- }
-
- public boolean isEntityInvulnerable() {
- return false;
- }
}
diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java index 952b3ba..ceb2625 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java @@ -1,12 +1,11 @@ package darkknight.jewelrycraft.entities;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityLiving;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.item.ItemSpawnEgg;
-import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
public class EntityList
{
diff --git a/src/main/java/darkknight/jewelrycraft/entities/renders/HeartRender.java b/src/main/java/darkknight/jewelrycraft/entities/renders/HeartRender.java index d951340..d25ecbe 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/renders/HeartRender.java +++ b/src/main/java/darkknight/jewelrycraft/entities/renders/HeartRender.java @@ -1,71 +1,67 @@ -package darkknight.jewelrycraft.entities.renders; - -import java.util.Random; -import org.lwjgl.opengl.GL11; -import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; -import darkknight.jewelrycraft.entities.EntityHeart; -import darkknight.jewelrycraft.util.Variables; - -/** - * @author Sorin - */ -public class HeartRender extends RenderLiving -{ - protected ResourceLocation texture; - Random rnd = new Random(); - - public HeartRender(ModelBase modelBase, float shadowSize) - { - super(modelBase, shadowSize); - } - - protected void renderModel(EntityLivingBase entity, float x, float y, float z, float rot1, float rot2, float rot3) - { - super.renderModel(entity, x, y, z, rot1, rot2, rot3); - rnd.setSeed(1542372345); - if (((EntityHeart)entity).getQuantity() > 2f){ - for(int i = 0; i < ((EntityHeart)entity).getQuantity() / 10f; i++){ - float posX = rnd.nextFloat() * 0.2f * (rnd.nextBoolean()?1:-1); - float posY = rnd.nextFloat() * 0.2f * (rnd.nextBoolean()?1:-1); - float posZ = rnd.nextFloat() * 0.2f * (rnd.nextBoolean()?1:-1); - float rotX = rnd.nextFloat() * 35f * (rnd.nextBoolean()?1:-1); - float rotY = rnd.nextFloat() * 35f * (rnd.nextBoolean()?1:-1); - float rotZ = rnd.nextFloat() * 35f * (rnd.nextBoolean()?1:-1); - GL11.glTranslatef(-0.15F, 0.0F, 0.0F); - GL11.glTranslatef(posX, posY, 0F); - GL11.glRotatef(rotY, 0F, 1F, 0F); - GL11.glRotatef(rotZ, 0F, 0F, 1F); - GL11.glPushMatrix(); - this.mainModel.render(entity, x, y, z, rot1, rot2, rot3); - GL11.glPopMatrix(); - } - } - } - - @Override - protected void preRenderCallback(EntityLivingBase entity, float f) - { - preRenderCallbackHeart((EntityHeart)entity, f); - } - - protected void preRenderCallbackHeart(EntityHeart entity, float f) - { - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glRotatef(55F, 1F, 0F, 0F); - String type = entity.getType(); - if (type == "" || type == null) type = "Red"; - texture = new ResourceLocation(Variables.MODID, "textures/entities/" + type + "Heart.png"); - } - - @Override - protected ResourceLocation getEntityTexture(Entity par1Entity) - { - return texture; - } -} +package darkknight.jewelrycraft.entities.renders;
+
+import java.util.Random;
+import org.lwjgl.opengl.GL11;
+import darkknight.jewelrycraft.entities.EntityHeart;
+import darkknight.jewelrycraft.util.Variables;
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.renderer.entity.RenderLiving;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.util.ResourceLocation;
+
+/**
+ * @author Sorin
+ */
+public class HeartRender extends RenderLiving
+{
+ protected ResourceLocation texture;
+ Random rnd = new Random();
+
+ public HeartRender(ModelBase modelBase, float shadowSize)
+ {
+ super(modelBase, shadowSize);
+ }
+
+ protected void renderModel(EntityLivingBase entity, float x, float y, float z, float rot1, float rot2, float rot3)
+ {
+ super.renderModel(entity, x, y, z, rot1, rot2, rot3);
+ rnd.setSeed(1542372345);
+ if (((EntityHeart)entity).getQuantity() > 2f){
+ for(int i = 0; i < ((EntityHeart)entity).getQuantity() / 10f; i++){
+ float posX = rnd.nextFloat() * 0.2f * (rnd.nextBoolean()?1:-1);
+ float posY = rnd.nextFloat() * 0.2f * (rnd.nextBoolean()?1:-1);
+ float rotY = rnd.nextFloat() * 35f * (rnd.nextBoolean()?1:-1);
+ float rotZ = rnd.nextFloat() * 35f * (rnd.nextBoolean()?1:-1);
+ GL11.glTranslatef(-0.15F, 0.0F, 0.0F);
+ GL11.glTranslatef(posX, posY, 0F);
+ GL11.glRotatef(rotY, 0F, 1F, 0F);
+ GL11.glRotatef(rotZ, 0F, 0F, 1F);
+ GL11.glPushMatrix();
+ this.mainModel.render(entity, x, y, z, rot1, rot2, rot3);
+ GL11.glPopMatrix();
+ }
+ }
+ }
+
+ @Override
+ protected void preRenderCallback(EntityLivingBase entity, float f)
+ {
+ preRenderCallbackHeart((EntityHeart)entity, f);
+ }
+
+ protected void preRenderCallbackHeart(EntityHeart entity, float f)
+ {
+ GL11.glScalef(0.4F, 0.4F, 0.4F);
+ GL11.glRotatef(55F, 1F, 0F, 0F);
+ String type = entity.getType();
+ if (type == "" || type == null) type = "Red";
+ texture = new ResourceLocation(Variables.MODID, "textures/entities/" + type + "Heart.png");
+ }
+
+ @Override
+ protected ResourceLocation getEntityTexture(Entity par1Entity)
+ {
+ return texture;
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java b/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java index 8012d84..9fd3c62 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java +++ b/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java @@ -1,9 +1,8 @@ package darkknight.jewelrycraft.entities.renders;
+import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
-import org.lwjgl.opengl.GL11;
-import cpw.mods.fml.common.Loader;
public class RenderHelper
{
|
