Search in sources :

Example 1 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class EffectHandler method tick.

public void tick() {
    if (cleanRequested) {
        for (Integer layer : complexEffects.keySet()) {
            List<EntityFX> effects = complexEffects.get(layer);
            effects.forEach(EntityFX::flagAsRemoved);
            effects.clear();
        }
        fastRenderParticles.clear();
        fastRenderLightnings.clear();
        toAddBuffer.clear();
        cleanRequested = false;
    }
    if (Minecraft.getMinecraft().player == null) {
        return;
    }
    acceptsNewParticles = false;
    for (Integer layer : complexEffects.keySet()) {
        Iterator<EntityFX> iterator = complexEffects.get(layer).iterator();
        while (iterator.hasNext()) {
            EntityFX effect = iterator.next();
            effect.tick();
            if (effect.needsRemoval()) {
                effect.flagAsRemoved();
                iterator.remove();
            }
        }
    }
    Vector3 playerPos = Vector3.atEntityCenter(Minecraft.getMinecraft().player);
    for (EntityFXFacingParticle effect : new ArrayList<>(fastRenderParticles)) {
        if (effect == null) {
            fastRenderParticles.remove(null);
            continue;
        }
        effect.tick();
        if (effect.needsRemoval() || effect.getPosition().distanceSquared(playerPos) >= Config.maxEffectRenderDistanceSq) {
            effect.flagAsRemoved();
            fastRenderParticles.remove(effect);
        }
    }
    for (EffectLightning effect : new ArrayList<>(fastRenderLightnings)) {
        if (effect == null) {
            fastRenderLightnings.remove(null);
            continue;
        }
        effect.tick();
        if (effect.needsRemoval()) {
            effect.flagAsRemoved();
            fastRenderLightnings.remove(effect);
        }
    }
    acceptsNewParticles = true;
    List<EntityFX> effects = new LinkedList<>(toAddBuffer);
    toAddBuffer.clear();
    for (EntityFX eff : effects) {
        registerUnsafe(eff);
    }
}
Also used : EffectLightning(hellfirepvp.fracture.client.effect.fx.EffectLightning) Vector3(hellfirepvp.fracture.common.util.Vector3) EntityFXFacingParticle(hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)

Example 2 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class FissureSwapHelper method doSwap.

public static boolean doSwap(TileFissureDevice device) {
    if (!device.isLinked())
        return false;
    int originDim = device.getWorld().provider.getDimension();
    BlockPos originPos = device.getPos();
    FissureData originData = FissureDataController.getFissureData(originDim, originPos);
    if (originData == null)
        return false;
    int linkedDim = device.getLinkedDimension();
    BlockPos linkedPos = device.getLinkedPos();
    FissureData targetData = FissureDataController.getFissureData(linkedDim, linkedPos);
    if (targetData == null)
        return false;
    BlockPos originMin = originData.getMin();
    BlockPos originMax = originData.getMax();
    BlockPos targetMin = targetData.getMin();
    BlockPos targetMax = targetData.getMax();
    BlockPos minOffset = new BlockPos(originMin.getX() < targetMin.getX() ? originMin.getX() : targetMin.getX(), originMin.getY() < targetMin.getY() ? originMin.getY() : targetMin.getY(), originMin.getZ() < targetMin.getZ() ? originMin.getZ() : targetMin.getZ());
    BlockPos maxOffset = new BlockPos(originMax.getX() > targetMax.getX() ? originMax.getX() : targetMax.getX(), originMax.getY() > targetMax.getY() ? originMax.getY() : targetMax.getY(), originMax.getZ() > targetMax.getZ() ? originMax.getZ() : targetMax.getZ());
    // Load worlds if not loaded yet
    World originWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(originDim);
    World targetWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(linkedDim);
    AxisAlignedBB boxOrigin = new AxisAlignedBB(minOffset.add(originPos), maxOffset.add(originPos));
    AxisAlignedBB boxTarget = new AxisAlignedBB(minOffset.add(linkedPos), maxOffset.add(linkedPos));
    List<BlockPos> ignoreOffsets = new LinkedList<>();
    Map<BlockPos, IBlockState> realOffsetStates = new HashMap<>();
    for (BlockPos pos : BlockPos.getAllInBox(minOffset.add(originPos), maxOffset.add(originPos))) {
        IBlockState from = originWorld.getBlockState(pos);
        if (originWorld.getTileEntity(pos) == null && from.getBlockHardness(originWorld, pos) >= 0F) {
            realOffsetStates.put(pos.subtract(originPos), from);
        } else {
            ignoreOffsets.add(pos.subtract(originPos));
        }
    }
    Map<BlockPos, IBlockState> targetOffsetStates = new HashMap<>();
    for (BlockPos pos : BlockPos.getAllInBox(minOffset.add(linkedPos), maxOffset.add(linkedPos))) {
        if (ignoreOffsets.contains(pos.subtract(linkedPos)))
            continue;
        IBlockState from = targetWorld.getBlockState(pos);
        if (targetWorld.getTileEntity(pos) == null && from.getBlockHardness(targetWorld, pos) >= 0F) {
            targetOffsetStates.put(pos.subtract(linkedPos), from);
        } else {
            realOffsetStates.remove(pos.subtract(linkedPos));
        }
    }
    for (Map.Entry<BlockPos, IBlockState> entry : realOffsetStates.entrySet()) {
        targetWorld.setBlockState(entry.getKey().add(linkedPos), entry.getValue());
    }
    for (Map.Entry<BlockPos, IBlockState> entry : targetOffsetStates.entrySet()) {
        originWorld.setBlockState(entry.getKey().add(originPos), entry.getValue());
    }
    List<EntityPlayer> originEntities = originWorld.getEntitiesWithinAABB(EntityPlayer.class, boxOrigin);
    List<EntityPlayer> targetEntities = targetWorld.getEntitiesWithinAABB(EntityPlayer.class, boxTarget);
    for (EntityPlayer e : originEntities) {
        Vector3 to = Vector3.atEntityCorner(e).subtract(originPos).add(linkedPos);
        MiscUtils.transferEntityTo(e, linkedDim, to);
    }
    for (EntityPlayer e : targetEntities) {
        Vector3 to = Vector3.atEntityCorner(e).subtract(linkedPos).add(originPos);
        MiscUtils.transferEntityTo(e, originDim, to);
    }
    FissureSwapPreparation.removeTicket(originDim, originPos);
    FissureSwapPreparation.removeTicket(linkedDim, linkedPos);
    return true;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) HashMap(java.util.HashMap) Vector3(hellfirepvp.fracture.common.util.Vector3) World(net.minecraft.world.World) LinkedList(java.util.LinkedList) FissureData(hellfirepvp.fracture.common.fissure.FissureData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class EffectLightning method renderCurrentTextureAroundAxis.

private void renderCurrentTextureAroundAxis(Vector3 from, Vector3 to, double angle, double size, BufferBuilder buf) {
    Vector3 aim = to.clone().subtract(from).normalize();
    Vector3 aimPerp = aim.clone().perpendicular().normalize();
    Vector3 perp = aimPerp.clone().rotate(angle, aim).normalize();
    Vector3 perpFrom = perp.clone().multiply(size);
    Vector3 perpTo = perp.multiply(size);
    Vector3 vec = from.clone().add(perpFrom.clone().multiply(-1));
    buf.pos(vec.getX(), vec.getY(), vec.getZ()).tex(1, 1).color(ovR, ovG, ovB, 1F).endVertex();
    vec = from.clone().add(perpFrom);
    buf.pos(vec.getX(), vec.getY(), vec.getZ()).tex(1, 0).color(ovR, ovG, ovB, 1F).endVertex();
    vec = to.clone().add(perpTo);
    buf.pos(vec.getX(), vec.getY(), vec.getZ()).tex(0, 0).color(ovR, ovG, ovB, 1F).endVertex();
    vec = to.clone().add(perpTo.clone().multiply(-1));
    buf.pos(vec.getX(), vec.getY(), vec.getZ()).tex(0, 1).color(ovR, ovG, ovB, 1F).endVertex();
}
Also used : Vector3(hellfirepvp.fracture.common.util.Vector3)

Example 4 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class EntityFXFacingParticle method renderBatched.

private void renderBatched(float partial, BufferBuilder vb) {
    float alpha = alphaFunction.getAlpha(age, maxAge);
    alpha *= alphaMultiplier;
    Vector3 iPos = RenderingUtils.interpolateVec(this.prevPos, this.pos, partial);
    RenderingUtils.renderFacingFullQuadVB(vb, iPos.getX(), iPos.getY(), iPos.getZ(), partial, scale, 0, colorRed, colorGreen, colorBlue, alpha);
}
Also used : Vector3(hellfirepvp.fracture.common.util.Vector3)

Example 5 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class EntityFXFloatingCube method render.

@Override
public void render(float partialTicks) {
    TextureHelper.refreshTextureBindState();
    texture.bind();
    GlStateManager.pushMatrix();
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableBlend();
    Blending.DEFAULT.apply();
    Blending.DEFAULT.applyStateManager();
    GlStateManager.disableCull();
    GlStateManager.depthMask(false);
    GlStateManager.disableAlpha();
    RenderingUtils.removeStandartTranslationFromTESRMatrix(partialTicks);
    Vector3 translateTo = getInterpolatedPosition(partialTicks);
    GL11.glTranslated(translateTo.getX(), translateTo.getY(), translateTo.getZ());
    float alpha = alphaFunction.getAlpha(age, maxAge);
    alpha *= alphaMultiplier;
    GlStateManager.color(colorRed, colorGreen, colorBlue, alpha);
    float scaleF = this.scale;
    scaleF = scaleFunction.getScale(this, partialTicks, scaleF);
    GlStateManager.scale(scaleF, scaleF, scaleF);
    Vector3 rotation = getInterpolatedRotation(partialTicks);
    GlStateManager.rotate((float) rotation.getX(), 1, 0, 0);
    GlStateManager.rotate((float) rotation.getY(), 0, 1, 0);
    GlStateManager.rotate((float) rotation.getZ(), 0, 0, 1);
    RenderingUtils.renderTexturedCubeCentral(new Vector3(), 1, 0, 0, 1, 1);
    GlStateManager.enableAlpha();
    GlStateManager.depthMask(true);
    GlStateManager.enableCull();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.popMatrix();
    TextureHelper.refreshTextureBindState();
}
Also used : Vector3(hellfirepvp.fracture.common.util.Vector3)

Aggregations

Vector3 (hellfirepvp.fracture.common.util.Vector3)23 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 EffectLightning (hellfirepvp.fracture.client.effect.fx.EffectLightning)4 EntityFXFacingParticle (hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)4 EntityFXFloatingCube (hellfirepvp.fracture.client.effect.fx.EntityFXFloatingCube)4 Entity (net.minecraft.entity.Entity)4 FissureData (hellfirepvp.fracture.common.fissure.FissureData)3 LinkedList (java.util.LinkedList)3 Random (java.util.Random)2 Vec3i (net.minecraft.util.math.Vec3i)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1