private void spawnPaleontologist(World world, Random random) { if (random.nextInt(2) == 0) { if (this.villagerCount < 2) { Entity paleontologist = null; if(this.isZombieInfested) { paleontologist = new EntityZombieVillager(world); ((EntityZombieVillager) paleontologist).setProfession(VillagerRegistry.getId(VillagerHandler.PALEONTOLOGIST)); }else { paleontologist = new EntityVillager(world, VillagerRegistry.getId(VillagerHandler.PALEONTOLOGIST)); } paleontologist.setPosition(boundingBox.minX + (boundingBox.maxX - boundingBox.minX) / 2, boundingBox.minY + 3, boundingBox.minZ + (boundingBox.maxZ - boundingBox.minZ) / 2); world.spawnEntity(paleontologist); this.villagerCount++; } } }
private void startConverting(EntityZombieVillager v, int t) { // v.conversionTime = t; ObfuscationReflectionHelper.setPrivateValue(EntityZombieVillager.class, v, t, "conversionTime", "field_82234_d"); v.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, t, Math.min(v.world.getDifficulty().getId() - 1, 0))); v.world.setEntityState(v, (byte) 16); try { // v.getDataManager().set(CONVERTING, Boolean.valueOf(true)); DataParameter<Boolean> CONVERTING = ObfuscationReflectionHelper.getPrivateValue(EntityZombieVillager.class, v, "CONVERTING", "field_184739_bx"); v.getDataManager().set(CONVERTING, Boolean.valueOf(true)); } catch (Exception e) {} } }
@Override public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { if (entity instanceof EntityZombieVillager && entity.isChild() == false) { EntityZombieVillager zombie = ((EntityZombieVillager) entity); if (zombie.isConverting() == false) { // dont waste a second one if already converting //this is what we WANT to do, but the method is protected. we have to fake it by faking the interact event // zombie.startConverting(1200); consumeSelf(itemstack); startConverting(zombie, CONVTIME); zombie.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 600, 1)); return true; } } return super.itemInteractionForEntity(itemstack, player, entity, hand); }
/** * Spawns a number of villagers in this component. Parameters: world, component bounding box, x offset, y * offset, z offset, number of villagers */ protected void spawnVillagers(World worldIn, StructureBoundingBox structurebb, int x, int y, int z, int count) { if (this.villagersSpawned < count) { for (int i = this.villagersSpawned; i < count; ++i) { int j = this.getXWithOffset(x + i, z); int k = this.getYWithOffset(y); int l = this.getZWithOffset(x + i, z); if (!structurebb.isVecInside(new BlockPos(j, k, l))) { break; } ++this.villagersSpawned; if (this.field_189929_i) { EntityZombieVillager entityzombie = new EntityZombieVillager(worldIn); entityzombie.setLocationAndAngles((double) j + 0.5D, (double) k, (double) l + 0.5D, 0.0F, 0.0F); entityzombie.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData) null); entityzombie.enablePersistence(); worldIn.spawnEntity(entityzombie); } else { EntitySnowVillager entityvillager = new EntitySnowVillager(worldIn); entityvillager.setLocationAndAngles((double) j + 0.5D, (double) k, (double) l + 0.5D, 0.0F, 0.0F); entityvillager.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData) null); ModVillagers.INSTANCE.setRandomProfession(entityvillager, worldIn.rand); worldIn.spawnEntity(entityvillager); } } } }