new workspace

This commit is contained in:
KitsuShadow
2015-07-28 23:27:27 -04:00
parent 28a22a6d43
commit a1d3b54d6f
530 changed files with 2222 additions and 21468 deletions

View File

@@ -1,198 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem()==new ItemStack(ModBlocks.damascus,1)){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
return true;
}
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,79 +0,0 @@
package com.kitsu.medievalcraft.block.crucible;
import java.util.Random;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.util.CustomTab;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public abstract class CrucibleBase extends BlockContainer {
protected CrucibleBase(Material mat, String unlocalizedName) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(2.0F);
this.setResistance(1.0F);
this.setHarvestLevel("pickaxe", 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
return true;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return Item.getItemFromBlock(this);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getRenderType() {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,204 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPrey()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPrey();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,229 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
protected Entity findPreySquid()
{
//EntitySquid squid = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
AxisAlignedBB ab = this.boundingBox.expand(64D, 16D, 64D);
EntitySquid squid = this.worldObj.getEntitiesWithinAABB(EntitySquid.class, ab);
System.out.println("Finding Squid");
return (squid != null) ? squid : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
this.targetedEntity = findPreySquid();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,229 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
protected Entity findPreySquid()
{
//EntitySquid squid = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
AxisAlignedBB ab = this.boundingBox.expand(64D, 16D, 64D);
EntitySquid squid = (EntitySquid) this.worldObj.getEntitiesWithinAABB(EntitySquid.class, ab);
System.out.println("Finding Squid");
return (squid != null) && (canEntityBeSeen(squid)) ? squid : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
this.targetedEntity = findPreySquid();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,221 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
protected Entity findPreySquid()
{
//EntitySquid squid = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
//AxisAlignedBB ab = new AxisAlignedBB(-16d, -16d, -16d, 16d, 16d, 16d);
EntitySquid squid = (EntitySquid) this.worldObj.getEntitiesWithinAABB(EntitySquid.class, AxisAlignedBB.getBoundingBox(-106d, -106d, -106d, 106d, 106d, 106d));
System.out.println("Finding Squid");
return (squid != null) && (canEntityBeSeen(squid)) ? squid : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -20,7 +20,7 @@ public class RenderModelArrow extends Render
public static final ResourceLocation MODEL_CRUCIBLE = new ResourceLocation("kitsumedievalcraft:models/ModelArrow.obj");
public static final ResourceLocation TEXTURE = new ResourceLocation("kitsumedievalcraft:models/modelarrow.png");
//public IModelCustom model = AdvancedModelLoader.loadModel(MODEL_CRUCIBLE);
public IModelCustom model = AdvancedModelLoader.loadModel(MODEL_CRUCIBLE);
public void doRender(EntityModelArrow p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
@@ -30,7 +30,7 @@ public class RenderModelArrow extends Render
GL11.glRotatef(p_76986_1_.prevRotationYaw + (p_76986_1_.rotationYaw - p_76986_1_.prevRotationYaw) * p_76986_9_ - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_, 0.0F, 0.0F, 1.0F);
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);
//model.renderAll();
model.renderAll();
GL11.glPopMatrix();
}

View File

@@ -1,209 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileEntityFirebox;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
EntityItem entCoal = null;
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,205 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,198 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem()==new ItemStack(ModBlocks.damascus)){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
}
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,198 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem()==new ItemStack(ModBlocks.damascus)){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
return true;
}
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,64 @@
package com.kitsu.medievalcraft.renderer.blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import com.kitsu.medievalcraft.entity.EntityModelArrow;
public class RenderModelArrow extends Render
{
//private static final ResourceLocation arrowTextures = new ResourceLocation("textures/entity/arrow.png");
private static final ResourceLocation arrowTextures = new ResourceLocation("kitsumedievalcraft:textures/items/itemModelArrow.png");
public static final ResourceLocation MODEL_CRUCIBLE = new ResourceLocation("kitsumedievalcraft:models/ModelArrow.obj");
//public static final ResourceLocation TEXTURE = new ResourceLocation("kitsumedievalcraft:models/modelarrow.png");
public IModelCustom model = AdvancedModelLoader.loadModel(MODEL_CRUCIBLE);
public void doRender(EntityModelArrow p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
GL11.glPushMatrix();
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_ );
GL11.glRotatef(p_76986_1_.prevRotationYaw + (p_76986_1_.rotationYaw - p_76986_1_.prevRotationYaw) * p_76986_9_ - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_, 0.0F, 0.0F, 1.0F);
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);
model.renderAll();
GL11.glPopMatrix();
}
protected ResourceLocation getEntityTexture(EntityModelArrow p_110775_1_)
{
return arrowTextures;
}
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected ResourceLocation getEntityTexture(Entity p_110775_1_)
{
return this.getEntityTexture((EntityModelArrow)p_110775_1_);
}
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
//System.out.println("doRender Ran");
this.doRender((EntityModelArrow)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
}
}

View File

@@ -1,5 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
public class EntityAIWaterMob {
}

View File

@@ -1,123 +0,0 @@
package com.kitsu.medievalcraft.block.ingots;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class IngotBase extends BlockContainer {
private final Random random = new Random();
public static boolean makeParts;
public static int locX, locY, locZ;
public IngotBase(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeMetal);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.25F, 0.0F, 0.35F,
0.75F , 0.15F, 0.7F);
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return Item.getItemFromBlock(this);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return null;
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
if(makeParts == true){
parts(world, locX, locY, locZ);
makeParts = false;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int aa, float bb, float cc, float ff){
//System.out.println(this.getUnlocalizedName());
if(player.inventory.getCurrentItem().getItem()!=ModItems.forgeHammer){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
return true;
}
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
return true;
}
}
return false;
}
private void parts(World world, int x, int y, int z){
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
}
@Override
public int getRenderType() {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,202 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileEntityFirebox;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
EntityItem entCoal = null;
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
System.out.println(tileEnt.isCoal);
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,199 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
ItemStack c = new ItemStack(ModBlocks.damascus,1);
if(player.inventory.getCurrentItem()==c){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
return true;
}
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,210 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,210 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,256 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.profiler.Profiler;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.ChunkCache;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public Profiler theProfiler;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
protected Entity findPreySquid()
{
//EntitySquid squid = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
AxisAlignedBB ab = this.boundingBox.expand(64D, 16D, 64D);
EntityLivingBase squid = this.getpa
System.out.println("Finding Squid");
return (Entity) squid;
}
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
{
this.theProfiler.startSection("pathfind");
int i = MathHelper.floor_double(p_72865_1_.posX);
int j = MathHelper.floor_double(p_72865_1_.posY + 1.0D);
int k = MathHelper.floor_double(p_72865_1_.posZ);
int l = (int)(p_72865_3_ + 16.0F);
int i1 = i - l;
int j1 = j - l;
int k1 = k - l;
int l1 = i + l;
int i2 = j + l;
int j2 = k + l;
ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2, 0);
PathEntity pathentity = (new PathFinder(chunkcache, p_72865_4_, p_72865_5_, p_72865_6_, p_72865_7_)).createEntityPathTo(p_72865_1_, p_72865_2_, p_72865_3_);
this.theProfiler.endSection();
return pathentity;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
this.targetedEntity = findPreySquid();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,231 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
protected Entity findPreySquid()
{
//EntitySquid squid = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
AxisAlignedBB ab = this.boundingBox.expand(64D, 16D, 64D);
List squid = this.worldObj.getEntitiesWithinAABB(EntitySquid.class, ab);
System.out.println("Finding Squid");
return (Entity) ((squid != null) ? squid : null);
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
this.targetedEntity = findPreySquid();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,229 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
protected Entity findPreySquid()
{
//EntitySquid squid = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
//AxisAlignedBB ab = new AxisAlignedBB(-16d, -16d, -16d, 16d, 16d, 16d);
EntitySquid squid = (EntitySquid) this.worldObj.getEntitiesWithinAABB(EntitySquid.class, AxisAlignedBB.getBoundingBox(-106d, -106d, -106d, 106d, 106d, 106d));
System.out.println("Finding Squid");
return (squid != null) && (canEntityBeSeen(squid)) ? squid : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
this.targetedEntity = findPreySquid();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,228 +0,0 @@
package com.kitsu.medievalcraft.entityAI;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.profiler.Profiler;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.ChunkCache;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public Profiler theProfiler;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
this.targetedEntity = findPreySquid();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -1,198 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
ItemStack[] placeArray = new ItemStack[5];
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
placeArray[0].equals(new ItemStack(ModBlocks.damascus));
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem()==placeArray[0]){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
}
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -1,198 +0,0 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer{
private final Random random = new Random();
ItemStack[] placeArray = new ItemStack[5];
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 0.5F, 1.0F);
placeArray[0].equals(new ItemStack(ModBlocks.damascus));
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
}
world.markBlockForUpdate(x, y, z);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
//System.out.println("");
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem()==){
}
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
/* if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
//tileEnt.markDirty();
*/
}
tileEnt.markForUpdate();
tileEnt.markDirty();
//System.out.println(player.inventory.getCurrentItem());
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}