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);
}
}
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;
}
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();
}
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);
}
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();
}
Aggregations