Search in sources :

Example 21 with Vec3i

use of net.minecraft.util.math.Vec3i in project SomeModjam5Mod by HellFirePvP.

the class FissureData method recalcSize.

private void recalcSize() {
    int minX = MiscUtils.getMinEntry(stateOffsetMap.keySet(), Vec3i::getX);
    int minY = MiscUtils.getMinEntry(stateOffsetMap.keySet(), Vec3i::getY);
    int minZ = MiscUtils.getMinEntry(stateOffsetMap.keySet(), Vec3i::getZ);
    int maxX = MiscUtils.getMaxEntry(stateOffsetMap.keySet(), Vec3i::getX);
    int maxY = MiscUtils.getMaxEntry(stateOffsetMap.keySet(), Vec3i::getY);
    int maxZ = MiscUtils.getMaxEntry(stateOffsetMap.keySet(), Vec3i::getZ);
    this.min = new BlockPos(minX, minY, minZ);
    this.max = new BlockPos(maxX, maxY, maxZ);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) BlockPos(net.minecraft.util.math.BlockPos)

Example 22 with Vec3i

use of net.minecraft.util.math.Vec3i in project SomeModjam5Mod by HellFirePvP.

the class TileFissureDevice method playEffects.

@SideOnly(Side.CLIENT)
private void playEffects() {
    int depth = getStructureDepth();
    if (depth > 0) {
        if (headFloatingCube1 == null || ((EntityFXFloatingCube) headFloatingCube1).isRemoved()) {
            headFloatingCube1 = setupCube(0.35F, 0.3F);
        }
        if (headFloatingCube2 == null || ((EntityFXFloatingCube) headFloatingCube2).isRemoved()) {
            headFloatingCube2 = setupCube(0.3F, 0.2F);
        }
        if (headFloatingCube3 == null || ((EntityFXFloatingCube) headFloatingCube3).isRemoved()) {
            headFloatingCube3 = setupCube(0.25F, 0.04F);
        }
        handleAnimations(headFloatingCube1);
        handleAnimations(headFloatingCube2);
        handleAnimations(headFloatingCube3);
        if (this.percActive >= 1F && rand.nextFloat() >= 0.8F) {
            EffectLightning lightning = EffectHandler.getInstance().lightning(new Vector3(0.4 + rand.nextFloat() * 0.2, 0.1 - depth, 0.4 + rand.nextFloat() * 0.2).add(getPos()), new Vector3(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).add(getPos()));
            lightning.setOverlayColor(new Color(0x2DE400));
        }
        if (this.percActive > 0) {
            for (int i = 0; i < depth * 6; i++) {
                if (rand.nextFloat() <= this.percActive) {
                    EntityFXFacingParticle p = new EntityFXFacingParticle(30);
                    p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
                    p.setColor(new Color(0x2DE400));
                    p.setPosition(new Vector3(getPos()).add(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).addY(-rand.nextFloat() * (0.3 + depth)));
                    p.setScale(0.05F + rand.nextFloat() * 0.05F);
                    p.setAlphaMultiplier(0.75F);
                    p.setMotion(Vector3.random().multiply(0.006F));
                    EffectHandler.getInstance().registerFX(p);
                }
            }
        }
        FissureData otherData = FissureDataController.getFissureData(this.getLinkedDimension(), this.getLinkedPos());
        playOuterCube(otherData);
        if (this.percDrawFissure > 0 && otherData != null) {
            if (percDrawFissure < 1F) {
                float chance = 1F - Math.abs((percDrawFissure - 0.5F) * 1.6F);
                for (int i = 0; i < 19; i++) {
                    if (rand.nextFloat() < chance) {
                        Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(Vector3.random().multiply(2.5)).addY(1.3);
                        Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-15);
                        EntityFXFacingParticle p = new EntityFXFacingParticle(30);
                        p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
                        p.setColor(new Color(0x2DE400));
                        p.setPosition(particlePos);
                        p.setScale(0.03F + rand.nextFloat() * 0.03F);
                        p.setAlphaMultiplier(0.85F);
                        p.setMotion(dir);
                        EffectHandler.getInstance().registerFX(p);
                    }
                }
            } else {
                Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
                Vector3 randPos = new Vector3(otherData.getMin());
                randPos.addX(vecSub.getX() * rand.nextFloat());
                randPos.addY(vecSub.getY() * rand.nextFloat());
                randPos.addZ(vecSub.getZ() * rand.nextFloat());
                randPos.add(getPos());
                EntityFXFacingParticle p = new EntityFXFacingParticle(60);
                p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
                p.setColor(new Color(0x2DE400));
                p.setPosition(randPos);
                p.setScale(0.02F + rand.nextFloat() * 0.03F);
                p.setAlphaMultiplier(0.75F);
                p.setMotion(Vector3.random().multiply(0.01F));
                EffectHandler.getInstance().registerFX(p);
                for (int i = 0; i < 4; i++) {
                    p = new EntityFXFacingParticle(40);
                    p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
                    p.setColor(new Color(0x2DE400));
                    p.setPosition(new Vector3(getPos()).add(0.5, 1.3, 0.5));
                    p.setScale(0.015F + rand.nextFloat() * 0.02F);
                    p.setAlphaMultiplier(0.75F);
                    p.setMotion(Vector3.random().multiply(0.015F));
                    EffectHandler.getInstance().registerFX(p);
                }
                if (rand.nextInt(6) == 0) {
                    Vector3 randFrom = new Vector3(otherData.getMin());
                    randFrom.addX(vecSub.getX() * rand.nextFloat());
                    randFrom.addY(vecSub.getY() * rand.nextFloat());
                    randFrom.addZ(vecSub.getZ() * rand.nextFloat());
                    randFrom.add(getPos());
                    Vector3 randTo = new Vector3(otherData.getMin());
                    randTo.addX(vecSub.getX() * rand.nextFloat());
                    randTo.addY(vecSub.getY() * rand.nextFloat());
                    randTo.addZ(vecSub.getZ() * rand.nextFloat());
                    randTo.add(getPos());
                    Vector3 dst = randTo.clone().subtract(randFrom);
                    if (dst.length() > 6) {
                        dst.normalize().multiply(6);
                    }
                    EffectLightning eff = EffectHandler.getInstance().lightning(randFrom, randFrom.clone().add(dst));
                    eff.setOverlayColor(new Color(0x2DE400));
                }
            }
        }
    }
}
Also used : FissureData(hellfirepvp.fracture.common.fissure.FissureData) Vec3i(net.minecraft.util.math.Vec3i) EffectLightning(hellfirepvp.fracture.client.effect.fx.EffectLightning) Vector3(hellfirepvp.fracture.common.util.Vector3) EntityFXFacingParticle(hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 23 with Vec3i

use of net.minecraft.util.math.Vec3i in project RFTools by McJty.

the class SpawnerTileEntity method checkStateServer.

private void checkStateServer() {
    testSyringe();
    if (mobId == null || mobId.isEmpty()) {
        return;
    }
    List<SpawnerConfiguration.MobSpawnAmount> spawnAmounts = getSpawnAmounts();
    for (int i = 0; i < 3; i++) {
        if (matter[i] < spawnAmounts.get(i).getAmount()) {
            // Not enough material yet.
            return;
        }
    }
    // We have enough materials. Check power.
    Integer rf = SpawnerConfiguration.mobSpawnRf.get(mobId);
    if (rf == null) {
        rf = SpawnerConfiguration.defaultMobSpawnRf;
    }
    rf = (int) (rf * (2.0f - getInfusedFactor()) / 2.0f);
    if (getEnergyStored() < rf) {
        return;
    }
    consumeEnergy(rf);
    for (int i = 0; i < 3; i++) {
        matter[i] -= spawnAmounts.get(i).getAmount();
    }
    markDirty();
    IBlockState state = getWorld().getBlockState(getPos());
    EnumFacing k = OrientationTools.getOrientation(state);
    int sx = getPos().getX();
    int sy = getPos().getY();
    int sz = getPos().getZ();
    Vec3i dir = k.getDirectionVec();
    sx += dir.getX();
    sy += dir.getY();
    sz += dir.getZ();
    // if (entityCheckBox == null) {
    // entityCheckBox = AxisAlignedBB.getBoundingBox(xCoord-9, yCoord-9, zCoord-9, xCoord+sx+10, yCoord+sy+10, zCoord+sz+10);
    // }
    // 
    // int cnt = countEntitiesWithinAABB(entityCheckBox);
    // if (cnt >= SpawnerConfiguration.maxEntitiesAroundSpawner) {
    // return;
    // }
    EntityLiving entityLiving = EntityTools.createEntity(getWorld(), mobId);
    if (entityLiving == null) {
        Logging.logError("Fail to spawn mob: " + mobId);
        return;
    }
    if (entityLiving instanceof EntityDragon) {
        // Ender dragon needs to be spawned with an additional NBT key set
        NBTTagCompound dragonTag = new NBTTagCompound();
        entityLiving.writeEntityToNBT(dragonTag);
        dragonTag.setShort("DragonPhase", (short) 0);
        entityLiving.readEntityFromNBT(dragonTag);
    }
    if (k == EnumFacing.DOWN) {
        // @todo right? (used to be height)
        sy -= entityLiving.getEyeHeight() - 1;
    }
    entityLiving.setLocationAndAngles(sx + 0.5D, sy, sz + 0.5D, 0.0F, 0.0F);
    getWorld().spawnEntity(entityLiving);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) EntityDragon(net.minecraft.entity.boss.EntityDragon) IBlockState(net.minecraft.block.state.IBlockState) EntityLiving(net.minecraft.entity.EntityLiving) EnumFacing(net.minecraft.util.EnumFacing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 24 with Vec3i

use of net.minecraft.util.math.Vec3i in project Wurst-MC-1.12 by Wurst-Imperium.

the class FlyPathProcessor method process.

@Override
public void process() {
    // get positions
    BlockPos pos = new BlockPos(WMinecraft.getPlayer());
    Vec3d posVec = WMinecraft.getPlayer().getPositionVector();
    BlockPos nextPos = path.get(index);
    int posIndex = path.indexOf(pos);
    AxisAlignedBB nextBox = new AxisAlignedBB(nextPos.getX() + 0.3, nextPos.getY(), nextPos.getZ() + 0.3, nextPos.getX() + 0.7, nextPos.getY() + 0.2, nextPos.getZ() + 0.7);
    if (posIndex == -1)
        ticksOffPath++;
    else
        ticksOffPath = 0;
    // update index
    if (posIndex > index || posVec.xCoord >= nextBox.minX && posVec.xCoord <= nextBox.maxX && posVec.yCoord >= nextBox.minY && posVec.yCoord <= nextBox.maxY && posVec.zCoord >= nextBox.minZ && posVec.zCoord <= nextBox.maxZ) {
        if (posIndex > index)
            index = posIndex + 1;
        else
            index++;
        // stop when changing directions
        if (creativeFlying) {
            WMinecraft.getPlayer().motionX /= Math.max(Math.abs(WMinecraft.getPlayer().motionX) * 50, 1);
            WMinecraft.getPlayer().motionY /= Math.max(Math.abs(WMinecraft.getPlayer().motionY) * 50, 1);
            WMinecraft.getPlayer().motionZ /= Math.max(Math.abs(WMinecraft.getPlayer().motionZ) * 50, 1);
        }
        if (index >= path.size())
            done = true;
        return;
    }
    lockControls();
    WMinecraft.getPlayer().capabilities.isFlying = creativeFlying;
    boolean x = posVec.xCoord < nextBox.minX || posVec.xCoord > nextBox.maxX;
    boolean y = posVec.yCoord < nextBox.minY || posVec.yCoord > nextBox.maxY;
    boolean z = posVec.zCoord < nextBox.minZ || posVec.zCoord > nextBox.maxZ;
    boolean horizontal = x || z;
    // face next position
    if (horizontal) {
        facePosition(nextPos);
        if (Math.abs(WMath.wrapDegrees(RotationUtils.getHorizontalAngleToClientRotation(new Vec3d(nextPos).addVector(0.5, 0.5, 0.5)))) > 1)
            return;
    }
    // skip mid-air nodes
    Vec3i offset = nextPos.subtract(pos);
    while (index < path.size() - 1 && path.get(index).add(offset).equals(path.get(index + 1))) index++;
    if (creativeFlying) {
        if (!x)
            WMinecraft.getPlayer().motionX /= Math.max(Math.abs(WMinecraft.getPlayer().motionX) * 50, 1);
        if (!y)
            WMinecraft.getPlayer().motionY /= Math.max(Math.abs(WMinecraft.getPlayer().motionY) * 50, 1);
        if (!z)
            WMinecraft.getPlayer().motionZ /= Math.max(Math.abs(WMinecraft.getPlayer().motionZ) * 50, 1);
    }
    // horizontal movement
    if (horizontal) {
        if (!creativeFlying && WMinecraft.getPlayer().getDistance(nextPos.getX() + 0.5, pos.getY() + 0.1, nextPos.getZ() + 0.5) <= wurst.mods.flightMod.speed.getValueF()) {
            WMinecraft.getPlayer().setPosition(nextPos.getX() + 0.5, pos.getY() + 0.1, nextPos.getZ() + 0.5);
            return;
        }
        mc.gameSettings.keyBindForward.pressed = true;
        if (WMinecraft.getPlayer().isCollidedHorizontally)
            if (posVec.yCoord > nextBox.maxY)
                mc.gameSettings.keyBindSneak.pressed = true;
            else if (posVec.yCoord < nextBox.minY)
                mc.gameSettings.keyBindJump.pressed = true;
    // vertical movement
    } else if (y) {
        if (!creativeFlying && WMinecraft.getPlayer().getDistance(pos.getX() + 0.5, nextPos.getY() + 0.1, pos.getZ() + 0.5) <= wurst.mods.flightMod.speed.getValueF()) {
            WMinecraft.getPlayer().setPosition(pos.getX() + 0.5, nextPos.getY() + 0.1, pos.getZ() + 0.5);
            return;
        }
        if (posVec.yCoord < nextBox.minY)
            mc.gameSettings.keyBindJump.pressed = true;
        else
            mc.gameSettings.keyBindSneak.pressed = true;
        if (WMinecraft.getPlayer().isCollidedVertically) {
            mc.gameSettings.keyBindSneak.pressed = false;
            mc.gameSettings.keyBindForward.pressed = true;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 25 with Vec3i

use of net.minecraft.util.math.Vec3i in project Binnie by ForestryMC.

the class PageSpeciesGenome method onValueChanged.

@Override
public void onValueChanged(IAlleleSpecies species) {
    IAllele[] template = BeeManager.beeRoot.getTemplate(species.getUID());
    if (template == null) {
        return;
    }
    IBeeGenome genome = BeeManager.beeRoot.templateAsGenome(template);
    IBee bee = BeeManager.beeRoot.getBee(genome);
    speedText.setValue(rateSpeed(genome.getSpeed()));
    lifespanText.setValue(rateLifespan(genome.getLifespan()));
    fertilityText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".children", genome.getFertility()));
    floweringText.setValue(rateFlowering(genome.getFlowering()));
    Vec3i area = genome.getTerritory();
    territoryText.setValue(area.getX() + "x" + area.getY() + 'x' + area.getZ());
    String behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".daytime");
    if (genome.getPrimary().isNocturnal()) {
        behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".nighttime");
    }
    if (genome.getNeverSleeps()) {
        behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".allDay");
    }
    nocturnalText.setValue(behavior);
    if (genome.getCaveDwelling()) {
        caveDwellingText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".notNeeded"));
    } else {
        caveDwellingText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".required"));
    }
    tolerantFlyerText.setValue(tolerated(genome.getToleratesRain()));
    if (genome.getFlowerProvider() != null) {
        flowerText.setValue(genome.getFlowerProvider().getDescription());
    } else {
        flowerText.setValue(AlleleHelper.toDisplay(EnumTolerance.NONE));
    }
    effectText.setValue(genome.getEffect().getAlleleName());
}
Also used : IAllele(forestry.api.genetics.IAllele) Vec3i(net.minecraft.util.math.Vec3i) IBee(forestry.api.apiculture.IBee) IBeeGenome(forestry.api.apiculture.IBeeGenome)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)68 BlockPos (net.minecraft.util.math.BlockPos)35 IBlockState (net.minecraft.block.state.IBlockState)15 World (net.minecraft.world.World)10 EnumFacing (net.minecraft.util.EnumFacing)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Tessellator (net.minecraft.client.renderer.Tessellator)5 IBeeModifier (forestry.api.apiculture.IBeeModifier)4 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)4 Vec3d (net.minecraft.util.math.Vec3d)4 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 EnumTemperature (forestry.api.core.EnumTemperature)2 EffectLightning (hellfirepvp.fracture.client.effect.fx.EffectLightning)2 EntityFXFacingParticle (hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)2 FissureData (hellfirepvp.fracture.common.fissure.FissureData)2 Vector3 (hellfirepvp.fracture.common.util.Vector3)2 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)2 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)2 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)2