use of net.minecraft.util.math.Vec3i in project Galacticraft by micdoodle8.
the class TileEntitySolarArrayController method update.
@Override
public void update() {
if (!this.initialised) {
this.storage.setCapacity(50000);
this.initialised = true;
}
if (!this.world.isRemote) {
this.receiveEnergyGC(null, this.generateWatts, false);
EnumSet<EnumFacing> outputDirections = EnumSet.noneOf(EnumFacing.class);
outputDirections.addAll(Arrays.asList(EnumFacing.HORIZONTALS));
outputDirections.removeAll(this.getElectricalOutputDirections());
BlockVec3 thisVec = new BlockVec3(this);
solarArray.clear();
for (EnumFacing direction : outputDirections) {
TileEntity tileAdj = thisVec.getTileEntityOnSide(this.world, direction);
if (tileAdj != null) {
if (tileAdj instanceof INetworkProvider) {
if (tileAdj instanceof ITransmitter) {
if (((ITransmitter) tileAdj).canConnect(direction.getOpposite(), NetworkType.SOLAR_MODULE)) {
if (((INetworkProvider) tileAdj).getNetwork() instanceof SolarModuleNetwork) {
solarArray.addAll(((SolarModuleNetwork) ((INetworkProvider) tileAdj).getNetwork()).getTransmitters());
}
}
} else {
if (((INetworkProvider) tileAdj).getNetwork() instanceof SolarModuleNetwork) {
solarArray.addAll(((SolarModuleNetwork) ((INetworkProvider) tileAdj).getNetwork()).getTransmitters());
}
}
}
}
}
}
super.update();
if (!this.world.isRemote) {
this.recharge(this.getInventory().get(0));
if (this.disableCooldown > 0) {
this.disableCooldown--;
}
if (!this.getDisabled(0) && this.ticks % 20 == 0) {
this.solarStrength = 0;
int arraySizeWithinRange = 0;
if (this.world.isDaytime() && (this.world.provider instanceof IGalacticraftWorldProvider || !this.world.isRaining() && !this.world.isThundering())) {
for (ITransmitter transmitter : solarArray) {
TileEntity tile = (TileEntity) transmitter;
Vec3i diff = tile.getPos().subtract(this.getPos());
if (Math.abs(diff.getX()) <= 16 && diff.getY() == 0 && Math.abs(diff.getZ()) <= 16) {
arraySizeWithinRange++;
if (this.world.canBlockSeeSky(tile.getPos())) {
boolean valid = true;
for (int y = this.getPos().getY() + 1; y < 256; y++) {
IBlockState state = this.world.getBlockState(this.getPos().add(0, y, 0));
if (state.getBlock().isOpaqueCube(state)) {
valid = false;
break;
}
}
if (valid) {
this.solarStrength++;
}
}
}
}
}
connectedInfo = solarStrength << 16 | arraySizeWithinRange;
}
}
float angle = this.world.getCelestialAngle(1.0F) - 0.7845194F < 0 ? 1.0F - 0.7845194F : -0.7845194F;
float celestialAngle = (this.world.getCelestialAngle(1.0F) + angle) * 360.0F;
if (!(this.world.provider instanceof WorldProviderSpaceStation))
celestialAngle += 12.5F;
if (this.world.provider instanceof WorldProviderVenus)
celestialAngle = 180F - celestialAngle;
celestialAngle %= 360;
boolean isDaytime = this.world.isDaytime() && (celestialAngle < 180.5F || celestialAngle > 359.5F) || this.world.provider instanceof WorldProviderSpaceStation;
if (!this.world.isRemote) {
int generated = this.getGenerate();
if (generated > 0) {
this.generateWatts = Math.min(Math.max(generated, 0), TileEntitySolarArrayController.MAX_GENERATE_WATTS);
} else {
this.generateWatts = 0;
}
}
this.produce();
}
use of net.minecraft.util.math.Vec3i in project malmo by Microsoft.
the class BuildBattleDecoratorImplementation method parseParameters.
/**
* Attempt to parse the given object as a set of parameters for this handler.
*
* @param params the parameter block to parse
* @return true if the object made sense for this handler; false otherwise.
*/
@Override
public boolean parseParameters(Object params) {
if (params == null || !(params instanceof BuildBattleDecorator))
return false;
this.params = (BuildBattleDecorator) params;
this.sourceBounds = this.params.getGoalStructureBounds();
this.destBounds = this.params.getPlayerStructureBounds();
this.delta = new Vec3i(destBounds.getMin().getX() - sourceBounds.getMin().getX(), destBounds.getMin().getY() - sourceBounds.getMin().getY(), destBounds.getMin().getZ() - sourceBounds.getMin().getZ());
this.structureVolume = volumeOfBounds(this.sourceBounds);
assert (this.structureVolume == volumeOfBounds(this.destBounds));
this.dest = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState) null));
this.source = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState) null));
DrawBlockBasedObjectType tickBlock = this.params.getBlockTypeOnCorrectPlacement();
DrawBlockBasedObjectType crossBlock = this.params.getBlockTypeOnIncorrectPlacement();
this.blockTypeOnCorrectPlacement = (tickBlock != null) ? new XMLBlockState(tickBlock.getType(), tickBlock.getColour(), tickBlock.getFace(), tickBlock.getVariant()) : null;
this.blockTypeOnIncorrectPlacement = (crossBlock != null) ? new XMLBlockState(crossBlock.getType(), crossBlock.getColour(), crossBlock.getFace(), crossBlock.getVariant()) : null;
return true;
}
use of net.minecraft.util.math.Vec3i in project Minestuck by mraof.
the class SburbHandler method getUnderlingList.
public static List<SpawnListEntry> getUnderlingList(BlockPos pos, World world) {
BlockPos spawn = world.getSpawnPoint();
int difficulty = (int) Math.round(Math.sqrt(new Vec3i(pos.getX() >> 4, 0, pos.getZ() >> 4).distanceSq(new Vec3i(spawn.getX() >> 4, 0, spawn.getZ() >> 4))));
difficulty = Math.min(30, difficulty / 3);
if (difficultyList[difficulty] != null)
return difficultyList[difficulty];
ArrayList<SpawnListEntry> list = new ArrayList<SpawnListEntry>();
int impWeight, ogreWeight = 0, basiliskWeight = 0, lichWeight = 0, giclopsWeight = 0;
if (difficulty < 8)
impWeight = difficulty + 1;
else {
impWeight = 8 - (difficulty - 8) / 3;
if (difficulty < 20)
ogreWeight = (difficulty - 5) / 3;
else
ogreWeight = 5 - (difficulty - 20) / 3;
if (difficulty >= 16) {
if (difficulty < 26)
basiliskWeight = (difficulty - 14) / 2;
else
basiliskWeight = 6;
if (difficulty < 28)
lichWeight = (difficulty - 12) / 3;
else
lichWeight = 6;
if (difficulty >= 20)
if (difficulty < 30)
giclopsWeight = (difficulty - 17) / 3;
else
giclopsWeight = 5;
}
}
if (impWeight > 0)
list.add(new SpawnListEntry(EntityImp.class, impWeight, Math.max(1, (int) (impWeight / 2.5)), Math.max(3, impWeight)));
if (ogreWeight > 0)
list.add(new SpawnListEntry(EntityOgre.class, ogreWeight, ogreWeight >= 5 ? 2 : 1, Math.max(1, ogreWeight / 2)));
if (basiliskWeight > 0)
list.add(new SpawnListEntry(EntityBasilisk.class, basiliskWeight, 1, Math.max(1, basiliskWeight / 2)));
if (lichWeight > 0)
list.add(new SpawnListEntry(EntityLich.class, lichWeight, 1, Math.max(1, lichWeight / 2)));
if (giclopsWeight > 0 && !MinestuckConfig.disableGiclops)
list.add(new SpawnListEntry(EntityGiclops.class, giclopsWeight, 1, Math.max(1, giclopsWeight / 2)));
difficultyList[difficulty] = list;
return list;
}
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));
}
}
}
}
}
Aggregations