1.6.2 test - Finished liquids, added connected textures on glass

This commit is contained in:
mDiyo committed 2013-07-26 21:18:53 -07:00
1 parent 40c6f445a2
commit a80fcbce86
704 files changed
+60909

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
package tconstruct.entity;
import tconstruct.entity.ai.GAIAttackTarget;
import tconstruct.entity.ai.GAIFindTarget;
import tconstruct.entity.ai.GAIFollowOwner;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public class Automaton extends GolemBase
{
int state;
/*TaskBase currentTask;
HashMap<String, TaskBase> taskList = new HashMap<String, TaskBase>();*/
public Automaton(World world)
{
super(world);
this.setSize(0.9F, 2.42F);
//this.texture = "/mods/tinker/textures/mob/crystalguardamber.png";
this.tasks.addTask(1, new GAIAttackTarget(this));
this.tasks.addTask(2, new GAIFindTarget(this));
this.tasks.addTask(3, new GAIFollowOwner(this));
/*taskList.put("wait", new TaskWait(this));
TaskBase task = new TaskClearcut(this);
taskList.put("clearcut", task);
currentTask = task;*/
}
/*@Override
public void initCreature ()
{
baseAttack = 5;
maxHealth = 50;
}*/
/*@Override
public void updateAITick()
{
if (!currentTask.update())
{
currentTask.finishTask();
}
}*/
protected String getHurtSound ()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound ()
{
return "mob.irongolem.death";
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound (int par1, int par2, int par3, int par4)
{
this.playSound("mob.irongolem.walk", 1.0F, 1.0F);
}
public boolean interact (EntityPlayer par1EntityPlayer)
{
this.setCurrentItemOrArmor(0, par1EntityPlayer.getCurrentEquippedItem().copy());
return true;
}
}
+624
View File
@@ -0,0 +1,624 @@
package tconstruct.entity;
import tconstruct.TConstruct;
import tconstruct.common.TContent;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.tools.ToolCore;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.SpiderEffectsGroupData;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
public class BlueSlime extends EntityLiving implements IMob, IBossDisplayData
{
private static final float[] field_100000_e = new float[] { 1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F };
public float sizeOffset;
public float sizeFactor;
public float sizeHeight;
/** the time between each jump of the slime */
protected int slimeJumpDelay = 0;
public BlueSlime(World world)
{
super(world);
//this.texture = "/mods/tinker/textures/mob/slimeedible.png";
int offset = this.rand.nextInt(299);
if (offset < 149)
offset = 1;
else if (offset < 298)
offset = 2;
else
offset = 3;
int size = 1 << offset;
this.yOffset = 0.0F;
this.slimeJumpDelay = this.rand.nextInt(120) + 40;
this.setSlimeSize(size);
this.jumpMovementFactor = 0.004F * size + 0.01F;
}
protected void damageEntity (DamageSource damageSource, int damage)
{
//Minecraft.getMinecraft().getLogAgent().logInfo("Damage: "+damage);
if (damageSource.damageType.equals("arrow"))
damage = damage / 2;
super.damageEntity(damageSource, damage);
}
public String getEntityName ()
{
String s = EntityList.getEntityString(this);
if (s == null)
{
s = "generic";
}
if (getSlimeSize() >= 8)
s = "TConstruct.KingSlime";
return StatCollector.translateToLocal("entity." + s + ".name");
}
/*@Override
public void initCreature ()
{
if (getSlimeSize() == 2 && rand.nextInt(8) == 0)
{
EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj);
entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
//entityskeleton.initCreature();
this.worldObj.spawnEntityInWorld(entityskeleton);
entityskeleton.mountEntity(this);
}
if (getSlimeSize() == 4 && rand.nextInt(12) == 0)
{
EntityCreeper creeper = new EntityCreeper(this.worldObj);
creeper.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
//creeper.initCreature();
this.worldObj.spawnEntityInWorld(creeper);
creeper.mountEntity(this);
}
if (getSlimeSize() == 8)
{
for (int i = 0; i < 5; i++)
{
BlueSlime slime = new BlueSlime(this.worldObj);
slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
//slime.initCreature();
this.worldObj.spawnEntityInWorld(slime);
}
BlueSlime slime = new BlueSlime(this.worldObj);
slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
slime.setSlimeSize(2);
this.worldObj.spawnEntityInWorld(slime);
EntitySkeleton skelton = new EntitySkeleton(this.worldObj);
skelton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
//skelton.initCreature();
this.worldObj.spawnEntityInWorld(skelton);
skelton.mountEntity(slime);
}
}*/
public EntityLivingData func_110161_a(EntityLivingData par1EntityLivingData)
{
Object par1EntityLivingData1 = super.func_110161_a(par1EntityLivingData);
if (getSlimeSize() == 2 && rand.nextInt(8) == 0)
{
EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj);
entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
entityskeleton.func_110161_a(par1EntityLivingData);
this.worldObj.spawnEntityInWorld(entityskeleton);
entityskeleton.mountEntity(this);
}
if (getSlimeSize() == 4 && rand.nextInt(12) == 0)
{
EntityCreeper creeper = new EntityCreeper(this.worldObj);
creeper.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
creeper.func_110161_a(par1EntityLivingData);
this.worldObj.spawnEntityInWorld(creeper);
creeper.mountEntity(this);
}
if (getSlimeSize() == 8)
{
for (int i = 0; i < 5; i++)
{
BlueSlime slime = new BlueSlime(this.worldObj);
slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
slime.func_110161_a(par1EntityLivingData);
this.worldObj.spawnEntityInWorld(slime);
}
BlueSlime slime = new BlueSlime(this.worldObj);
slime.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
slime.setSlimeSize(2);
this.worldObj.spawnEntityInWorld(slime);
EntitySkeleton skelton = new EntitySkeleton(this.worldObj);
skelton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
skelton.func_110161_a(par1EntityLivingData);
this.worldObj.spawnEntityInWorld(skelton);
skelton.mountEntity(slime);
}
return (EntityLivingData)par1EntityLivingData1;
}
@Override
public double getMountedYOffset ()
{
return this.height * 0.3;
}
protected void jump ()
{
this.motionY = 0.05 * getSlimeSize() + 0.37;
if (this.isPotionActive(Potion.jump))
{
this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
}
if (this.isSprinting())
{
float f = this.rotationYaw * 0.017453292F;
this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
}
if (this.getBrightness(1.0F) > 0.9F && rand.nextInt(5) == 0
&& this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))
{
int size = this.getSlimeSize() - 1;
if (size < 7)
{
if (size <= 0)
this.kill();
else
this.setSlimeSize(size);
}
}
this.isAirBorne = true;
ForgeHooks.onLivingJump(this);
}
protected void fall (float par1)
{
}
protected String getSlimeParticle ()
{
return "blueslime";
}
@Override
public boolean getCanSpawnHere ()
{
return isValidLightLevel() && this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()
&& !this.worldObj.isAnyLiquid(this.boundingBox);
}
protected boolean isValidLightLevel ()
{
int x = MathHelper.floor_double(this.posX);
int y = MathHelper.floor_double(this.boundingBox.minY);
int z = MathHelper.floor_double(this.posZ);
if (y < 60 && rand.nextInt(5) != 0)
{
return false;
}
if (this.worldObj.getSavedLightValue(EnumSkyBlock.Sky, x, y, z) > this.rand.nextInt(32))
{
return false;
}
else
{
int light = this.worldObj.getBlockLightValue(x, y, z);
if (this.worldObj.isThundering())
{
int i1 = this.worldObj.skylightSubtracted;
this.worldObj.skylightSubtracted = 10;
light = this.worldObj.getBlockLightValue(x, y, z);
this.worldObj.skylightSubtracted = i1;
}
return light <= this.rand.nextInt(8);
}
}
protected void entityInit ()
{
super.entityInit();
this.dataWatcher.addObject(16, new Byte((byte) 1));
//this.dataWatcher.addObject(17, new Integer(100));
}
/*public void setSlimeSize (int size)
{
this.dataWatcher.updateObject(16, new Byte((byte) size));
this.setSize(0.6F * size, 0.6F * size);
this.setPosition(this.posX, this.posY, this.posZ);
this.setEntityHealth(this.getMaxHealth());
this.experienceValue = size + 2;
if (size >= 8)
this.experienceValue = 500;
}*/
public void setSlimeSize(int size)
{
this.dataWatcher.updateObject(16, new Byte((byte)size));
this.setSize(0.6F * (float)size, 0.6F * (float)size);
this.setPosition(this.posX, this.posY, this.posZ);
this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(this.getMaxHealth());
this.setEntityHealth(this.func_110138_aP());
this.experienceValue = size + 2^(size);
if (size >= 8)
this.experienceValue = 500;
}
public int getMaxHealth ()
{
int i = this.getSlimeSize();
if (i == 1)
return 4;
if (i == 8)
return 100;
return (int) Math.min(i * i + 8, 49);
}
/**
* Returns the size of the slime.
*/
public int getSlimeSize ()
{
return this.dataWatcher.getWatchableObjectByte(16);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("Size", this.getSlimeSize() - 1);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setSlimeSize(par1NBTTagCompound.getInteger("Size") + 1);
//this.dataWatcher.updateObject(17, Integer.valueOf(this.health));
}
/**
* Returns the name of the sound played when the slime jumps.
*/
protected String getJumpSound ()
{
return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small");
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate ()
{
if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0 && this.getSlimeSize() > 0)
{
this.isDead = true;
}
/*if (!this.worldObj.isRemote)
{
this.dataWatcher.updateObject(17, Integer.valueOf(this.health));
}*/
this.sizeFactor += (this.sizeOffset - this.sizeFactor) * 0.5F;
this.sizeHeight = this.sizeFactor;
boolean flag = this.onGround;
super.onUpdate();
int i;
if (this.onGround && !flag)
{
i = this.getSlimeSize();
for (int j = 0; j < i * 8; ++j)
{
float f = this.rand.nextFloat() * (float) Math.PI * 2.0F;
float offset = this.rand.nextFloat() * 0.5F + 0.5F;
float xPos = MathHelper.sin(f) * (float) i * 0.5F * offset;
float zPos = MathHelper.cos(f) * (float) i * 0.5F * offset;
TConstruct.proxy.spawnParticle(this.getSlimeParticle(), this.posX + (double) xPos, this.boundingBox.minY, this.posZ + (double) zPos, 0.0D, 0.0D, 0.0D);
}
if (this.makesSoundOnLand())
{
this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
}
this.sizeOffset = -0.5F;
}
else if (!this.onGround && flag)
{
this.sizeOffset = 1.0F;
}
this.func_70808_l();
if (this.worldObj.isRemote)
{
i = this.getSlimeSize();
this.setSize(0.6F * (float) i, 0.6F * (float) i);
}
}
protected void updateEntityActionState ()
{
//Minecraft.getMinecraft().getLogAgent().logInfo("Collided with "+entity.getEntityName());
this.despawnEntity();
EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
if (entityplayer != null)
{
this.faceEntity(entityplayer, 10.0F, 20.0F);
}
else if (this.onGround && this.slimeJumpDelay == 1)
{
this.rotationYaw = this.rotationYaw + rand.nextFloat() * 180 - 90;
if (rotationYaw > 360)
rotationYaw -= 360;
if (rotationYaw < 0)
rotationYaw += 360;
}
if (this.onGround && this.slimeJumpDelay-- <= 0)
{
this.slimeJumpDelay = this.getJumpDelay();
if (entityplayer != null)
{
this.slimeJumpDelay /= 12;
}
this.isJumping = true;
if (this.makesSoundOnJump())
{
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 = (float) (1 * this.getSlimeSize());
}
else
{
this.isJumping = false;
if (this.onGround)
{
this.moveStrafing = this.moveForward = 0.0F;
}
}
}
public boolean handleWaterMovement ()
{
return false;
}
protected void func_70808_l ()
{
this.sizeOffset *= 0.6F;
}
/**
* Gets the amount of time the slime needs to wait between jumps.
*/
protected int getJumpDelay ()
{
return this.rand.nextInt(120) + 40;
}
protected BlueSlime createInstance ()
{
return new BlueSlime(this.worldObj);
}
/**
* Will get destroyed next tick.
*/
public void setDead ()
{
int size = this.getSlimeSize();
if (!this.worldObj.isRemote && size > 1 && this.func_110143_aJ() <= 0 && size < 8)
{
float f = (-0.5F) * (float) size / 4.0F;
float f1 = (-0.5F) * (float) size / 4.0F;
BlueSlime entityslime = this.createInstance();
entityslime.setSlimeSize(size / 2);
entityslime.setLocationAndAngles(this.posX + (double) f, this.posY + 0.5D, this.posZ + (double) f1, this.rand.nextFloat() * 360.0F, 0.0F);
this.worldObj.spawnEntityInWorld(entityslime);
}
super.setDead();
}
protected void dropFewItems (boolean par1, int par2)
{
int size = this.getSlimeSize();
int j = this.getDropItemId();
if (j > 0 && (rand.nextInt(2) == 0) || size >= 8)
{
int k = rand.nextInt(3) + rand.nextInt(this.getSlimeSize());
if (par2 > 0)
{
k += this.rand.nextInt(par2 + 1);
}
for (int l = 0; l < k; ++l)
{
this.dropItem(j, 1);
}
}
if (size == 8)
{
ToolCore tool = getValidTool();
Item accessory = tool.getAccessoryItem();
ItemStack accessoryStack = accessory != null ? new ItemStack(tool.getAccessoryItem(), 1, 17) : null;
ItemStack toolStack = ToolBuilder.instance.buildTool(new ItemStack(tool.getHeadItem(), 1, 17), new ItemStack(tool.getHandleItem(), 1, 17), accessoryStack,
"King Slime " + tool.getToolName());
NBTTagCompound tags = toolStack.getTagCompound().getCompoundTag("InfiTool");
tags.setInteger("Attack", 3 + tool.getDamageVsEntity(null));
tags.setInteger("TotalDurability", 1500);
tags.setInteger("BaseDurability", 1500);
tags.setInteger("MiningSpeed", 800);
this.entityDropItem(toolStack, 0f);
if (rand.nextInt(5) == 0)
{
ItemStack dropStack = new ItemStack(TContent.heartCanister, 1, 1);
this.entityDropItem(dropStack, 0f);
}
}
}
ToolCore getValidTool ()
{
ToolCore tool = TConstructRegistry.tools.get(rand.nextInt(TConstructRegistry.tools.size()));
if (tool.getAccessoryItem() != null)
tool = getValidTool();
return tool;
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer (EntityPlayer par1EntityPlayer)
{
if (this.canDamagePlayer())
{
int i = this.getSlimeSize();
if (this.canEntityBeSeen(par1EntityPlayer) && this.getDistanceSqToEntity(par1EntityPlayer) < 0.6D * (double) i * 0.6D * (double) i
&& par1EntityPlayer.attackEntityFrom(DamageSource.causeMobDamage(this), this.getAttackStrength()))
{
this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
}
}
}
/**
* Indicates weather the slime is able to damage the player (based upon the slime's size)
*/
protected boolean canDamagePlayer ()
{
return this.getSlimeSize() > 1;
}
/**
* Gets the amount of damage dealt to the player when "attacked" by the slime.
*/
protected int getAttackStrength ()
{
return this.getSlimeSize();
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound ()
{
return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small");
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound ()
{
return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small");
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId ()
{
return TContent.strangeFood.itemID;
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume ()
{
return Math.min(0.05F * (float) this.getSlimeSize(), 0.3f);
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed ()
{
return 0;
}
/**
* Returns true if the slime makes a sound when it jumps (based upon the slime's size)
*/
protected boolean makesSoundOnJump ()
{
return this.getSlimeSize() > 0;
}
/**
* Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size)
*/
protected boolean makesSoundOnLand ()
{
return this.getSlimeSize() > 2;
}
/*@Override
public int getBossHealth ()
{
return this.dataWatcher.getWatchableObjectInt(17);
}*/
}
File diff suppressed because it is too large. Load diff
+15
View File
@@ -0,0 +1,15 @@
package tconstruct.entity;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.world.World;
public class Crystal extends EntityCreeper
{
public Crystal(World par1World)
{
super(par1World);
//texture = "/mods/tinker/textures/mob/crystalwater.png";
}
}
+21
View File
@@ -0,0 +1,21 @@
package tconstruct.entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.world.World;
public class CrystalGuardian extends EntityLiving
{
public CrystalGuardian(World par1World)
{
super(par1World);
//this.texture = "/mods/tinker/textures/mob/crystalguardamber.png";
}
/*@Override
public int getMaxHealth ()
{
return 100;
}*/
}
+51
View File
@@ -0,0 +1,51 @@
package tconstruct.entity;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
public class FakeBlockEntity extends Entity implements IEntityAdditionalSpawnData
{
public FakeBlockEntity(World world)
{
super(world);
preventEntitySpawning = true;
}
@Override
protected void entityInit ()
{
}
@Override
public void writeSpawnData (ByteArrayDataOutput data)
{
}
@Override
public void readSpawnData (ByteArrayDataInput data)
{
}
@Override
protected void readEntityFromNBT (NBTTagCompound var1)
{
}
@Override
protected void writeEntityToNBT (NBTTagCompound var1)
{
}
}
+25
View File
@@ -0,0 +1,25 @@
package tconstruct.entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class FancyEntityItem extends EntityItem
{
public FancyEntityItem(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public FancyEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
{
this(par1World, par2, par4, par6);
this.setEntityItemStack(par8ItemStack);
this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
}
public FancyEntityItem(World par1World)
{
super(par1World);
}
}
+443
View File
@@ -0,0 +1,443 @@
package tconstruct.entity;
import java.lang.ref.WeakReference;
import java.util.Random;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ToolCore;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityMultiPart;
import net.minecraft.entity.boss.EntityDragonPart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class GolemBase extends EntityCreature implements IInventory
{
public WeakReference<EntityLivingBase> leader; //Monster
public String ownerName = ""; //Player
public int maxHealth = 20;
public int baseAttack;
public boolean paused;
int useTime;
protected static Random rand = new Random();
//public static CoordTuple target;
public int targetX;
public int targetY;
public int targetZ;
public boolean targetLock;
public ItemStack[] inventory;
public GolemBase(World world)
{
super(world);
setupInventory();
}
public void setupInventory ()
{
inventory = new ItemStack[0];
}
/*@Override
public int getMaxHealth ()
{
//Workaround for dying on spawn
if (maxHealth == 0)
return 20;
return maxHealth;
}
@Override
public void initCreature ()
{
baseAttack = 3;
paused = false;
}*/
public EntityLivingBase getOwner ()
{
if (leader == null || leader.get() == null)
return this.worldObj.getPlayerEntityByName(ownerName);
return leader.get();
}
public void setOwner (EntityLivingBase living)
{
if (living instanceof EntityPlayer)
ownerName = ((EntityPlayer) living).username;
else
leader = new WeakReference(living);
}
public boolean isOwner (Entity entity)
{
if (entity == null)
{
return false;
}
if (entity instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer) entity;
return entityplayer.username.equalsIgnoreCase(ownerName);
}
return false;
}
public float getSpeed ()
{
return 0.25f;
}
/* AI */
@Override
protected boolean isAIEnabled ()
{
return true;
}
protected void updateWanderPath ()
{
if (!paused)
super.updateWanderPath();
}
public boolean standby()
{
return false;
}
public boolean following ()
{
return false;
}
public boolean patrolling ()
{
return true;
}
public void attackEntityAsGolem (Entity target)
{
/*ItemStack stack = getHeldItem();
if (stack == null)
target.attackEntityFrom(DamageSource.causeMobDamage(this), baseAttack);
else if (stack.getItem() instanceof ToolCore)
{
if (stack.hasTagCompound())
{
AbilityHelper.onLeftClickEntity(stack, this, target, (ToolCore) stack.getItem(), baseAttack);
}
else
target.attackEntityFrom(DamageSource.causeMobDamage(this), baseAttack);
}
else
{
if (target.canAttackWithItem())
{
if (!target.func_85031_j(this))
{
int i = stack.getDamageVsEntity(target) + baseAttack;
if (this.isPotionActive(Potion.damageBoost))
{
i += 3 << this.getActivePotionEffect(Potion.damageBoost).getAmplifier();
}
if (this.isPotionActive(Potion.weakness))
{
i -= 2 << this.getActivePotionEffect(Potion.weakness).getAmplifier();
}
int j = 0;
int k = 0;
if (target instanceof EntityLivingBase)
{
k = EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase) target);
j += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase) target);
}
if (this.isSprinting())
{
++j;
}
if (i > 0 || k > 0)
{
boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null
&& target instanceof EntityLivingBase;
if (flag && i > 0)
{
i += this.rand.nextInt(i / 2 + 2);
}
i += k;
boolean flag1 = false;
int l = EnchantmentHelper.getFireAspectModifier(this);
if (target instanceof EntityLivingBase && l > 0 && !target.isBurning())
{
flag1 = true;
target.setFire(1);
}
boolean flag2 = target.attackEntityFrom(DamageSource.causeMobDamage(this), i);
if (flag2)
{
if (j > 0)
{
target.addVelocity((double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F), 0.1D,
(double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F));
this.motionX *= 0.6D;
this.motionZ *= 0.6D;
this.setSprinting(false);
}
this.setLastAttackingEntity(target);
if (target instanceof EntityLivingBase)
{
EnchantmentThorns.func_92096_a(this, (EntityLivingBase) target, this.rand);
}
}
//ItemStack stack = this.getCurrentEquippedItem();
Object object = target;
if (target instanceof EntityDragonPart)
{
IEntityMultiPart ientitymultipart = ((EntityDragonPart) target).entityDragonObj;
if (ientitymultipart != null && ientitymultipart instanceof EntityLivingBase)
{
object = (EntityLivingBase) ientitymultipart;
}
}
if (stack != null && object instanceof EntityLivingBase)
{
//stack.hitEntity((EntityLiving)object, this);
Item.itemsList[stack.itemID].hitEntity(stack, (EntityLivingBase) object, this);
if (stack.stackSize <= 0)
{
this.destroyCurrentEquippedItem();
}
}
if (target instanceof EntityLivingBase)
{
if (l > 0 && flag2)
{
target.setFire(l * 4);
}
else if (flag1)
{
target.extinguish();
}
}
//this.addExhaustion(0.3F);
}
}
}
}*/
}
public void teleport (double x, double y, double z)
{
this.setPosition(x, y, z);
worldObj.playSoundAtEntity(this, "mob.endermen.portal", 0.5F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
}
/* Other */
protected boolean canDespawn ()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getItemIcon (ItemStack par1ItemStack, int par2)
{
Icon icon = super.getItemIcon(par1ItemStack, par2);
if (par1ItemStack.getItem().requiresMultipleRenderPasses())
{
return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
}
return icon;
}
/* Inventory */
@Override
public ItemStack getStackInSlot (int slot)
{
if (slot < 0 || slot >= inventory.length)
return null;
return inventory[slot];
}
public boolean isStackInSlot (int slot)
{
if (slot < 0 || slot >= inventory.length)
return false;
return inventory[slot] != null;
}
@Override
public int getSizeInventory ()
{
return inventory.length;
}
@Override
public int getInventoryStackLimit ()
{
return 64;
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
inventory[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
}
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
if (inventory[slot] != null)
{
if (inventory[slot].stackSize <= quantity)
{
ItemStack stack = inventory[slot];
inventory[slot] = null;
return stack;
}
ItemStack split = inventory[slot].splitStack(quantity);
if (inventory[slot].stackSize == 0)
{
inventory[slot] = null;
}
return split;
}
else
{
return null;
}
}
@Override
public String getInvName ()
{
return "golem.none";
}
@Override
public boolean isInvNameLocalized ()
{
return false;
}
@Override
public void onInventoryChanged ()
{
}
public ItemStack getStackInSlotOnClosing (int slot)
{
return null;
}
public void openChest ()
{
}
public void closeChest ()
{
}
@Override
public boolean isItemValidForSlot (int i, ItemStack itemstack)
{
return true;
}
@Override
public boolean isUseableByPlayer (EntityPlayer entityplayer)
{
return true;
}
public void destroyCurrentEquippedItem ()
{
worldObj.playSoundAtEntity(this, "random.break", 0.5F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
this.setCurrentItemOrArmor(0, null);
}
/* Saving */
public void writeEntityToNBT (NBTTagCompound tags)
{
super.writeEntityToNBT(tags);
tags.setString("OwnerName", ownerName);
NBTTagList nbttaglist = new NBTTagList();
for (int iter = 0; iter < inventory.length; iter++)
{
if (inventory[iter] != null)
{
NBTTagCompound tagList = new NBTTagCompound();
tagList.setByte("Slot", (byte) iter);
inventory[iter].writeToNBT(tagList);
nbttaglist.appendTag(tagList);
}
}
tags.setTag("Items", nbttaglist);
}
public void readEntityFromNBT (NBTTagCompound tags)
{
super.readEntityFromNBT(tags);
ownerName = tags.getString("OwnerName");
NBTTagList nbttaglist = tags.getTagList("Items");
inventory = new ItemStack[getSizeInventory()];
for (int iter = 0; iter < nbttaglist.tagCount(); iter++)
{
NBTTagCompound tagList = (NBTTagCompound) nbttaglist.tagAt(iter);
byte slotID = tagList.getByte("Slot");
if (slotID >= 0 && slotID < inventory.length)
{
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList);
}
}
}
}
+108
View File
@@ -0,0 +1,108 @@
package tconstruct.entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class MetalSlime extends BlueSlime
{
public MetalSlime(World world)
{
super(world);
//this.texture = "/mods/tinker/textures/mob/slimemetal.png";
}
public boolean attackEntityFrom (DamageSource damageSource, int damage)
{
if (!damageSource.isExplosion() && damageSource.isProjectile())
return false;
return super.attackEntityFrom(damageSource, damage);
}
public int getMaxHealth ()
{
int i = this.getSlimeSize();
if (i == 1)
return 4;
return (int) Math.min(i * i + 20, 100);
}
public int getTotalArmorValue ()
{
return super.getTotalArmorValue() + 12;
}
public void setDead ()
{
this.isDead = true;
}
/*protected void dropFewItems (boolean par1, int par2)
{
int j = this.getDropItemId();
if (j > 0)
{
int k = rand.nextInt(3) + rand.nextInt(this.getSlimeSize());
if (par2 > 0)
{
k += this.rand.nextInt(par2 + 1);
}
for (int l = 0; l < k; ++l)
{
this.dropItem(j, 1);
}
}
}*/
protected void updateEntityActionState ()
{
this.despawnEntity();
EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
if (entityplayer != null)
{
this.faceEntity(entityplayer, 10.0F, 20.0F);
}
else if (this.onGround && this.slimeJumpDelay == 1)
{
this.rotationYaw = this.rotationYaw + rand.nextFloat() * 180 - 90;
if (rotationYaw > 360)
rotationYaw -= 360;
if (rotationYaw < 0)
rotationYaw += 360;
}
if (this.onGround && this.slimeJumpDelay-- <= 0)
{
this.slimeJumpDelay = this.getJumpDelay();
if (entityplayer != null)
{
this.slimeJumpDelay /= 3;
}
this.isJumping = true;
if (this.makesSoundOnJump())
{
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 = (float) (1 * this.getSlimeSize());
}
else
{
this.isJumping = false;
if (this.onGround)
{
this.moveStrafing = this.moveForward = 0.0F;
}
}
}
}
+71
View File
@@ -0,0 +1,71 @@
package tconstruct.entity;
import tconstruct.TConstruct;
import tconstruct.common.TProxyCommon;
import tconstruct.entity.ai.GAIFellTree;
import tconstruct.entity.ai.GAIFollowOwner;
import tconstruct.entity.ai.GAISwim;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class MiniGardy extends GolemBase
{
public MiniGardy(World world)
{
super(world);
//this.texture = "/mods/tinker/textures/mob/googirl.png";
this.setSize(0.375F, 0.875F);
this.tasks.addTask(1, new GAISwim(this));
this.tasks.addTask(8, new GAIFellTree(this));
this.tasks.addTask(10, new GAIFollowOwner(this));
}
@Override
public void setupInventory ()
{
inventory = new ItemStack[14];
}
@SideOnly(Side.CLIENT)
public float getShadowSize () //Opacity, not size
{
return 1.0F;
}
public boolean interact (EntityPlayer player)
{
if (player.isSneaking())
{
if (!worldObj.isRemote)
player.openGui(TConstruct.instance, TProxyCommon.miniGardyGui, this.worldObj, this.entityId, 0, 0);
return true;
//return false;
}
else
{
ItemStack stack = this.getHeldItem();
if (stack == null)
{
ItemStack playerStack = player.getCurrentEquippedItem();
if (playerStack != null)
{
this.setCurrentItemOrArmor(0, playerStack.copy());
player.destroyCurrentEquippedItem();
}
}
else
{
if (player.inventory.addItemStackToInventory(stack.copy()))
{
//this.worldObj.playSoundAtEntity(this, par1Str, par2, par3);
this.worldObj.playSoundAtEntity(player, "random.pop", 0.3F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
this.setCurrentItemOrArmor(0, null);
}
}
return true;
}
}
}
+31
View File
@@ -0,0 +1,31 @@
package tconstruct.entity;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.world.World;
public class Skyla extends EntityCreeper
{
public Skyla(World par1World)
{
super(par1World);
//username = "Skyla";
//texture = "/mods/tinker/textures/mob/skyla.png";
}
/*@Override
public void sendChatToPlayer (String var1) {}
@Override
public boolean canCommandSenderUseCommand (int var1, String var2)
{
return false;
}
@Override
public ChunkCoordinates getPlayerCoordinates ()
{
return null;
}*/
}
+175
View File
@@ -0,0 +1,175 @@
package tconstruct.entity;
import tconstruct.TConstruct;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
public class SlimeClone extends GolemBase implements IEntityAdditionalSpawnData
{
public float sizeOffset;
public float sizeFactor;
public float sizeHeight;
public String username = "";
public String skinUrl = "";
public SlimeClone(World world)
{
super(world);
//this.texture = "/mob/char.png";
}
public SlimeClone(World world, String username)
{
this(world);
this.username = username;
}
/*@Override
public void initCreature ()
{
maxHealth = 100;
//health = 100;
baseAttack = 3;
paused = false;
}*/
public void onUpdate ()
{
if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0 && this.getSlimeSize() > 0)
{
this.isDead = true;
}
this.sizeFactor += (this.sizeOffset - this.sizeFactor) * 0.5F;
this.sizeHeight = this.sizeFactor;
boolean flag = this.onGround;
super.onUpdate();
float i;
if (this.onGround && !flag)
{
i = this.getSlimeSize();
for (int j = 0; j < i * 8; ++j)
{
float f = this.rand.nextFloat() * (float) Math.PI * 2.0F;
float offset = this.rand.nextFloat() * 0.5F + 0.5F;
float xPos = MathHelper.sin(f) * (float) i * 0.5F * offset;
float zPos = MathHelper.cos(f) * (float) i * 0.5F * offset;
TConstruct.proxy.spawnParticle(this.getSlimeParticle(), this.posX + (double) xPos, this.boundingBox.minY, this.posZ + (double) zPos, 0.0D, 0.0D, 0.0D);
}
if (this.makesSoundOnLand())
{
this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
}
this.sizeOffset = -0.5F;
}
else if (!this.onGround && flag)
{
this.sizeOffset = 1.0F;
}
this.func_70808_l();
if (this.worldObj.isRemote)
{
i = this.getSlimeSize();
this.setSize(0.6F * (float) i, 0.6F * (float) i);
}
}
protected void func_70808_l ()
{
this.sizeOffset *= 0.6F;
}
protected String getJumpSound ()
{
return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small");
}
protected void jump ()
{
this.motionY = 0.05 * getSlimeSize() + 0.37;
if (this.isPotionActive(Potion.jump))
{
this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
}
if (this.isSprinting())
{
float f = this.rotationYaw * 0.017453292F;
this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
}
this.isAirBorne = true;
ForgeHooks.onLivingJump(this);
}
protected void fall (float par1)
{
}
protected String getSlimeParticle ()
{
return "blueslime";
}
public float getSlimeSize ()
{
return 1.5f;
}
/**
* Returns true if the slime makes a sound when it jumps (based upon the slime's size)
*/
protected boolean makesSoundOnJump ()
{
return this.getSlimeSize() > 0;
}
/**
* Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size)
*/
protected boolean makesSoundOnLand ()
{
return this.getSlimeSize() > 2;
}
public void writeEntityToNBT (NBTTagCompound tags)
{
super.writeEntityToNBT(tags);
tags.setString("Username", username);
}
public void readEntityFromNBT (NBTTagCompound tags)
{
super.readEntityFromNBT(tags);
username = tags.getString("Username");
}
@Override
public void writeSpawnData (ByteArrayDataOutput data)
{
data.writeUTF(username);
}
@Override
public void readSpawnData (ByteArrayDataInput data)
{
username = data.readUTF();
skinUrl = "http://skins.minecraft.net/MinecraftSkins/" + username + ".png";
}
}
+138
View File
@@ -0,0 +1,138 @@
package tconstruct.entity.ai;
import tconstruct.entity.GolemBase;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.pathfinding.PathNavigate;
public class GAIAttackTarget extends GolemAIBase
{
private PathNavigate pathfinder;
private EntityLivingBase theTarget;
private float speed;
private int counter;
private boolean avoidsWater = true;
//public static String targetEntityRegex;
public GAIAttackTarget(GolemBase doll)
{
super(doll);
this.speed = doll.getSpeed();
this.pathfinder = doll.getNavigator();
this.setMutexBits(3);
}
@Override
public boolean shouldExecute ()
{
if (golem.paused)
{
return false;
}
/*if (golem.isStandbyMode() || golem.isRideonMode())
{
return false;
}
if (golem.getDollID() != DollRegistry.getDollID("Shanghai"))
{
return false;
}*/
theTarget = golem.getAttackTarget();
if (theTarget == null)
{
return false;
}
String name = EntityList.getEntityString(theTarget);
if (name == null)
{
return false;
}
/*Pattern targetPattern = Pattern.compile(targetEntityRegex);
Matcher targetMatcher = targetPattern.matcher(name);
if (!targetMatcher.find())
{
return false;
}*/
return true;
}
@Override
public void startExecuting ()
{
counter = 0;
this.avoidsWater = this.golem.getNavigator().getAvoidsWater();
this.golem.getNavigator().setAvoidsWater(true);
}
@Override
public boolean continueExecuting ()
{
/* if (!golem.isEnable())
{
return false;
}
if (golem.isStandbyMode() || golem.isRideonMode())
{
return false;
}*/
if (this.pathfinder.noPath())
{
return false;
}
if (this.theTarget == null)
{
return false;
}
if (!this.theTarget.isEntityAlive())
{
return false;
}
return true;
}
@Override
public void resetTask ()
{
this.theTarget = null;
this.pathfinder.clearPathEntity();
this.golem.getNavigator().setAvoidsWater(this.avoidsWater);
}
@Override
public void updateTask ()
{
if (!this.pathfinder.noPath())
{
this.golem.getLookHelper().setLookPositionWithEntity(this.theTarget, 10.0F, (float) this.golem.getVerticalFaceSpeed());
}
if (--this.counter <= 0)
{
this.counter = 20;
this.pathfinder.tryMoveToEntityLiving(this.theTarget, this.speed);
if (this.golem.getDistanceSqToEntity(this.theTarget) < 9f && this.golem.getEntitySenses().canSee(this.theTarget))
{
if (this.golem.getHeldItem() != null)
{
this.golem.swingItem();
}
//theTarget.attackEntityFrom(DamageSource.causeMobDamage(golem), attackStrength);
golem.attackEntityAsGolem(theTarget);
/*if (golem.getOwner() != null)
{
theTarget.attackEntityFrom(DamageSource.causePlayerDamage(golem.getOwner()), attackStrength);
}
else
{*/
//}
}
}
}
}
+233
View File
@@ -0,0 +1,233 @@
package tconstruct.entity.ai;
import tconstruct.entity.GolemBase;
import net.minecraft.block.Block;
import net.minecraft.block.StepSound;
import net.minecraft.util.MathHelper;
public class GAIFellTree extends GolemAIBase
{
private int counter;
private int logID;
private int blockStrength;
private int cutX, cutY, cutZ;
public static int cutRange = 4;
public static double cutSpeed = 2.5;
public GAIFellTree(GolemBase doll)
{
super(doll);
this.setMutexBits(3);
}
@Override
public boolean shouldExecute ()
{
if (golem.paused)
{
return false;
}
int golemX = MathHelper.floor_double(golem.posX);
int golemY = MathHelper.floor_double(golem.posY + (double) golem.getEyeHeight());
int golemZ = MathHelper.floor_double(golem.posZ);
int logCount = 0;
int leavesCount = 0;
int targetX = cutRange;
int targetY = 0;
int targetZ = cutRange;
boolean isTarget = false;
for (int iterX = -cutRange; iterX <= cutRange; ++iterX)
{
for (int iterZ = -cutRange; iterZ <= cutRange; ++iterZ)
{
int dy = 0;
int distanceToBlock = Math.abs(iterX) + Math.abs(iterZ);
if (distanceToBlock > cutRange)
{
continue;
}
int bid = world.getBlockId(golemX + iterX, golemY + dy, golemZ + iterZ);
Block log = Block.blocksList[bid];
if (log == null)
{
continue;
}
if (log.isWood(world, golemX + iterX, golemY + dy, golemZ + iterZ))
{
if (Math.abs(targetX) + Math.abs(targetZ) > distanceToBlock)
{
while (golemY + dy > 0)
{
int cbid = world.getBlockId(golemX + iterX, golemY + dy - 1, golemZ + iterZ);
if (cbid != bid)
{
break;
}
--dy;
}
int lCount = 0;
int blockCount = 0;
while (golemY + dy < world.getHeight())
{
int cbid = world.getBlockId(golemX + iterX, golemY + dy, golemZ + iterZ);
if (cbid != bid)
{
break;
}
int[][] coords = new int[][] { { golemX + iterX + 1, golemY + dy, golemZ + iterZ }, { golemX + iterX - 1, golemY + dy, golemZ + iterZ },
{ golemX + iterX, golemY + dy, golemZ + iterZ + 1 }, { golemX + iterX, golemY + dy, golemZ + iterZ - 1 } };
for (int i = 0; i < 4; ++i)
{
Block leaves = Block.blocksList[world.getBlockId(coords[i][0], coords[i][1], coords[i][2])];
if (leaves != null && leaves.isLeaves(world, coords[i][0], coords[i][1], coords[i][2]))
{
blockCount++;
}
}
++lCount;
++dy;
}
if (blockCount >= 4)
{
targetX = iterX;
targetY = dy - 1;
targetZ = iterZ;
isTarget = true;
logCount = blockCount;
leavesCount = lCount;
logID = bid;
}
}
}
}
}
golem.targetX = golemX + targetX;
golem.targetY = golemY + targetY;
golem.targetZ = golemZ + targetZ;
golem.targetLock = isTarget;
if (!isTarget)
{
return false;
}
golem.teleport((double) (golem.targetX) + 0.5D, (double) (golem.targetY + 1), (double) (golem.targetZ) + 0.5D);
golem.getNavigator().clearPathEntity();
return true;
}
public void startExecuting ()
{
counter = 0;
}
public boolean continueExecuting ()
{
if (golem.paused)
{
return false;
}
if (Math.abs(MathHelper.floor_double(golem.posX - golem.targetX)) + Math.abs(MathHelper.floor_double(golem.posY - golem.targetY))
+ Math.abs(MathHelper.floor_double(golem.posZ - golem.targetZ)) > cutRange)
{
System.out.println("Too far away");
return false;
}
if (!golem.targetLock)
{
System.out.println("Target lost");
return false;
}
return true;
}
@Override
public void resetTask ()
{
golem.targetLock = false;
}
@Override
public void updateTask ()
{
if (counter == 0)
{
boolean isCutting = false;
for (int dx = -cutRange; dx <= cutRange; ++dx)
{
for (int dz = -cutRange; dz <= cutRange; ++dz)
{
if (Math.abs(dx) + Math.abs(dz) > cutRange)
{
continue;
}
if (world.getBlockId(golem.targetX + dx, golem.targetY, golem.targetZ + dz) == logID)
{
cutX = golem.targetX + dx;
cutY = golem.targetY;
cutZ = golem.targetZ + dz;
isCutting = true;
}
if (isCutting)
{
break;
}
}
if (isCutting)
{
break;
}
}
if (!isCutting)
{
cutX = golem.targetX;
cutY = golem.targetY;
cutZ = golem.targetZ;
golem.targetY--;
if (world.getBlockId(golem.targetX, golem.targetY, golem.targetZ) == logID)
{
isCutting = true;
}
else
{
golem.targetLock = isCutting = false;
return;
}
}
Block b = Block.blocksList[world.getBlockId(cutX, cutY, cutZ)];
blockStrength = b == null ? 0 : MathHelper.floor_double(1.0 + 30.0 * b.getBlockHardness(world, cutX, cutY, cutZ) / cutSpeed);
blockStrength = blockStrength < 0 ? 0 : blockStrength;
}
if (counter >= blockStrength)
{
Block b = Block.blocksList[world.getBlockId(cutX, cutY, cutZ)];
if (b != null)
{
world.destroyBlock(cutX, cutY, cutZ, true);
}
counter = 0;
return;
}
if (counter % 4 == 0)
{
Block b = Block.blocksList[world.getBlockId(golem.targetX, golem.targetY, golem.targetZ)];
if (b != null)
{
StepSound stepsound = b.stepSound;
world.playSoundEffect(golem.targetX + 0.5f, golem.targetY + 0.5f, golem.targetZ + 0.5f, stepsound.getBreakSound(), (stepsound.getVolume() + 1.0f) / 8f, stepsound.getPitch() * 0.5f);
}
}
this.golem.getLookHelper().setLookPosition((double) (cutX) + 0.5D, (double) (cutY) + 0.5D, (double) (cutZ) + 0.5D, 20.0F, (float) this.golem.getVerticalFaceSpeed());
counter++;
}
}
+167
View File
@@ -0,0 +1,167 @@
package tconstruct.entity.ai;
import java.util.List;
import tconstruct.entity.GolemBase;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.entity.passive.EntitySheep;
public class GAIFindTarget extends GolemAIBase
{
private int counter;
public static double searchRange = 16;
public static double searchHeight = 4;
public GAIFindTarget(GolemBase golem)
{
super(golem);
this.setMutexBits(8);
}
public boolean shouldExecute ()
{
if (golem.paused)
{
return false;
}
return true;
}
public void startExecuting ()
{
counter = 0;
}
public boolean continueExecuting ()
{
return !golem.paused;
}
public void updateTask ()
{
if (counter == 0)
{
List<EntityLiving> targetList = (List<EntityLiving>) (world.getEntitiesWithinAABB(EntityLiving.class, golem.boundingBox.expand(searchRange, searchHeight, searchRange)));
EntityLiving theTarget = null;
EntityLiving stealTarget = null;
theTarget = null;
for (EntityLiving e : targetList)
{
if (golem.patrolling())
{
if (e instanceof IMob)
{
if (theTarget == null)
{
theTarget = e;
}
else
{
if (golem.getDistanceSqToEntity(theTarget) > golem.getDistanceSqToEntity(e))
{
theTarget = e;
}
}
}
}
if (golem.following())
{
Entity tt = null;
if (e instanceof EntityCreature)
{
tt = ((EntityCreature) e).getEntityToAttack();
}
else
{
tt = e.getAttackTarget();
}
if (golem.isOwner(tt))
{
if (theTarget == null)
{
theTarget = e;
}
else
{
if (golem.getDistanceSqToEntity(theTarget) > golem.getDistanceSqToEntity(e))
{
theTarget = e;
}
}
}
}
if (golem.patrolling())
{
if (e instanceof EntitySheep)
{
EntitySheep sheep = (EntitySheep) e;
if (!sheep.getSheared() && !sheep.isChild())
{
if (stealTarget == null)
{
stealTarget = e;
}
else
{
if (golem.getDistanceSqToEntity(stealTarget) > golem.getDistanceSqToEntity(e))
{
stealTarget = e;
}
}
}
}
else if (e instanceof EntityChicken || e instanceof EntityMooshroom || e instanceof EntityIronGolem)
{
if (stealTarget == null)
{
stealTarget = e;
}
else
{
if (golem.getDistanceSqToEntity(stealTarget) > golem.getDistanceSqToEntity(e))
{
stealTarget = e;
}
}
}
}
}
/*StringBuffer msg = new StringBuffer(golem.getDollName() + " : ");
if (entityCount.isEmpty())
{
msg.append("No target");
golem.chatMessage(msg.toString(), 2);
}
else
{
Iterator it = entityCount.keySet().iterator();
while (it.hasNext())
{
String s = (String) it.next();
int v = entityCount.get(s).intValue();
msg.append(s);
msg.append("[");
msg.append(v);
msg.append("] ");
}
golem.chatMessage(msg.toString(), 1);
}*/
golem.setAttackTarget(theTarget == null ? stealTarget : theTarget);
}
counter = (counter + 1) % 20;
}
}
+106
View File
@@ -0,0 +1,106 @@
package tconstruct.entity.ai;
import tconstruct.entity.GolemBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.util.MathHelper;
public class GAIFollowOwner extends GolemAIBase
{
private EntityLivingBase leader;
private float speed;
private float maxDist;
private float minDist;
private PathNavigate pathfinder;
private boolean avoidsWater;
private int counter;
public GAIFollowOwner(GolemBase golem)
{
super(golem);
this.speed = golem.getSpeed();
this.minDist = 4.0f;
this.maxDist = 2.5f;
this.pathfinder = golem.getNavigator();
this.setMutexBits(3);
}
public boolean shouldExecute ()
{
EntityLivingBase owner = this.golem.getOwner();
if (owner == null)
{
return false;
}
if (this.golem.getDistanceSqToEntity(owner) < (double) (this.minDist * this.minDist))
{
return false;
}
this.leader = owner;
return true;
}
public boolean continueExecuting ()
{
if (this.pathfinder.noPath())
{
return false;
}
if (this.golem.getDistanceSqToEntity(this.leader) < (double) (this.maxDist * this.maxDist))
{
return false;
}
return true;
}
public void startExecuting ()
{
this.counter = 0;
this.avoidsWater = this.golem.getNavigator().getAvoidsWater();
this.golem.getNavigator().setAvoidsWater(false);
}
public void resetTask ()
{
this.leader = null;
this.pathfinder.clearPathEntity();
this.golem.getNavigator().setAvoidsWater(this.avoidsWater);
}
public void updateTask ()
{
this.golem.getLookHelper().setLookPositionWithEntity(this.leader, 10.0F, (float) this.golem.getVerticalFaceSpeed());
if (--this.counter <= 0)
{
this.counter = 10;
if (!this.pathfinder.tryMoveToEntityLiving(this.leader, this.speed))
{
if (this.golem.getDistanceSqToEntity(this.leader) >= 144.0D)
{
int var1 = MathHelper.floor_double(this.leader.posX) - 2;
int var2 = MathHelper.floor_double(this.leader.posZ) - 2;
int var3 = MathHelper.floor_double(this.leader.boundingBox.minY);
for (int var4 = 0; var4 <= 4; ++var4)
{
for (int var5 = 0; var5 <= 4; ++var5)
{
if ((var4 < 1 || var5 < 1 || var4 > 3 || var5 > 3) && this.world.doesBlockHaveSolidTopSurface(var1 + var4, var3 - 1, var2 + var5)
&& !this.world.isBlockNormalCube(var1 + var4, var3, var2 + var5) && !this.world.isBlockNormalCube(var1 + var4, var3 + 1, var2 + var5))
{
this.golem.setLocationAndAngles((double) ((float) (var1 + var4) + 0.5F), (double) var3, (double) ((float) (var2 + var5) + 0.5F), this.golem.rotationYaw,
this.golem.rotationPitch);
this.pathfinder.clearPathEntity();
return;
}
}
}
}
}
}
}
}
+38
View File
@@ -0,0 +1,38 @@
package tconstruct.entity.ai;
import tconstruct.entity.GolemBase;
public class GAISwim extends GolemAIBase
{
public GAISwim(GolemBase golem)
{
super(golem);
this.setMutexBits(4);
golem.getNavigator().setCanSwim(true);
}
public boolean shouldExecute()
{
if(golem.isInWater() || this.golem.handleLavaMovement())
{
return true;
}
return false;
}
/*public void startExecuting()
{
if(golem.standby())
{
golem.setPatrolMode();
}
}*/
public void updateTask()
{
if (this.golem.getRNG().nextFloat() < 0.8F)
{
this.golem.getJumpHelper().setJumping();
}
}
}
+23
View File
@@ -0,0 +1,23 @@
package tconstruct.entity.ai;
import tconstruct.entity.GolemBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.world.World;
public class GolemAIBase extends EntityAIBase
{
protected GolemBase golem;
protected World world;
public GolemAIBase(GolemBase entity)
{
golem = entity;
world = entity.worldObj;
}
@Override
public boolean shouldExecute ()
{
return false;
}
}
@@ -0,0 +1,638 @@
package tconstruct.entity.projectile;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet70GameEvent;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ReportedException;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData
{
public ItemStack returnStack;
public float mass;
public int baseDamage;
private float knockbackStrengthMod;
public ArrowEntity(World par1World)
{
super(par1World);
}
public ArrowEntity(World world, EntityLivingBase living, float baseSpeed, ItemStack stack)
{
super(world, living, baseSpeed);
this.returnStack = stack;
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
this.mass = toolTag.getFloat("Mass");
this.baseDamage = toolTag.getInteger("Attack");
}
@Override
public void onCollideWithPlayer (EntityPlayer par1EntityPlayer)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(returnStack))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, 1);
this.setDead();
}
}
}
@Override
public void onUpdate ()
{
this.onEntityUpdate();
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
}
int i = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
if (i > 0)
{
Block.blocksList[i].setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
AxisAlignedBB axisalignedbb = Block.blocksList[i].getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);
if (axisalignedbb != null && axisalignedbb.isVecInside(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ)))
{
this.inGround = true;
}
}
if (this.arrowShake > 0)
{
--this.arrowShake;
}
if (this.inGround)
{
int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
if (j == this.inTile && k == this.inData)
{
++this.ticksInGround;
if (this.ticksInGround == 120000)
{
this.setDead();
}
}
else
{
this.inGround = false;
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
else
{
++this.ticksInAir;
Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true);
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int l;
float ySpeed;
for (l = 0; l < list.size(); ++l)
{
Entity entity1 = (Entity) list.get(l);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
ySpeed = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) ySpeed, (double) ySpeed, (double) ySpeed);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).func_96122_a(entityplayer))
{
movingobjectposition = null;
}
}
float speed;
float f3;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
double damageSpeed = (double) speed * this.damage;
damageSpeed *= baseDamage;
damageSpeed /= 5D;
int damageInflicted = MathHelper.ceiling_double_int(damageSpeed);
if (this.getIsCritical())
{
damageInflicted += this.rand.nextInt(damageInflicted / 2 + 2);
}
if (!worldObj.isRemote)
{
System.out.println("Speed: " + damageSpeed);
System.out.println("Damage: " + damageInflicted);
}
DamageSource damagesource = null;
if (this.shootingEntity == null)
{
damagesource = DamageSource.causeArrowDamage(this, this);
}
else
{
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, damageInflicted))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entityliving = (EntityLivingBase) movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0 || this.knockbackStrengthMod > 0)
{
f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f3 > 0.0F)
{
float knockback = knockbackStrength + knockbackStrengthMod;
movingobjectposition.entityHit.addVelocity(this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3, 0.1D, this.motionZ
* (double) knockback * 0.6000000238418579D / (double) f3);
}
}
if (this.shootingEntity != null)
{
EnchantmentThorns.func_92096_a(this.shootingEntity, entityliving, this.rand);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer
&& this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
}
}
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
this.motionX = 0;
this.motionZ = 0;
if (movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) movingobjectposition.entityHit;
if (player.inventory.addItemStackToInventory(returnStack))
this.setDead();
}
else if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase living = (EntityLivingBase) movingobjectposition.entityHit;
if (addItemStackToInventory(returnStack, living))
this.setDead();
}
}
}
else
{
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
}
else
{
this.xTile = movingobjectposition.blockX;
this.yTile = movingobjectposition.blockY;
this.zTile = movingobjectposition.blockZ;
this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double) speed * 0.05000000074505806D;
this.posY -= this.motionY / (double) speed * 0.05000000074505806D;
this.posZ -= this.motionZ / (double) speed * 0.05000000074505806D;
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
this.setIsCritical(false);
if (this.inTile != 0)
{
Block.blocksList[this.inTile].onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this);
}
}
}
if (this.getIsCritical())
{
for (l = 0; l < 4; ++l)
{
this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double) l / 4.0D, this.posY + this.motionY * (double) l / 4.0D, this.posZ + this.motionZ * (double) l / 4.0D,
-this.motionX, -this.motionY + 0.2D, -this.motionZ);
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) speed) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float dropSpeed = 0.99F;
float speedMod = 1.05f + (mass / 1.26F) / 6F;
ySpeed = 0.05F * speedMod;
if (this.isInWater())
{
for (int j1 = 0; j1 < 4; ++j1)
{
f3 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX,
this.motionY, this.motionZ);
}
dropSpeed = 0.8F;
}
this.motionX *= (double) dropSpeed;
this.motionY *= (double) dropSpeed;
this.motionZ *= (double) dropSpeed;
this.motionY -= (double) ySpeed;
this.setPosition(this.posX, this.posY, this.posZ);
this.doBlockCollisions();
}
}
public boolean addItemStackToInventory (ItemStack par1ItemStack, EntityLivingBase living)
{
if (par1ItemStack == null)
{
return false;
}
else
{
try
{
int stackSize;
/*if (par1ItemStack.isItemDamaged())
{
slotID = this.getFirstEmptyStack(living);
if (slotID >= 0)
{
living.setCurrentItemOrArmor(slotID, par1ItemStack);
living.func_96120_a(slotID, 2.0f);
par1ItemStack.stackSize = 0;
return true;
}
else
{
return false;
}
}
else*/
{
do
{
stackSize = par1ItemStack.stackSize;
par1ItemStack.stackSize = this.storePartialItemStack(par1ItemStack, living);
} while (par1ItemStack.stackSize > 0 && par1ItemStack.stackSize < stackSize);
return par1ItemStack.stackSize < stackSize;
}
}
catch (Throwable throwable)
{
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added");
crashreportcategory.addCrashSection("Item ID", Integer.valueOf(par1ItemStack.itemID));
crashreportcategory.addCrashSection("Item data", Integer.valueOf(par1ItemStack.getItemDamage()));
//crashreportcategory.addCrashSectionCallable("Item name", new CallableItemName(this, par1ItemStack));
throw new ReportedException(crashreport);
}
}
}
public int getFirstEmptyStack (EntityLivingBase living)
{
for (int i = 0; i < 5; ++i)
{
if (living.getCurrentItemOrArmor(i) == null)
{
return i;
}
}
return -1;
}
private int storePartialItemStack (ItemStack par1ItemStack, EntityLivingBase living)
{
int i = par1ItemStack.itemID;
int j = par1ItemStack.stackSize;
int slotID;
if (par1ItemStack.getMaxStackSize() == 1)
{
slotID = this.getFirstEmptyStack(living);
if (slotID < 0)
{
return j;
}
else
{
/*if (this.mainInventory[k] == null)
{
this.mainInventory[k] = par1ItemStack;
}*/
if (living.getCurrentItemOrArmor(slotID) == null)
{
living.setCurrentItemOrArmor(slotID, par1ItemStack);
if (living instanceof EntityLiving)
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
}
return 0;
}
}
else
{
slotID = this.storeItemStack(par1ItemStack, living);
if (slotID < 0)
{
slotID = this.getFirstEmptyStack(living);
}
if (slotID < 0)
{
return j;
}
else
{
ItemStack stack = living.getCurrentItemOrArmor(slotID);
if (stack == null)
{
living.setCurrentItemOrArmor(slotID, par1ItemStack);
if (living instanceof EntityLiving)
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
return par1ItemStack.stackSize;
}
else
{
int l = j;
if (j > stack.getMaxStackSize() - stack.stackSize)
{
l = stack.getMaxStackSize() - stack.stackSize;
}
if (l > 64 - stack.stackSize)
{
l = 64 - stack.stackSize;
}
if (l == 0)
{
return j;
}
else
{
j -= l;
stack.stackSize++;
living.setCurrentItemOrArmor(slotID, stack);
if (living instanceof EntityLiving)
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
return j;
}
}
}
}
}
private int storeItemStack (ItemStack par1ItemStack, EntityLivingBase living)
{
for (int slotID = 0; slotID < 5; ++slotID)
{
ItemStack stack = living.getCurrentItemOrArmor(slotID);
if (stack != null && stack.itemID == par1ItemStack.itemID && stack.isStackable() && stack.stackSize < stack.getMaxStackSize() && stack.stackSize < 64
&& (!stack.getHasSubtypes() || stack.getItemDamage() == par1ItemStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, par1ItemStack))
{
return slotID;
}
}
return -1;
}
public void setKnockbackModStrength (float par1)
{
this.knockbackStrengthMod = par1;
}
public void writeEntityToNBT (NBTTagCompound tags)
{
super.writeEntityToNBT(tags);
tags.setCompoundTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
}
public void readEntityFromNBT (NBTTagCompound tags)
{
super.readEntityFromNBT(tags);
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
}
@Override
public void writeSpawnData (ByteArrayDataOutput data)
{
if (!returnStack.hasTagCompound())
this.kill();
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
data.writeShort(returnStack.itemID);
data.writeFloat(rotationYaw);
data.writeFloat(mass);
data.writeInt(tags.getInteger("RenderHandle"));
data.writeInt(tags.getInteger("RenderHead"));
data.writeInt(tags.getInteger("RenderAccessory"));
int effects = 0;
if (tags.hasKey("Effect1"))
effects++;
if (tags.hasKey("Effect2"))
effects++;
if (tags.hasKey("Effect3"))
effects++;
if (tags.hasKey("Effect4"))
effects++;
if (tags.hasKey("Effect5"))
effects++;
if (tags.hasKey("Effect6"))
effects++;
data.writeInt(effects);
switch (effects)
{
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
}
}
@Override
public void readSpawnData (ByteArrayDataInput data)
{
returnStack = new ItemStack(data.readShort(), 1, 0);
rotationYaw = data.readFloat();
mass = data.readFloat();
NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound toolTag = new NBTTagCompound();
toolTag.setInteger("RenderHandle", data.readInt());
toolTag.setInteger("RenderHead", data.readInt());
toolTag.setInteger("RenderAccessory", data.readInt());
switch (data.readInt())
{
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
}
compound.setCompoundTag("InfiTool", toolTag);
returnStack.setTagCompound(compound);
}
public ItemStack getEntityItem ()
{
return returnStack;
}
}
@@ -0,0 +1,94 @@
package tconstruct.entity.projectile;
import tconstruct.items.tools.Dagger;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ToolCore;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class DaggerEntity extends RotatingBase
{
public DaggerEntity(World world)
{
super(world);
}
public DaggerEntity(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
super(world, entityplayer, 0.75F, 0.8F);
//System.out.println("Stack: "+itemstack);
returnStackSlot = entityplayer.inventory.currentItem;
returnStack = itemstack;
}
public DaggerEntity(World world, EntityPlayer entityplayer, float f, float g)
{
super(world, entityplayer, f, g);
}
/*public void entityInit ()
{
super.entityInit();
}*/
@Override
public void onHit (MovingObjectPosition movingobjectposition)
{
if (movingobjectposition.entityHit != null)
{
if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeMobDamage(owner), damageDealt))
{
worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
motionX *= -0.1D;
motionY *= -0.1D;
motionZ *= -0.1D;
rotationYaw += 180F;
prevRotationYaw += 180F;
ticksInAir = 0;
if (movingobjectposition.entityHit instanceof EntityLiving)
{
Dagger dagger = (Dagger) returnStack.getItem();
this.hitEntity(returnStack, (EntityLiving) movingobjectposition.entityHit, owner, dagger);
}
}
}
else
{
onGround = true;
xTile = movingobjectposition.blockX;
yTile = movingobjectposition.blockY;
zTile = movingobjectposition.blockZ;
inTile = worldObj.getBlockId(xTile, yTile, zTile);
motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
float f = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
posX -= (motionX / (double) f) * 0.05D;
posY -= (motionY / (double) f) * 0.05D;
posZ -= (motionZ / (double) f) * 0.05D;
worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
arrowShake = 7;
if (!worldObj.isRemote)
AbilityHelper.damageTool(returnStack, 1, owner, false);
}
}
public boolean hitEntity (ItemStack stack, EntityLiving mob, EntityPlayer player, ToolCore weapon)
{
if (!worldObj.isRemote && player.canAttackWithItem())
{
AbilityHelper.onLeftClickEntity(stack, player, mob, weapon);
}
return true;
}
protected void dealFireDamage (int i)
{
}
}
@@ -0,0 +1,192 @@
package tconstruct.entity.projectile;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class LaunchedPotion extends EntityThrowable
{
/**
* The damage value of the thrown potion that this EntityPotion represents.
*/
private ItemStack potionDamage;
public LaunchedPotion(World par1World)
{
super(par1World);
}
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, int par3)
{
this(par1World, par2EntityLiving, new ItemStack(Item.potion, 1, par3));
}
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, ItemStack par3ItemStack)
{
super(par1World, par2EntityLiving);
this.potionDamage = par3ItemStack;
}
@SideOnly(Side.CLIENT)
public LaunchedPotion(World par1World, double par2, double par4, double par6, int par8)
{
this(par1World, par2, par4, par6, new ItemStack(Item.potion, 1, par8));
}
public LaunchedPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
{
super(par1World, par2, par4, par6);
this.potionDamage = par8ItemStack;
}
/**
* Gets the amount of gravity to apply to the thrown entity with each tick.
*/
protected float getGravityVelocity ()
{
return 0.05F;
}
protected float func_70182_d ()
{
return 1.0F;
}
protected float func_70183_g ()
{
return -10.0F;
}
public void setPotionDamage (int par1)
{
if (this.potionDamage == null)
{
this.potionDamage = new ItemStack(Item.potion, 1, 0);
}
this.potionDamage.setItemDamage(par1);
}
/**
* Returns the damage value of the thrown potion that this EntityPotion represents.
*/
public int getPotionDamage ()
{
if (this.potionDamage == null)
{
this.potionDamage = new ItemStack(Item.potion, 1, 0);
}
return this.potionDamage.getItemDamage();
}
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact (MovingObjectPosition par1MovingObjectPosition)
{
if (!this.worldObj.isRemote)
{
List list = Item.potion.getEffects(this.potionDamage);
if (list != null && !list.isEmpty())
{
AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
if (list1 != null && !list1.isEmpty())
{
Iterator iterator = list1.iterator();
while (iterator.hasNext())
{
EntityLivingBase entityliving = (EntityLivingBase) iterator.next();
double d0 = this.getDistanceSqToEntity(entityliving);
if (d0 < 16.0D)
{
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
if (entityliving == par1MovingObjectPosition.entityHit)
{
d1 = 1.0D;
}
Iterator iterator1 = list.iterator();
while (iterator1.hasNext())
{
PotionEffect potioneffect = (PotionEffect) iterator1.next();
int i = potioneffect.getPotionID();
if (Potion.potionTypes[i].isInstant())
{
Potion.potionTypes[i].affectEntity(this.getThrower(), entityliving, potioneffect.getAmplifier(), d1);
}
else
{
int j = (int) (d1 * (double) potioneffect.getDuration() + 0.5D);
if (j > 20)
{
entityliving.addPotionEffect(new PotionEffect(i, j, potioneffect.getAmplifier()));
}
}
}
}
}
}
}
this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionDamage());
this.setDead();
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
if (par1NBTTagCompound.hasKey("Potion"))
{
this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion"));
}
else
{
this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue"));
}
if (this.potionDamage == null)
{
this.setDead();
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
if (this.potionDamage != null)
{
par1NBTTagCompound.setCompoundTag("Potion", this.potionDamage.writeToNBT(new NBTTagCompound()));
}
}
}
@@ -0,0 +1,486 @@
package tconstruct.entity.projectile;
import java.util.List;
import tconstruct.library.tools.AbilityHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
{
public RotatingBase(World world)
{
super(world);
texID = 0;
tex2ID = 16 * 3;
returnStackSlot = -1;
hasHitGround = false;
hasHitMob = false;
damageDealt = 4;
maxGroundTicks = 2400;
xTile = -1;
yTile = -1;
zTile = -1;
inTile = 0;
onGround = false;
arrowShake = 0;
ticksInAir = 0;
setSize(0.5F, 0.5F);
}
public RotatingBase(World world, double d, double d1, double d2)
{
this(world);
setPosition(d, d1, d2);
yOffset = 0.0F;
}
public RotatingBase(World world, EntityPlayer entityliving, float f, float f1)
{
this(world);
owner = entityliving;
setLocationAndAngles(entityliving.posX, entityliving.posY + (double) entityliving.getEyeHeight(), entityliving.posZ, entityliving.rotationYaw, entityliving.rotationPitch);
posX -= MathHelper.cos((rotationYaw / 180F) * 3.141593F) * 0.16F;
posY -= 0.10000000149011612D;
posZ -= MathHelper.sin((rotationYaw / 180F) * 3.141593F) * 0.16F;
setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
setArrowHeading(motionX, motionY, motionZ, f, f1);
}
/*public void setOnGround(boolean flag)
{
onGround = flag;
this.dataWatcher.updateObject(6, Byte.valueOf((byte) (flag == true ? 1 : 0)));
}
public boolean getOnGround()
{
return this.dataWatcher.getWatchableObjectByte(0) == 1 ? true : false;
}*/
@Override
protected void entityInit ()
{
}
public void damageItem (int i, boolean flag)
{
if (!flag)
{
return;
}
if (returnStack.stackSize < 1)
{
for (int j = 0; j < 8; j++)
{
worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
}
//kill();
}
}
/*
public void returnToPlayer()
{
damageDagger(0, true);
if(returnStack.stackSize < 1)
{
return;
}
if(returnStackSlot > 0)
{
mod_Infi2x2.forceAddToInv((EntityPlayer)returnsTo, returnStack, returnStackSlot, true);
} else
{
mod_Infi2x2.addToInv((EntityPlayer)returnsTo, returnStack, true);
}
}
*/
public void determineRotation ()
{
rotationPitch = -57.29578F * (float) Math.atan2(motionY, motionX);
double d = Math.sqrt((double) (rotationYaw * rotationYaw) + motionY * motionY);
prevRotationYaw = -57.29578F * (float) Math.atan2(motionZ, d);
}
public void onHit (MovingObjectPosition movingobjectposition)
{
}
public void setArrowHeading (double d, double d1, double d2, float f, float f1)
{
float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
d /= f2;
d1 /= f2;
d2 /= f2;
d += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
d1 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
d2 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
d *= f;
d1 *= f;
d2 *= f;
motionX = d;
motionY = d1;
motionZ = d2;
float f3 = MathHelper.sqrt_double(d * d + d2 * d2);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f3) * 180D) / 3.1415927410125732D);
ticksInGround = 0;
}
@Override
public void setVelocity (double d, double d1, double d2)
{
motionX = d;
motionY = d1;
motionZ = d2;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(d * d + d2 * d2);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f) * 180D) / 3.1415927410125732D);
}
}
@Override
public void onUpdate ()
{
super.onUpdate();
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI);
}
if (arrowShake > 0)
{
arrowShake--;
}
if (onGround)
{
int i = worldObj.getBlockId(xTile, yTile, zTile);
if (i != inTile)
{
onGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksInGround = 0;
ticksInAir = 0;
}
else
{
/*this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;*/
/*ticksInGround++;
if (ticksInGround == 1200)
{
setDead();
}
if (ticksInGround == maxGroundTicks)
{
setDead();
}*/
if (!hasHitGround)
{
hasHitGround = true;
damageItem(1, true);
}
return;
}
return;
}
else
{
ticksInAir++;
}
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movingobjectposition = worldObj.clip(vec3d, vec3d1);
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (movingobjectposition != null)
{
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int j = 0; j < list.size(); j++)
{
Entity entity1 = (Entity) list.get(j);
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5)
{
continue;
}
float f3 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f3, f3, f3);
MovingObjectPosition movingobjectposition2 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (movingobjectposition2 == null)
{
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition2.hitVec);
if (d1 < d || d == 0.0D)
{
entity = entity1;
d = d1;
}
}
if (entity != null)
{
MovingObjectPosition movingobjectposition1 = new MovingObjectPosition(entity);
onHit(movingobjectposition1);
}
if (movingobjectposition != null)
{
onHit(movingobjectposition);
}
posX += motionX;
posY += motionY;
posZ += motionZ;
float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F)
{
}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
{
}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
{
}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
{
}
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f2 = 0.99F;
float f4 = 0.03F;
if (isInWater())
{
for (int k = 0; k < 4; k++)
{
float f5 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * (double) f5, posY - motionY * (double) f5, posZ - motionZ * (double) f5, motionX, motionY, motionZ);
}
f2 = 0.8F;
}
motionX *= f2;
motionY *= f2;
motionZ *= f2;
motionY -= f4;
setPosition(posX, posY, posZ);
if (!onGround)
{
prevBoomerangRotation = boomerangRotation;
for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F)
{
}
}
}
/*public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
if (par1NBTTagCompound.hasKey("Potion"))
{
this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion"));
}
else
{
this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue"));
}
if (this.potionDamage == null)
{
this.setDead();
}
}
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
if (this.potionDamage != null)
{
}
}*/
public void writeEntityToNBT (NBTTagCompound tags)
{
tags.setCompoundTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
tags.setShort("xTile", (short) xTile);
tags.setShort("yTile", (short) yTile);
tags.setShort("zTile", (short) zTile);
tags.setByte("inTile", (byte) inTile);
tags.setByte("shake", (byte) arrowShake);
tags.setByte("onGround", (byte) (onGround ? 1 : 0));
}
public void readEntityFromNBT (NBTTagCompound tags)
{
//super.readEntityFromNBT(tags);
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
xTile = tags.getShort("xTile");
yTile = tags.getShort("yTile");
zTile = tags.getShort("zTile");
inTile = tags.getByte("inTile") & 0xff;
arrowShake = tags.getByte("shake") & 0xff;
onGround = tags.getByte("onGround") == 1;
}
public void onCollideWithPlayer (EntityPlayer entityplayer)
{
onCollideWithPlayer(entityplayer, true);
}
public void onCollideWithPlayer (EntityPlayer entityplayer, boolean flag)
{
if (returnStack == null || returnStack.stackSize == 0 || worldObj.isRemote)
{
return;
}
if (!flag || onGround && arrowShake <= 0)
{
if (!flag || returnsTo != null && !returnsTo.isDead && returnsTo != entityplayer)
{
return;
}
AbilityHelper.addToInv(entityplayer, returnStack, true);
worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.onItemPickup(this, 1);
kill();
}
}
public float getShadowSize ()
{
return 0.0F;
}
public ItemStack getEntityItem ()
{
return returnStack;
}
public int age = 0;
public int hoverStart = 0;
public int texID;
public int tex2ID;
public ItemStack returnStack;
public int returnStackSlot;
public boolean hasHitGround;
public boolean hasHitMob;
public float prevBoomerangRotation;
public float boomerangRotation;
public Entity returnsTo;
public int damageDealt;
public int maxGroundTicks;
protected int xTile;
protected int yTile;
protected int zTile;
protected int inTile;
public int arrowShake;
public EntityPlayer owner;
protected int ticksInGround;
protected int ticksInAir;
@Override
public void writeSpawnData (ByteArrayDataOutput data)
{
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
data.writeShort(returnStack.itemID);
data.writeFloat(rotationYaw);
data.writeInt(tags.getInteger("RenderHandle"));
data.writeInt(tags.getInteger("RenderHead"));
data.writeInt(tags.getInteger("RenderAccessory"));
int effects = 0;
if (tags.hasKey("Effect1"))
effects++;
if (tags.hasKey("Effect2"))
effects++;
if (tags.hasKey("Effect3"))
effects++;
if (tags.hasKey("Effect4"))
effects++;
if (tags.hasKey("Effect5"))
effects++;
if (tags.hasKey("Effect6"))
effects++;
data.writeInt(effects);
switch (effects)
{
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
}
}
@Override
public void readSpawnData (ByteArrayDataInput data)
{
returnStack = new ItemStack(data.readShort(), 1, 0);
rotationYaw = data.readFloat();
NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound toolTag = new NBTTagCompound();
toolTag.setInteger("RenderHandle", data.readInt());
toolTag.setInteger("RenderHead", data.readInt());
toolTag.setInteger("RenderAccessory", data.readInt());
switch (data.readInt())
{
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
}
compound.setCompoundTag("InfiTool", toolTag);
returnStack.setTagCompound(compound);
}
}