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