Search in sources :

Example 1 with AbstractEntityCQR

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);
    }
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) ProjectileBullet(team.cqr.cqrepoured.entity.projectiles.ProjectileBullet) AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR) ItemStack(net.minecraft.item.ItemStack)

Example 2 with AbstractEntityCQR

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);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) CPacketSyncEntity(team.cqr.cqrepoured.network.client.packet.CPacketSyncEntity) AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR)

Example 3 with AbstractEntityCQR

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();
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TraderOffer(team.cqr.cqrepoured.entity.trade.TraderOffer) ContainerMerchant(team.cqr.cqrepoured.inventory.ContainerMerchant) AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR)

Example 4 with AbstractEntityCQR

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);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR)

Example 5 with AbstractEntityCQR

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);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) BlockState(net.minecraft.block.BlockState) Difficulty(net.minecraft.world.Difficulty) ResourceLocation(net.minecraft.util.ResourceLocation) AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR) TileEntitySpawner(team.cqr.cqrepoured.tileentity.TileEntitySpawner)

Aggregations

AbstractEntityCQR (team.cqr.cqrepoured.entity.bases.AbstractEntityCQR)26 Entity (net.minecraft.entity.Entity)10 ItemStack (net.minecraft.item.ItemStack)8 LivingEntity (net.minecraft.entity.LivingEntity)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 MobEntity (net.minecraft.entity.MobEntity)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 ListNBT (net.minecraft.nbt.ListNBT)3 BlockPos (net.minecraft.util.math.BlockPos)3 ServerWorld (net.minecraft.world.server.ServerWorld)3 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)3 BlockState (net.minecraft.block.BlockState)2 CompoundNBT (net.minecraft.nbt.CompoundNBT)2 INBT (net.minecraft.nbt.INBT)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 IFakeWeapon (team.cqr.cqrepoured.item.IFakeWeapon)2 ISupportWeapon (team.cqr.cqrepoured.item.ISupportWeapon)2 DoorBlock (net.minecraft.block.DoorBlock)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1