Search in sources :

Example 1 with Arena

use of com.teamwizardry.wizardry.api.arena.Arena in project Wizardry by TeamWizardry.

the class EntityZachriel method processInteract.

@Override
protected boolean processInteract(EntityPlayer player, EnumHand hand) {
    if (player.getHeldItemMainhand().getItem() == ModItems.MAGIC_WAND) {
        HashSet<UUID> players = new HashSet<>();
        players.add(player.getUniqueID());
        ArenaManager.INSTANCE.addArena(new Arena(player.world.provider.getDimension(), getPosition(), 10, 10, getEntityId(), players));
    }
    return super.processInteract(player, hand);
}
Also used : UUID(java.util.UUID) Arena(com.teamwizardry.wizardry.api.arena.Arena) HashSet(java.util.HashSet)

Example 2 with Arena

use of com.teamwizardry.wizardry.api.arena.Arena in project Wizardry by TeamWizardry.

the class EntityZachriel method attackEntityFrom.

@Override
public boolean attackEntityFrom(@Nonnull DamageSource source, float amount) {
    if (arena == null) {
        HashSet<UUID> players = new HashSet<>();
        arena = new Arena(getEntityWorld().provider.getDimension(), getPosition(), 50, 50, getEntityId(), players);
        ArenaManager.INSTANCE.addArena(arena);
    }
    if (burstTimer > 0)
        return false;
    boolean result = super.attackEntityFrom(source, amount);
    if (// Special case for the /kill command
    source.equals(DamageSource.OUT_OF_WORLD)) {
        numLoads = loadTimes.length;
        return super.attackEntityFrom(source, amount);
    }
    if (!world.isRemote) {
        float healthPercent = this.getHealth() / this.getMaxHealth();
        if (numSaves < saveTimes.length && healthPercent < saveTimes[numSaves]) {
            numSaves++;
            nextBurstSave = nextBurst;
        }
        if (numLoads < loadTimes.length && healthPercent < loadTimes[numLoads]) {
            this.setHealth(this.getMaxHealth() * saveTimes[numLoads]);
            numLoads++;
            nextBurst = nextBurstSave;
            if (this.isDead)
                this.isDead = false;
            // run load code
            NemezEventHandler.reverseTime(this);
        }
        if (nextBurst < burstLevels.length && healthPercent < burstLevels[nextBurst]) {
            nextBurst++;
            burstTimer = 60;
        }
    }
    return result;
// ZachTimeManager manager = null;
// for (ZachTimeManager manager1 : ArenaManager.INSTANCE.zachHourGlasses) {
// if (manager1.getEntityZachriel().getEntityId() == getEntityId()) {
// manager = manager1;
// }
// }
// 
// if (manager == null) return false;
// 
// ZachTimeManager finalManager = manager;
// long lastRecordedBlockTime = System.currentTimeMillis();
// 
// Thread thread = new Thread(() -> {
// ZachTimeManager.BasicPalette palette = finalManager.getPalette();
// 
// for (BlockPos pos : finalManager.getTrackedBlocks()) {
// HashMap<Long, IBlockState> states = finalManager.getBlocksAtPos(pos, palette);
// ArrayDeque<Long> dequeTime = new ArrayDeque<>(states.keySet());
// 
// while (!dequeTime.isEmpty()) {
// if (System.currentTimeMillis() - lastRecordedBlockTime < dequeTime.peek() / 10.0) continue;
// 
// IBlockState state = states.get(dequeTime.pop());
// world.setBlockState(pos, state);
// world.playEvent(2001, pos, Block.getStateId(state));
// }
// }
// finalManager.resetBlocks();
// });
// thread.start();
// 
// thread = new Thread(() -> {
// for (Entity entity : finalManager.getTrackedEntities(world)) {
// HashMap<Long, JsonObject> snapshots = finalManager.getEntitySnapshots(entity);
// ArrayDeque<Long> dequeTime = new ArrayDeque<>(snapshots.keySet());
// 
// while (!dequeTime.isEmpty()) {
// if (System.currentTimeMillis() - lastRecordedBlockTime < dequeTime.peek()) continue;
// 
// JsonObject snapshot = snapshots.get(dequeTime.pop());
// finalManager.setEntityToSnapshot(snapshot, entity);
// }
// }
// finalManager.resetEntities();
// });
// thread.start();
// 
// return false;
}
Also used : UUID(java.util.UUID) Arena(com.teamwizardry.wizardry.api.arena.Arena) HashSet(java.util.HashSet)

Example 3 with Arena

use of com.teamwizardry.wizardry.api.arena.Arena in project Wizardry by TeamWizardry.

the class EntityZachriel method onUpdate.

@Override
public void onUpdate() {
    this.motionY = 0;
    super.onUpdate();
    // BATTLE
    {
        if (arena == null) {
            HashSet<UUID> players = new HashSet<>();
            arena = new Arena(getEntityWorld().provider.getDimension(), getPosition(), 50, 50, getEntityId(), players);
            ArenaManager.INSTANCE.addArena(arena);
        }
        for (EntityLivingBase targeted : arena.getVictims()) nemezDrive.trackEntity(targeted);
        if (burstTimer > 0) {
            burstTimer--;
            if (burstTimer == 0)
                if (!world.isRemote)
                    for (EntityPlayer player : world.playerEntities) if (EntitySelectors.CAN_AI_TARGET.apply(player) && getDistanceSq(player) < 32 * 32) {
                        PotionEffect corruption = player.getActivePotionEffect(ModPotions.ZACH_CORRUPTION);
                        float bonusDamage = corruption == null ? 0 : burstDamage * (corruption.getAmplifier() + 1);
                        player.attackEntityFrom(DamageSource.causeMobDamage(this).setMagicDamage().setDamageBypassesArmor(), burstDamage + bonusDamage);
                    }
            ClientRunnable.run(new ClientRunnable() {

                @Override
                @SideOnly(Side.CLIENT)
                public void runIfClient() {
                    ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(30, 50));
                    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
                    glitter.enableMotionCalculation();
                    glitter.setCollision(burstTimer > 0);
                    glitter.setCanBounce(burstTimer > 0);
                    glitter.setAcceleration(new Vec3d(0, -0.035, 0));
                    glitter.setColor(new Color(255, 0, 206));
                    glitter.setAlphaFunction(new InterpFadeInOut(0.5F, 0F));
                    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 1, 1, (i, build) -> {
                        double theta = 2.0F * (float) Math.PI * RandUtil.nextFloat();
                        double r;
                        if (burstTimer > 0)
                            r = (getEntityBoundingBox().maxX - getEntityBoundingBox().minX) / 2 * RandUtil.nextFloat(0.01F, 1);
                        else
                            r = 32 * RandUtil.nextFloat();
                        double x = r * MathHelper.cos((float) theta);
                        double y = (getEntityBoundingBox().maxY - getEntityBoundingBox().minY) * RandUtil.nextFloat();
                        double z = r * MathHelper.sin((float) theta);
                        build.setPositionOffset(new Vec3d(x, y, z));
                        build.addMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.15), 0));
                    });
                }
            });
        }
        if (!world.isRemote) {
            List<EntityCorruptionArea> corruptionList = world.getEntitiesWithinAABB(EntityCorruptionArea.class, new AxisAlignedBB(getPosition()).grow(2));
            if (corruptionList.isEmpty()) {
                EntityCorruptionArea corruption = new EntityCorruptionArea(world, posX, posY, posZ);
                world.spawnEntity(corruption);
            }
        }
    }
    nemezDrive.endUpdate();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PotionEffect(net.minecraft.potion.PotionEffect) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Arena(com.teamwizardry.wizardry.api.arena.Arena) Vec3d(net.minecraft.util.math.Vec3d) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

Arena (com.teamwizardry.wizardry.api.arena.Arena)3 HashSet (java.util.HashSet)3 UUID (java.util.UUID)2 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)1 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)1 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)1 List (java.util.List)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 PotionEffect (net.minecraft.potion.PotionEffect)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 Vec3d (net.minecraft.util.math.Vec3d)1