finished changes to monolith spawning

This commit is contained in:
StevenRS11 2013-06-24 00:34:21 -04:00
parent e847794e8d
commit 8bbd1384c5
3 changed files with 50 additions and 27 deletions

View file

@ -31,7 +31,7 @@ public class MobObelisk extends EntityFlying implements IMob
float soundTime = 0; float soundTime = 0;
int aggro = 0; int aggro = 0;
byte textureState = 0; byte textureState = 0;
boolean hasJumped= false;
float scaleFactor = 0; float scaleFactor = 0;
int aggroMax; int aggroMax;
int destX=0; int destX=0;
@ -101,27 +101,7 @@ public class MobObelisk extends EntityFlying implements IMob
byte b0 = this.dataWatcher.getWatchableObjectByte(16); byte b0 = this.dataWatcher.getWatchableObjectByte(16);
this.texture="/mods/DimDoors/textures/mobs/Monolith"+b0+".png"; this.texture="/mods/DimDoors/textures/mobs/Monolith"+b0+".png";
if(!this.hasJumped&&!this.worldObj.isRemote)
{
int sanity=0;
double jumpHeight=0;
do
{
jumpHeight = this.posY+rand.nextInt(25);
if(this.worldObj.provider instanceof pocketProvider)
{
jumpHeight = this.posY+rand.nextInt(10);
}
sanity++;
}
while(!this.worldObj.isAirBlock((int)this.posX,(int)jumpHeight+6 , (int)this.posZ)&&sanity<20);
this.hasJumped=true;
this.setLocationAndAngles(this.posX,jumpHeight , this.posZ, this.rotationPitch, this.rotationYaw);
PacketDispatcher.sendPacketToAllInDimension(new Packet34EntityTeleport(this), this.worldObj.provider.dimensionId);
this.worldObj.updateEntity(this);
}
super.onEntityUpdate(); super.onEntityUpdate();
@ -372,9 +352,20 @@ public class MobObelisk extends EntityFlying implements IMob
par1NBTTagCompound.setInteger("aggro", this.aggro); par1NBTTagCompound.setInteger("aggro", this.aggro);
par1NBTTagCompound.setInteger("aggroMax", this.aggroMax); par1NBTTagCompound.setInteger("aggroMax", this.aggroMax);
par1NBTTagCompound.setByte("textureState", this.textureState); par1NBTTagCompound.setByte("textureState", this.textureState);
par1NBTTagCompound.setBoolean("hasJumped", this.hasJumped);
par1NBTTagCompound.setFloat("scaleFactor", this.scaleFactor); par1NBTTagCompound.setFloat("scaleFactor", this.scaleFactor);
}
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.soundTime = par1NBTTagCompound.getFloat("soundTime");
this.aggro = par1NBTTagCompound.getInteger("aggro");
this.aggroMax = par1NBTTagCompound.getInteger("aggroMax");
this.textureState = par1NBTTagCompound.getByte("textureState");
this.scaleFactor = par1NBTTagCompound.getFloat("scaleFactor");
} }
public boolean getCanSpawnHere() public boolean getCanSpawnHere()
{ {

View file

@ -196,14 +196,27 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
} }
y = yCoordHelper.getFirstUncovered(this.worldObj,x , y+2, z); y = yCoordHelper.getFirstUncovered(this.worldObj,x , y+2, z);
Entity mob = new MobObelisk(this.worldObj);
mob.setLocationAndAngles(x, y, z, 1, 1);
yTest=yCoordHelper.getFirstUncovered(this.worldObj,x , y+5, z); yTest=yCoordHelper.getFirstUncovered(this.worldObj,x , y+5, z);
if(yTest>245) if(yTest>245)
{ {
return; return;
} }
int jumpSanity=0;
int jumpHeight=0;
do
{
jumpHeight = y+rand.nextInt(25);
jumpSanity++;
}
while(!this.worldObj.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
Entity mob = new MobObelisk(this.worldObj);
mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
this.worldObj.spawnEntityInWorld(mob); this.worldObj.spawnEntityInWorld(mob);
} }

View file

@ -3,8 +3,11 @@ package StevenDimDoors.mod_pocketDim.world;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import cpw.mods.fml.common.network.PacketDispatcher;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.EnumCreatureType;
import net.minecraft.network.packet.Packet34EntityTeleport;
import net.minecraft.world.ChunkPosition; import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
@ -108,9 +111,25 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
} }
if(y > 0) if(y > 0)
{ {
int jumpSanity=0;
int jumpHeight=0;
do
{
jumpHeight = y+random.nextInt(10);
jumpSanity++;
}
while(!this.worldObj.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
Entity mob = new MobObelisk(worldObj); Entity mob = new MobObelisk(worldObj);
mob.setLocationAndAngles(x, y+2+random.nextInt(5), z, 1, 1); mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
worldObj.spawnEntityInWorld(mob); worldObj.spawnEntityInWorld(mob);
didSpawn=true; didSpawn=true;
} }