use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.
the class WorldGenHelper method generateCylinderFromPos.
/**
* Center is the bottom middle of the cylinder
*/
public static void generateCylinderFromPos(World world, ITreeBlockType block, BlockPos center, float radius, int height, EnumReplaceMode replace) {
BlockPos start = new BlockPos(center.getX() - radius, center.getY(), center.getZ() - radius);
for (int x = 0; x < radius * 2 + 1; x++) {
for (int y = height - 1; y >= 0; y--) {
// generating top-down is faster for lighting calculations
for (int z = 0; z < radius * 2 + 1; z++) {
BlockPos position = start.add(x, y, z);
Vec3i treeCenter = new Vec3i(center.getX(), position.getY(), center.getZ());
if (position.distanceSq(treeCenter) <= radius * radius + 0.01) {
EnumFacing direction = VectUtil.direction(position, treeCenter);
block.setDirection(direction);
addBlock(world, position, block, replace);
}
}
}
}
}
use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.
the class FarmLogic method getHarvestBox.
private static AxisAlignedBB getHarvestBox(World world, IFarmHousing farmHousing, boolean toWorldHeight) {
BlockPos coords = farmHousing.getCoords();
Vec3i area = farmHousing.getArea();
Vec3i offset = farmHousing.getOffset();
BlockPos min = coords.add(offset);
BlockPos max = min.add(area);
int maxY = max.getY();
if (toWorldHeight) {
maxY = world.getHeight();
}
return new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX(), maxY, max.getZ());
}
use of net.minecraft.util.math.Vec3i in project Fracture 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);
}
use of net.minecraft.util.math.Vec3i in project Fracture 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());
if (this.swapPerc > 0F) {
for (int i = 0; i < 40; i++) {
if (rand.nextFloat() < this.swapPerc) {
Vector3 offset = Vector3.random().multiply(2.5);
if (rand.nextBoolean()) {
offset = Vector3.random();
}
Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(offset).addY(1.3);
Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-20);
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);
}
}
for (int i = 0; i < 2; i++) {
if (rand.nextFloat() < this.swapPerc && otherData != null) {
Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
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));
}
}
}
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(-20);
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));
}
}
}
}
}
use of net.minecraft.util.math.Vec3i in project Fracture by HellFirePvP.
the class TileFissureDevice method playOuterCube.
@SideOnly(Side.CLIENT)
private void playOuterCube(FissureData drawData) {
if (drawData == null)
return;
int max = 0;
Vec3i minV = drawData.getMin();
Vec3i maxV = drawData.getMax();
if (Math.abs(minV.getX()) > max) {
max = Math.abs(minV.getX());
}
if (Math.abs(minV.getY()) > max) {
max = Math.abs(minV.getY());
}
if (Math.abs(minV.getZ()) > max) {
max = Math.abs(minV.getZ());
}
if (Math.abs(maxV.getX()) > max) {
max = Math.abs(maxV.getX());
}
if (Math.abs(maxV.getY()) > max) {
max = Math.abs(maxV.getY());
}
if (Math.abs(maxV.getZ()) > max) {
max = Math.abs(maxV.getZ());
}
if (outerFloatingCube1 == null || ((EntityFXFloatingCube) outerFloatingCube1).isRemoved()) {
outerFloatingCube1 = setupOuterCube(max);
}
if (outerFloatingCube2 == null || ((EntityFXFloatingCube) outerFloatingCube2).isRemoved()) {
outerFloatingCube2 = setupOuterCube(max);
}
handleOuterAnimations(outerFloatingCube1, max);
handleOuterAnimations(outerFloatingCube2, max);
}
Aggregations