use of team.cqr.cqrepoured.entity.bases.AbstractEntityCQR in project ChocolateQuestRepoured by TeamChocoQuest.
the class ItemRevolver method shoot.
@Override
public void shoot(World worldIn, LivingEntity shooter, Entity target, Hand handIn) {
if (!worldIn.isRemote) {
ItemStack bulletStack = new ItemStack(CQRItems.BULLET_IRON, 1);
if (shooter instanceof AbstractEntityCQR) {
AbstractEntityCQR cqrEnt = (AbstractEntityCQR) shooter;
ItemStack bullet = cqrEnt.getItemStackFromExtraSlot(EntityEquipmentExtraSlot.ARROW);
if (bullet != null && !bullet.isEmpty() && (bullet.getItem() instanceof ItemBullet)) {
bulletStack = bullet;
bullet.shrink(1);
}
}
ProjectileBullet bulletE = new ProjectileBullet(worldIn, shooter, this.getBulletType(bulletStack));
Vector3d v = target.position().subtract(shooter.position());
v = v.normalize();
v = v.scale(3.5D);
// bulletE.setVelocity(v.x, v.y, v.z);
bulletE.motionX = v.x;
bulletE.motionY = v.y;
bulletE.motionZ = v.z;
bulletE.velocityChanged = true;
worldIn.spawnEntity(bulletE);
}
}
use of team.cqr.cqrepoured.entity.bases.AbstractEntityCQR in project ChocolateQuestRepoured by TeamChocoQuest.
the class SPacketHandlerSyncEntity method execHandlePacket.
@Override
protected void execHandlePacket(CPacketSyncEntity packet, Supplier<Context> context, World world, PlayerEntity player) {
if (player.isCreative()) {
Entity entity = world.getEntity(packet.getEntityId());
if (entity instanceof AbstractEntityCQR) {
AbstractEntityCQR cqrentity = (AbstractEntityCQR) entity;
cqrentity.setHealthScale(packet.getHealthScaling() / 100.0D);
cqrentity.setDropChance(EquipmentSlotType.HEAD, packet.getDropChanceHelm() / 100.0F);
cqrentity.setDropChance(EquipmentSlotType.CHEST, packet.getDropChanceChest() / 100.0F);
cqrentity.setDropChance(EquipmentSlotType.LEGS, packet.getDropChanceLegs() / 100.0F);
cqrentity.setDropChance(EquipmentSlotType.FEET, packet.getDropChanceFeet() / 100.0F);
cqrentity.setDropChance(EquipmentSlotType.MAINHAND, packet.getDropChanceMainhand() / 100.0F);
cqrentity.setDropChance(EquipmentSlotType.OFFHAND, packet.getDropChanceOffhand() / 100.0F);
cqrentity.setSizeVariation(packet.getSizeScaling() / 100.0F);
}
}
}
use of team.cqr.cqrepoured.entity.bases.AbstractEntityCQR in project ChocolateQuestRepoured by TeamChocoQuest.
the class CPacketHandlerSyncTrades method execHandlePacket.
@Override
protected void execHandlePacket(SPacketSyncTrades message, Supplier<Context> context, World world, PlayerEntity player) {
Entity entity = world.getEntity(message.getEntityId());
if (entity instanceof AbstractEntityCQR) {
TraderOffer trades = ((AbstractEntityCQR) entity).getTrades();
trades.readFromNBT(message.getTrades());
if (player.containerMenu instanceof ContainerMerchant) {
((ContainerMerchant) player.containerMenu).onTradesUpdated();
}
CQRMain.proxy.updateGui();
}
}
use of team.cqr.cqrepoured.entity.bases.AbstractEntityCQR in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAIIdleSit method tick.
@Override
public void tick() {
if (++this.cooldown > COOLDOWN_BORDER) {
// Make entity sit
this.entity.setSitting(true);
if (this.entity.hasTrades()) {
this.entity.setChatting(true);
return;
}
// search for new talking partner
if (++this.cooldwonForPartnerCycle > COOLDOWN_FOR_PARTNER_CYCLE_BORDER) {
this.cooldwonForPartnerCycle = 0;
double x = this.entity.position().x;
double y = this.entity.position().y;
double z = this.entity.position().z;
double r = 6.0D;
AxisAlignedBB aabb = new AxisAlignedBB(x - r, y - r * 0.5D, z - r, x + r, y + r * 0.5D, z + r);
List<AbstractEntityCQR> friends = this.entity.level.getEntitiesOfClass(AbstractEntityCQR.class, aabb, this.predicate);
if (!friends.isEmpty()) {
this.talkingPartner = friends.get(this.random.nextInt(friends.size()));
}
}
// check if talking partner is valid and either talk to him or stop talking
if (this.talkingPartner != null) {
if (this.talkingPartner.isAlive() && this.entity.distanceToSqr(this.talkingPartner) < 8.0D * 8.0D) {
this.entity.setChatting(true);
this.entity.getLookControl().setLookAt(this.talkingPartner, 15.0F, 15.0F);
double dx = this.talkingPartner.position().x - this.entity.position().x;
double dz = this.talkingPartner.position().z - this.entity.position().z;
this.entity.yRot = (float) Math.toDegrees(MathHelper.atan2(dz, dx)) - 90.0F;
this.entity.yBodyRot = this.entity.yRot;
} else {
this.talkingPartner = null;
this.entity.setChatting(false);
}
} else {
this.entity.setChatting(false);
}
}
}
use of team.cqr.cqrepoured.entity.bases.AbstractEntityCQR in project ChocolateQuestRepoured by TeamChocoQuest.
the class WallPieceWall method placeSpawner.
private void placeSpawner(BlockPos spawnerPos, ISeedReader iSeedReader) {
Entity spawnerEnt = EntityList.createEntityByIDFromName(new ResourceLocation(CQRConfig.wall.mob), iSeedReader.getLevel());
if (spawnerEnt instanceof LivingEntity) {
Difficulty difficulty = iSeedReader.getDifficulty();
this.equipWeaponBasedOnDifficulty((LivingEntity) spawnerEnt, difficulty);
this.equipArmorBasedOnDifficulty((LivingEntity) spawnerEnt, difficulty);
if (spawnerEnt instanceof AbstractEntityCQR) {
((AbstractEntityCQR) spawnerEnt).setHealingPotions(1);
}
BlockState state2 = CQRBlocks.SPAWNER.defaultBlockState();
TileEntitySpawner tileSpawner = (TileEntitySpawner) CQRBlocks.SPAWNER.createTileEntity(state2, iSeedReader);
tileSpawner.inventory.setStackInSlot(0, SpawnerFactory.getSoulBottleItemStackForEntity(spawnerEnt));
// partBuilder.add(new PreparableSpawnerInfo(spawnerPos, tileSpawner.save(new CompoundNBT())));
this.placeBlock(iSeedReader, state2, spawnerPos.getX(), spawnerPos.getY(), spawnerPos.getZ(), this.boundingBox);
}
}
Aggregations