use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project MorePlanets by SteveKunG.
the class RenderTier4Rocket method doRender.
@Override
public void doRender(EntityTier4Rocket entity, double x, double y, double z, float entityYaw, float partialTicks) {
float rotationPitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks + 180;
float rollAmplitude = entity.rollAmplitude / 3 - partialTicks;
GlStateManager.disableRescaleNormal();
GlStateManager.pushMatrix();
GlStateManager.translate((float) x, (float) y + entity.getRenderOffsetY(), (float) z);
GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-rotationPitch, 0.0F, 0.0F, 1.0F);
if (rollAmplitude > 0.0F) {
float i = entity.getLaunched() ? (5 - MathHelper.floor(entity.timeUntilLaunch / 85)) / 10F : 0.3F;
GlStateManager.rotate(MathHelper.sin(rollAmplitude) * rollAmplitude * i * partialTicks, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(MathHelper.sin(rollAmplitude) * rollAmplitude * i * partialTicks, 1.0F, 0.0F, 1.0F);
}
this.updateModel();
RenderHelper.disableStandardItemLighting();
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(7425);
} else {
GlStateManager.shadeModel(7424);
}
GlStateManager.scale(-1.0F, -1.0F, 1.0F);
GlStateManager.scale(0.8F, 0.8F, 0.8F);
ClientUtil.drawBakedModel(this.rocketModel);
Vector3 teamColor = ClientUtil.updateTeamColor(Minecraft.getMinecraft().player.getName(), true);
if (teamColor != null) {
GlStateManager.color(teamColor.floatX(), teamColor.floatY(), teamColor.floatZ());
}
if (Minecraft.getMinecraft().player.ticksExisted / 10 % 2 < 1) {
GlStateManager.color(1, 0, 0);
} else {
GlStateManager.color(0, 1, 0);
}
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
GlStateManager.color(1, 1, 1);
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project MorePlanets by SteveKunG.
the class EntityTieredRocketMP method makeFlame.
private void makeFlame(double x2, double y2, double z2, Vector3 motionVec, boolean getLaunched) {
EntityLivingBase riddenByEntity = this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof EntityLivingBase) ? null : (EntityLivingBase) this.getPassengers().get(0);
if (getLaunched) {
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y2, z2 + 0.4 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y2, z2 + 0.4 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y2, z2 - 0.4 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y2, z2 - 0.4 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2, y2, z2), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2 + 0.4, y2, z2), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2 - 0.4, y2, z2), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2, y2, z2 + 0.4D), motionVec, new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameLaunched", new Vector3(x2, y2, z2 - 0.4D), motionVec, new Object[] { riddenByEntity });
return;
}
double x1 = motionVec.x;
double y1 = motionVec.y;
double z1 = motionVec.z;
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y2, z2 + 0.4 - this.rand.nextDouble() / 10), new Vector3(x1 + 0.5D, y1 - 0.3D, z1 + 0.5D), new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y2, z2 + 0.4 - this.rand.nextDouble() / 10), new Vector3(x1 - 0.5D, y1 - 0.3D, z1 + 0.5D), new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y2, z2 - 0.4 + this.rand.nextDouble() / 10), new Vector3(x1 - 0.5D, y1 - 0.3D, z1 - 0.5D), new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y2, z2 - 0.4 + this.rand.nextDouble() / 10), new Vector3(x1 + 0.5D, y1 - 0.3D, z1 - 0.5D), new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2 + 0.4, y2, z2), new Vector3(x1 + 0.8D, y1 - 0.3D, z1), new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2 - 0.4, y2, z2), new Vector3(x1 - 0.8D, y1 - 0.3D, z1), new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2, y2, z2 + 0.4D), new Vector3(x1, y1 - 0.3D, z1 + 0.8D), new Object[] { riddenByEntity });
GalacticraftCore.proxy.spawnParticle("launchFlameIdle", new Vector3(x2, y2, z2 - 0.4D), new Vector3(x1, y1 - 0.3D, z1 - 0.8D), new Object[] { riddenByEntity });
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class CommandGCHouston method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
EntityPlayerMP playerBase = null;
MinecraftServer server = MinecraftServer.getServer();
boolean isOp = false;
Entity entitySender = sender.getCommandSenderEntity();
if (entitySender == null) {
isOp = true;
} else if (entitySender instanceof EntityPlayer) {
GameProfile prof = ((EntityPlayer) entitySender).getGameProfile();
isOp = server.getConfigurationManager().canSendCommands(prof);
}
if (args.length < 2) {
try {
if (args.length == 0) {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
if (!playerBase.capabilities.isCreativeMode) {
if (ConfigManagerCore.challengeMode || !(playerBase.worldObj.provider instanceof IGalacticraftWorldProvider)) {
CommandBase.notifyOperators(sender, this, "commands.gchouston.fail");
return;
}
}
if (timerList.contains(playerBase)) {
timerList.remove(playerBase);
} else {
timerList.add(playerBase);
TickHandlerServer.timerHoustonCommand = 250;
String msg = EnumColor.YELLOW + GCCoreUtil.translate("commands.gchouston.confirm.1") + " " + EnumColor.WHITE + GCCoreUtil.translate("commands.gchouston.confirm.2");
CommandBase.notifyOperators(sender, this, msg);
return;
}
} else {
if (!isOp) {
CommandBase.notifyOperators(sender, this, "commands.gchouston.noop");
return;
}
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
}
if (playerBase != null) {
int dimID = ConfigManagerCore.idDimensionOverworld;
WorldServer worldserver = server.worldServerForDimension(dimID);
if (worldserver == null) {
worldserver = server.worldServerForDimension(0);
if (worldserver == null) {
throw new Exception("/gchouston could not find Overworld.");
}
dimID = 0;
}
BlockPos spawnPoint = null;
BlockPos bedPos = playerBase.getBedLocation(dimID);
if (bedPos != null) {
spawnPoint = EntityPlayer.getBedSpawnLocation(worldserver, bedPos, false);
}
if (spawnPoint == null) {
spawnPoint = worldserver.getTopSolidOrLiquidBlock(worldserver.getSpawnPoint());
}
GCPlayerStats stats = GCPlayerStats.get(playerBase);
stats.setRocketStacks(new ItemStack[0]);
stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
stats.setRocketItem(null);
stats.setFuelLevel(0);
stats.setCoordsTeleportedFromX(spawnPoint.getX());
stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
stats.setUsingPlanetSelectionGui(false);
playerBase.closeScreen();
Vector3 spawnPos = new Vector3(spawnPoint.getX() + 0.5D, spawnPoint.getY() + 0.25D, spawnPoint.getZ() + 0.5D);
try {
WorldUtil.teleportEntitySimple(worldserver, dimID, playerBase, spawnPos);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
CommandBase.notifyOperators(sender, this, "commands.gchouston.success", new Object[] { String.valueOf(EnumColor.GREY + "" + playerBase.getName()) });
} else {
throw new Exception("Could not find player with name: " + args[0]);
}
} catch (final Exception var6) {
throw new CommandException(var6.getMessage(), new Object[0]);
}
} else {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getCommandUsage(sender)), new Object[0]);
}
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class TileEntityAirLockController method update.
@Override
public void update() {
super.update();
if (!this.worldObj.isRemote) {
this.active = false;
if (this.redstoneActivation) {
this.active = this.worldObj.isBlockIndirectlyGettingPowered(this.getPos()) > 0;
}
if ((this.active || !this.redstoneActivation) && this.playerDistanceActivation) {
double distance = 0D;
switch(this.playerDistanceSelection) {
case 0:
distance = 1.0D;
break;
case 1:
distance = 2.0D;
break;
case 2:
distance = 5.0D;
break;
case 3:
distance = 10.0D;
break;
}
Vector3 minPos = new Vector3(this).translate(0.5D - distance);
Vector3 maxPos = new Vector3(this).translate(0.5D + distance);
AxisAlignedBB matchingRegion = AxisAlignedBB.fromBounds(minPos.x, minPos.y, minPos.z, maxPos.x, maxPos.y, maxPos.z);
List<EntityPlayer> playersWithin = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, matchingRegion);
if (this.playerNameMatches) {
boolean foundPlayer = false;
for (EntityPlayer p : playersWithin) {
if (PlayerUtil.getName(p).equalsIgnoreCase(this.playerToOpenFor)) {
foundPlayer = true;
break;
}
}
this.active = foundPlayer;
} else {
this.active = !playersWithin.isEmpty();
}
}
if (!this.invertSelection) {
this.active = !this.active;
}
if (this.protocol == null) {
this.protocol = this.lastProtocol = new AirLockProtocol(this);
}
if (this.ticks % 5 == 0) {
if (this.horizontalModeEnabled != this.lastHorizontalModeEnabled) {
this.unsealAirLock();
} else if (this.active || this.lastActive) {
this.lastOtherAirLocks = this.otherAirLocks;
this.otherAirLocks = this.protocol.calculate(this.horizontalModeEnabled);
if (this.active) {
if (this.otherAirLocks != this.lastOtherAirLocks || !this.lastActive) {
this.unsealAirLock();
if (this.otherAirLocks >= 0) {
this.sealAirLock();
}
}
} else {
if (this.lastActive) {
this.unsealAirLock();
}
}
}
if (this.active != this.lastActive) {
this.worldObj.markBlockForUpdate(this.getPos());
}
this.lastActive = this.active;
this.lastProtocol = this.protocol;
this.lastHorizontalModeEnabled = this.horizontalModeEnabled;
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class TeleportTypeAsteroids method getPlayerSpawnLocation.
@Override
public Vector3 getPlayerSpawnLocation(WorldServer world, EntityPlayerMP player) {
if (player != null) {
GCPlayerStats stats = GCPlayerStats.get(player);
int x = MathHelper.floor_double(stats.getCoordsTeleportedFromX());
int z = MathHelper.floor_double(stats.getCoordsTeleportedFromZ());
int limit = ConfigManagerCore.otherPlanetWorldBorders - 2;
if (limit > 20) {
if (x > limit) {
z *= limit / x;
x = limit;
} else if (x < -limit) {
z *= -limit / x;
x = -limit;
}
if (z > limit) {
x *= limit / z;
z = limit;
} else if (z < -limit) {
x *= -limit / z;
z = -limit;
}
}
int attemptCount = 0;
// Small pre-generate with a chunk loading radius of 3, to make sure some asteroids get generated
// (if the world is already generated here, this will be very quick)
this.preGenChunks(world, x >> 4, z >> 4);
do {
BlockVec3 bv3 = null;
if (world.provider instanceof WorldProviderAsteroids) {
bv3 = ((WorldProviderAsteroids) world.provider).getClosestAsteroidXZ(x, 0, z, true);
}
if (bv3 != null) {
// Check whether the returned asteroid is too far from the desired entry location in which case, give up
if (bv3.distanceSquared(new BlockVec3(x, 128, z)) > 25600) {
break;
}
if (ConfigManagerCore.enableDebug) {
GCLog.info("Testing asteroid at x" + (bv3.x) + " y" + (bv3.y) + " z" + bv3.z);
}
this.loadChunksAround(bv3.x, bv3.z, 2, world.theChunkProviderServer);
this.loadChunksAround(bv3.x, bv3.z, -3, world.theChunkProviderServer);
if (goodAsteroidEntry(world, bv3.x, bv3.y, bv3.z)) {
return new Vector3(bv3.x, 310, bv3.z);
}
if (goodAsteroidEntry(world, bv3.x + 2, bv3.y, bv3.z + 2)) {
return new Vector3(bv3.x + 2, 310, bv3.z + 2);
}
if (goodAsteroidEntry(world, bv3.x + 2, bv3.y, bv3.z - 2)) {
return new Vector3(bv3.x + 2, 310, bv3.z - 2);
}
if (goodAsteroidEntry(world, bv3.x - 2, bv3.y, bv3.z - 2)) {
return new Vector3(bv3.x - 2, 310, bv3.z - 2);
}
if (goodAsteroidEntry(world, bv3.x - 2, bv3.y, bv3.z + 2)) {
return new Vector3(bv3.x - 2, 310, bv3.z + 2);
}
// Failed to find an asteroid even though there should be one there
if (ConfigManagerCore.enableDebug) {
GCLog.info("Removing drilled out asteroid at x" + (bv3.x) + " z" + (bv3.z));
}
((WorldProviderAsteroids) world.provider).removeAsteroid(bv3.x, bv3.y, bv3.z);
}
attemptCount++;
} while (attemptCount < 5);
FMLLog.info("Failed to find good large asteroid landing spot! Falling back to making a small one.");
this.makeSmallLandingSpot(world, x, z);
return new Vector3(x, 310, z);
}
FMLLog.severe("Null player when teleporting to Asteroids!");
return new Vector3(0, 310, 0);
}
Aggregations