use of net.minecraft.entity.monster.EntitySnowman in project Tale-of-Kingdoms by Ivasik78.
the class EntitySantaClaus method onDeath.
@Override
public void onDeath(DamageSource damageSource) {
if (!worldObj.isRemote) {
if (damageSource.getSourceOfDamage() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) damageSource.getEntity();
player.addChatMessage(new ChatComponentTranslation("npc.santa.badKid.dialog"));
player.dropItem(Items.coal, worldObj.rand.nextInt(32));
PlayerProvider.get(player).badKid = true;
IntStream.range(1, rand.nextInt(5)).mapToObj(i -> new EntitySnowman(worldObj)).forEach(golem -> {
golem.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
golem.setAttackTarget(player);
worldObj.spawnEntityInWorld(golem);
});
}
}
}
use of net.minecraft.entity.monster.EntitySnowman in project Tale-of-Kingdoms by Ivasik78.
the class EntitySantaClaus method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (!worldObj.isRemote) {
int posX, posY, posZ;
--timer;
for (int l = 0; l < 4; ++l) {
posX = MathHelper.floor_double(this.posX + (double) ((float) (l % 2 * 2 - 1) * 0.25F));
posY = MathHelper.floor_double(this.posY);
posZ = MathHelper.floor_double(this.posZ + (double) ((float) (l / 2 % 2 * 2 - 1) * 0.25F));
if (this.worldObj.getBlock(posX, posY, posZ).getMaterial() == Material.air && Blocks.snow_layer.canPlaceBlockAt(this.worldObj, posX, posY, posZ))
this.worldObj.setBlock(posX, posY, posZ, Blocks.snow_layer);
}
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(30, 30, 30));
for (Entity entity : list) {
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (player.getDistanceToEntity(this) > 2F && player.getDistanceToEntity(this) < 8F) {
if (timer <= 0) {
if (!PlayerProvider.get(player).badKid) {
this.dropItem(Items.cookie, worldObj.rand.nextInt(25));
this.worldObj.setBlock((int) this.posX - 1, (int) this.posY, (int) this.posZ - 1, Blocks.cake);
if (worldObj.rand.nextInt(4) == 2) {
this.worldObj.setBlock((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1, Blocks.chest);
TileEntity te = worldObj.getTileEntity((int) this.posX + 1, (int) this.posY, (int) this.posZ + 1);
if (te instanceof TileEntityChest) {
IntStream.range(worldObj.rand.nextInt(25), worldObj.rand.nextInt(27)).forEach(i -> {
Item item = stacks.get(i) == null ? Item.getItemFromBlock(Blocks.air) : stacks.get(i);
((TileEntityChest) te).setInventorySlotContents(i, new ItemStack(item, i));
});
}
}
} else {
this.dropItem(Items.coal, worldObj.rand.nextInt(25));
EntitySnowman golem = new EntitySnowman(worldObj);
golem.setPosition(this.posX, this.posY, this.posZ);
golem.setAttackTarget(player);
worldObj.spawnEntityInWorld(golem);
}
timer = 6000;
}
if (timer < 0) {
timer = 6000;
}
}
}
}
}
}
Aggregations