use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class MapUtil method convertBiomeColour.
public static int convertBiomeColour(int in, int height) {
int rv;
int s = MapUtil.biomeColours.size();
if (in >= 128 && in < 128 + s) {
in -= 128;
}
if (in >= s) {
rv = getBiomeBaseColour(in);
} else {
BlockVec3 bv = MapUtil.biomeColours.get(in);
if (bv == null) {
rv = getBiomeBaseColour(in);
} else {
if (bv.z > 0 && MapUtil.rand.nextInt(100) < bv.z) {
rv = bv.y;
} else {
rv = bv.x;
}
}
}
if (rv == 0x9c2424 && MapUtil.rand.nextInt(2) == 0) {
rv = 0xbfa384;
}
if (height < OCEAN_HEIGHT) {
return rv;
}
if (height > 92 && (in == 3 || in == 20 || in == 31 || in == 33 || in == 34)) {
if (MapUtil.rand.nextInt(8) > 98 - height) {
rv = Material.snow.getMaterialMapColor().colorValue;
}
}
float factor = (height - 68F) / 94F;
return ColorUtil.lighten(rv, factor);
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class RenderAstroMiner method doRender.
@Override
public void doRender(EntityAstroMiner astroMiner, double x, double y, double z, float f, float partialTickTime) {
int ais = astroMiner.AIstate;
boolean active = ais > EntityAstroMiner.AISTATE_ATBASE;
float time = astroMiner.ticksExisted + partialTickTime;
float sinOfTheTime = (MathHelper.sin(time / 4) + 1F) / 4F + 0.5F;
float wx = active ? this.wobbleX.getNoise(time) + this.wobbleXX.getNoise(time) : 0F;
float wy = active ? this.wobbleY.getNoise(time) + this.wobbleYY.getNoise(time) : 0F;
float wz = active ? this.wobbleZ.getNoise(time) + this.wobbleZZ.getNoise(time) : 0F;
float partTime = partialTickTime - this.lastPartTime;
this.lastPartTime = partialTickTime;
while (partTime < 0) {
partTime += 1F;
}
this.updateModels();
this.bindEntityTexture(astroMiner);
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(GL11.GL_SMOOTH);
} else {
GlStateManager.shadeModel(GL11.GL_FLAT);
}
GlStateManager.disableRescaleNormal();
GlStateManager.pushMatrix();
final float rotPitch = astroMiner.prevRotationPitch + (astroMiner.rotationPitch - astroMiner.prevRotationPitch) * partialTickTime;
final float rotYaw = astroMiner.prevRotationYaw + (astroMiner.rotationYaw - astroMiner.prevRotationYaw) * partialTickTime;
GlStateManager.translate((float) x, (float) y + 1.4F, (float) z);
float partBlock;
switch(astroMiner.facing) {
case DOWN:
partBlock = (float) (astroMiner.posY % 2D);
break;
case UP:
partBlock = 1F - (float) (astroMiner.posY % 2D);
break;
case NORTH:
partBlock = (float) (astroMiner.posZ % 2D);
break;
case SOUTH:
partBlock = 1F - (float) (astroMiner.posZ % 2D);
break;
case WEST:
partBlock = (float) (astroMiner.posX % 2D);
break;
case EAST:
partBlock = 1F - (float) (astroMiner.posX % 2D);
break;
default:
partBlock = 0F;
}
partBlock /= 0.06F;
GlStateManager.rotate(rotYaw + 180F, 0, 1, 0);
if (rotPitch != 0F) {
GlStateManager.translate(-0.65F, -0.65F, 0);
GlStateManager.rotate(rotPitch / 4F, 1, 0, 0);
GlStateManager.translate(0.65F, 0.65F, 0);
}
GlStateManager.translate(0F, -0.42F, 0.28F);
GlStateManager.scale(0.0495F, 0.0495F, 0.0495F);
GlStateManager.translate(wx, wy, wz);
if (active) {
ClientUtil.drawBakedModel(this.mainModel);
this.renderLaserModel(astroMiner.retraction);
float lightMapSaveX = OpenGlHelper.lastBrightnessX;
float lightMapSaveY = OpenGlHelper.lastBrightnessY;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
GlStateManager.disableLighting();
GlStateManager.color(sinOfTheTime, sinOfTheTime, sinOfTheTime, 1.0F);
ClientUtil.drawBakedModel(this.hoverPadMain);
GlStateManager.disableCull();
GlStateManager.disableAlpha();
GlStateManager.depthMask(false);
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GlStateManager.enableBlend();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GlStateManager.color(sinOfTheTime, sinOfTheTime, sinOfTheTime, 0.6F);
ClientUtil.drawBakedModel(this.hoverPadGlow);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
if (ais < EntityAstroMiner.AISTATE_DOCKING) {
// This is the scanning lasers:
FMLClientHandler.instance().getClient().renderEngine.bindTexture(scanTexture);
final Tessellator tess = Tessellator.getInstance();
GlStateManager.color(0, 0.6F, 1.0F, 0.2F);
WorldRenderer worldRenderer = tess.getWorldRenderer();
float scanProgress = (MathHelper.cos(partBlock * 0.012F * 6.283F)) * 0.747F;
float scanAngle = 0.69866F - scanProgress * scanProgress;
float scanEndX = 38.77F * MathHelper.sin(scanAngle);
float scanEndY = 32F;
float scanEndZ = 38.77F * MathHelper.cos(scanAngle);
scanEndZ += 20F;
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
worldRenderer.pos(15.6F, -0.6F, -20F).tex(0D, 0D).endVertex();
worldRenderer.pos(15.6F + scanEndX, scanEndY - 0.6F, -scanEndZ).tex(1D, 0D).endVertex();
worldRenderer.pos(15.6F + scanEndX, -0.6F - scanEndY, -scanEndZ).tex(1D, 1D).endVertex();
worldRenderer.pos(15.6F, -0.7F, -20F).tex(0D, 1D).endVertex();
tess.draw();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
worldRenderer.pos(-15.6F, -0.6F, -20F).tex(0D, 0D).endVertex();
worldRenderer.pos(-15.6F - scanEndX, scanEndY - 0.6F, -scanEndZ).tex(1D, 0D).endVertex();
worldRenderer.pos(-15.6F - scanEndX, -0.6F - scanEndY, -scanEndZ).tex(1D, 1D).endVertex();
worldRenderer.pos(-15.6F, -0.7F, -20F).tex(0D, 1D).endVertex();
tess.draw();
int removeCount = 0;
int afterglowCount = 0;
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.translate((float) (x - astroMiner.posX), (float) (y - astroMiner.posY), (float) (z - astroMiner.posZ));
for (Integer blockTime : new ArrayList<Integer>(astroMiner.laserTimes)) {
if (blockTime < astroMiner.ticksExisted - 19) {
removeCount++;
} else if (blockTime < astroMiner.ticksExisted - 3) {
afterglowCount++;
}
}
if (removeCount > 0) {
astroMiner.removeLaserBlocks(removeCount);
}
int count = 0;
for (BlockVec3 blockLaser : new ArrayList<BlockVec3>(astroMiner.laserBlocks)) {
if (count < afterglowCount) {
int fade = astroMiner.ticksExisted - astroMiner.laserTimes.get(count) - 8;
if (fade < 0) {
fade = 0;
}
this.doAfterGlow(blockLaser, fade);
} else {
this.doLaser(astroMiner, blockLaser);
}
count++;
}
if (astroMiner.retraction > 0F) {
astroMiner.retraction -= RETRACTIONSPEED * partTime;
if (astroMiner.retraction < 0F) {
astroMiner.retraction = 0F;
}
}
GlStateManager.popMatrix();
} else {
if (astroMiner.retraction < 1F) {
astroMiner.retraction += RETRACTIONSPEED * partTime;
if (astroMiner.retraction > 1F) {
astroMiner.retraction = 1F;
}
}
GlStateManager.popMatrix();
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableCull();
GlStateManager.enableAlpha();
GlStateManager.enableLighting();
GlStateManager.depthMask(true);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightMapSaveX, lightMapSaveY);
} else {
this.bindEntityTexture(astroMiner);
ClientUtil.drawBakedModel(this.mainModelInactive);
this.renderLaserModel(astroMiner.retraction);
if (astroMiner.retraction < 1F) {
astroMiner.retraction += RETRACTIONSPEED * partTime;
if (astroMiner.retraction > 1F) {
astroMiner.retraction = 1F;
}
}
GlStateManager.popMatrix();
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class ShortRangeTelepadHandler method addShortRangeTelepad.
public static void addShortRangeTelepad(TileEntityShortRangeTelepad telepad) {
if (!telepad.getWorld().isRemote) {
if (telepad.addressValid) {
TelepadEntry newEntry = new TelepadEntry(GCCoreUtil.getDimensionID(telepad.getWorld()), new BlockVec3(telepad));
TelepadEntry previous = tileMap.put(telepad.address, newEntry);
if (previous == null || !previous.equals(newEntry)) {
AsteroidsTickHandlerServer.spaceRaceData.setDirty(true);
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class EntityAstroMiner method setMinePoints.
private void setMinePoints() {
// Still some areas left to mine from last visit (maybe it was full or out of power?)
if (this.minePoints.size() > 0) {
return;
}
BlockVec3 inFront = new BlockVec3(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 1.5D), MathHelper.floor_double(this.posZ + 0.5D));
int otherEnd = (this.worldObj.provider instanceof WorldProviderAsteroids) ? this.MINE_LENGTH_AST : this.MINE_LENGTH;
if (this.baseFacing == EnumFacing.NORTH || this.baseFacing == EnumFacing.WEST) {
otherEnd = -otherEnd;
}
switch(this.baseFacing) {
case NORTH:
case SOUTH:
this.minePoints.add(inFront.clone().translate(0, 0, otherEnd));
this.minePoints.add(inFront.clone().translate(4, 0, otherEnd));
this.minePoints.add(inFront.clone().translate(4, 0, 0));
this.minePoints.add(inFront.clone().translate(2, 3, 0));
this.minePoints.add(inFront.clone().translate(2, 3, otherEnd));
this.minePoints.add(inFront.clone().translate(-2, 3, otherEnd));
this.minePoints.add(inFront.clone().translate(-2, 3, 0));
this.minePoints.add(inFront.clone().translate(-4, 0, 0));
this.minePoints.add(inFront.clone().translate(-4, 0, otherEnd));
this.minePoints.add(inFront.clone().translate(-2, -3, otherEnd));
this.minePoints.add(inFront.clone().translate(-2, -3, 0));
this.minePoints.add(inFront.clone().translate(2, -3, 0));
this.minePoints.add(inFront.clone().translate(2, -3, otherEnd));
this.minePoints.add(inFront.clone().translate(0, 0, otherEnd));
break;
case WEST:
case EAST:
this.minePoints.add(inFront.clone().translate(otherEnd, 0, 0));
this.minePoints.add(inFront.clone().translate(otherEnd, 0, 4));
this.minePoints.add(inFront.clone().translate(0, 0, 4));
this.minePoints.add(inFront.clone().translate(0, 3, 2));
this.minePoints.add(inFront.clone().translate(otherEnd, 3, 2));
this.minePoints.add(inFront.clone().translate(otherEnd, 3, -2));
this.minePoints.add(inFront.clone().translate(0, 3, -2));
this.minePoints.add(inFront.clone().translate(0, 0, -4));
this.minePoints.add(inFront.clone().translate(otherEnd, 0, -4));
this.minePoints.add(inFront.clone().translate(otherEnd, -3, -2));
this.minePoints.add(inFront.clone().translate(0, -3, -2));
this.minePoints.add(inFront.clone().translate(0, -3, 2));
this.minePoints.add(inFront.clone().translate(otherEnd, -3, 2));
this.minePoints.add(inFront.clone().translate(otherEnd, 0, 0));
break;
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class WorldProviderAsteroids method getClosestAsteroidsXZ.
public ArrayList<BlockVec3> getClosestAsteroidsXZ(int x, int y, int z, int facing, int count) {
if (!this.checkHasAsteroids()) {
return null;
}
TreeMap<Integer, BlockVec3> targets = new TreeMap<>();
for (AsteroidData roid : this.asteroids) {
BlockVec3 test = roid.centre;
switch(facing) {
case 2:
if (z - 16 < test.z) {
continue;
}
break;
case 3:
if (z + 16 > test.z) {
continue;
}
break;
case 4:
if (x - 16 < test.x) {
continue;
}
break;
case 5:
if (x + 16 > test.x) {
continue;
}
break;
}
int dx = x - test.x;
int dz = z - test.z;
int a = dx * dx + dz * dz;
if (a < 262144) {
targets.put(a, test);
}
}
int max = Math.max(count, targets.size());
if (max <= 0) {
return null;
}
ArrayList<BlockVec3> returnValues = new ArrayList<>();
int i = 0;
int offset = EntityAstroMiner.MINE_LENGTH_AST / 2;
for (BlockVec3 target : targets.values()) {
BlockVec3 coords = target.clone();
GCLog.debug("Found nearby asteroid at " + target.toString());
switch(facing) {
case 2:
coords.z += offset;
break;
case 3:
coords.z -= offset;
break;
case 4:
coords.x += offset;
break;
case 5:
coords.x -= offset;
break;
}
returnValues.add(coords);
if (++i >= count) {
break;
}
}
return returnValues;
}
Aggregations