use of net.minecraft.util.math.Vec3i in project Totemic by TeamTotemic.
the class ComponentTipi method placeTipi.
private void placeTipi(World world, int x, int y, int z, EnumFacing dir, StructureBoundingBox bb) {
// Place dummy blocks
for (int i = 0; i < 2; i++) {
for (EnumFacing blockDir : EnumFacing.HORIZONTALS) {
if (blockDir == dir)
continue;
Vec3i dirVec = blockDir.getDirectionVec();
setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x + dirVec.getX(), y + i, z + dirVec.getZ(), bb);
}
}
setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x, y + 3, z, bb);
setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x, y + 4, z, bb);
setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x, y + 5, z, bb);
// Place Tipi block itself
setBlockState(world, ModBlocks.tipi.getDefaultState().withProperty(BlockTipi.FACING, dir), x, y, z, bb);
}
use of net.minecraft.util.math.Vec3i in project Charset by CharsetMC.
the class CharsetTweakBlockCarrying method dropCarriedBlock.
protected static boolean dropCarriedBlock(EntityPlayer entity, boolean must, int maxRadius) {
CarryHandler carryHandler = entity.getCapability(CAPABILITY, null);
if (carryHandler != null && carryHandler.isCarrying()) {
World world = entity.getEntityWorld();
if (world.isRemote) {
carryHandler.empty();
return true;
}
BlockPos base = entity.getPosition();
for (int method = 0; method <= (must ? 2 : 1); method++) {
for (int radius = 0; radius <= maxRadius; radius++) {
Vec3i radiusVec = new Vec3i(radius, radius, radius);
for (BlockPos pos : BlockPos.getAllInBoxMutable(base.subtract(radiusVec), base.add(radiusVec))) {
if (world.getBlockState(pos).getBlock().isReplaceable(world, pos) && (method > 1 || !world.isAirBlock(pos.down())) && (method > 0 || world.isSideSolid(pos.down(), EnumFacing.UP))) {
carryHandler.place(world, pos.toImmutable(), EnumFacing.UP, entity);
}
if (!carryHandler.isCarrying())
break;
}
if (!carryHandler.isCarrying())
break;
}
if (!carryHandler.isCarrying())
break;
}
if (carryHandler.isCarrying()) {
if (must) {
ModCharset.logger.error("Could not drop carried block from player " + entity.getName() + "! This is a bug!");
}
return false;
} else {
CharsetTweakBlockCarrying.syncCarryWithAllClients(entity);
return true;
}
} else {
return true;
}
}
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