PARTICLES

This commit is contained in:
StevenRS11
2013-05-27 20:08:42 -04:00
parent 8d19b2afab
commit 0e9918f9fe
3 changed files with 102 additions and 0 deletions

View File

@@ -91,6 +91,50 @@ public class DimData implements Serializable
} }
public ArrayList findRiftsInRange(World world, int range, int x, int y, int z)
{
LinkData nearest=null;
ArrayList rifts = new ArrayList();
int i=-range;
int j=-range;
int k=-range;
while (i<range)
{
while (j<range)
{
while (k<range)
{
if(world.getBlockId(x+i, y+j, z+k)==mod_pocketDim.blockRiftID)
{
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)!=0)
{
nearest=this.findLinkAtCoords(x+i, y+j, z+k);
if(nearest!=null)
{
rifts.add(nearest);
}
}
}
k++;
}
k=-range;
j++;
}
j=-range;
i++;
}
return rifts;
}
public LinkData addLinkToDim(LinkData link) public LinkData addLinkToDim(LinkData link)
{ {
if(this.linksInThisDim.containsKey(link.locZCoord)) if(this.linksInThisDim.containsKey(link.locZCoord))

View File

@@ -2,9 +2,13 @@ package StevenDimDoors.mod_pocketDim;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.ticking.MobObelisk;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList;
import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.monster.EntityEnderman;
@@ -75,6 +79,17 @@ public class TileEntityRift extends TileEntity
creeper.setLocationAndAngles(this.xCoord+.5, this.yCoord-1, this.zCoord+.5, 5, 6); creeper.setLocationAndAngles(this.xCoord+.5, this.yCoord-1, this.zCoord+.5, 5, 6);
worldObj.spawnEntityInWorld(creeper); worldObj.spawnEntityInWorld(creeper);
} }
if(dimHelper.dimList.get(this.worldObj.provider.dimensionId)!=null)
{
ArrayList rifts = dimHelper.dimList.get(this.worldObj.provider.dimensionId).findRiftsInRange(worldObj, 6, this.xCoord, this.yCoord, this.zCoord);
if(rifts.size()>15)
{
MobObelisk creeper = new MobObelisk(worldObj);
creeper.setLocationAndAngles(this.xCoord+.5, yCoordHelper.getFirstUncovered(this.worldObj, this.xCoord, this.yCoord, this.zCoord), this.zCoord+.5, 5, 6);
worldObj.spawnEntityInWorld(creeper);
}
}
} }

View File

@@ -7,8 +7,10 @@ import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.IMob; import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet34EntityTeleport; import net.minecraft.network.packet.Packet34EntityTeleport;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.LinkData; import StevenDimDoors.mod_pocketDim.LinkData;
@@ -41,6 +43,7 @@ public class MobObelisk extends EntityFlying implements IMob
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -51,6 +54,11 @@ public class MobObelisk extends EntityFlying implements IMob
return 20; return 20;
} }
public boolean canBePushed()
{
return false;
}
public void setEntityPosition(Entity entity, double x, double y, double z) public void setEntityPosition(Entity entity, double x, double y, double z)
{ {
entity.lastTickPosX = entity.prevPosX = entity.posX = x; entity.lastTickPosX = entity.prevPosX = entity.posX = x;
@@ -182,6 +190,13 @@ public class MobObelisk extends EntityFlying implements IMob
} }
for (int i = 0; i < -1+this.textureState/2; ++i)
{
entityPlayer.worldObj.spawnParticle("portal", entityPlayer.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, entityPlayer.posY + this.rand.nextDouble() * (double)entityPlayer.height - 0.75D, entityPlayer.posZ + (this.rand.nextDouble() - 0.5D) * (double)entityPlayer.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D);
}
} }
@@ -289,6 +304,10 @@ public class MobObelisk extends EntityFlying implements IMob
return true; return true;
} }
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
return false;
}
public void faceEntity(Entity par1Entity, float par2, float par3) public void faceEntity(Entity par1Entity, float par2, float par3)
{ {
double d0 = par1Entity.posX - this.posX; double d0 = par1Entity.posX - this.posX;
@@ -335,6 +354,30 @@ public class MobObelisk extends EntityFlying implements IMob
{ {
return 0.0F; return 0.0F;
} }
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setFloat("soundTime", this.soundTime);
par1NBTTagCompound.setInteger("aggro", this.aggro);
par1NBTTagCompound.setByte("textureState", this.textureState);
par1NBTTagCompound.setBoolean("hasJumped", this.hasJumped);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.soundTime=par1NBTTagCompound.getFloat("soundTime");
this.aggro=par1NBTTagCompound.getInteger("aggro");
this.textureState=par1NBTTagCompound.getByte("textureState");
this.hasJumped=par1NBTTagCompound.getBoolean("hasJumped");
}