use of net.minecraft.crash.CrashReport in project RecurrentComplex by Ivorforce.
the class SpawnCommandLogic method trigger.
public void trigger(World worldIn) {
if (!worldIn.isRemote) {
MinecraftServer minecraftserver = this.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && minecraftserver.isCommandBlockEnabled()) {
ICommandManager icommandmanager = minecraftserver.getCommandManager();
ICommandListener cachedAdmin = null;
if (!RCConfig.notifyAdminOnBlockCommands) {
cachedAdmin = RCAccessorCommandBase.getCommandAdmin();
CommandBase.setCommandListener(null);
}
try {
icommandmanager.executeCommand(this, this.commandStored);
} catch (Exception ex) {
CrashReport crashreport = CrashReport.makeCrashReport(ex, "Executing command block");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed");
crashreportcategory.addDetail("Command", this::getCommand);
crashreportcategory.addDetail("Name", this::getName);
throw new ReportedException(crashreport);
}
if (!RCConfig.notifyAdminOnBlockCommands)
CommandBase.setCommandListener(cachedAdmin);
}
}
}
use of net.minecraft.crash.CrashReport in project Galacticraft by micdoodle8.
the class BlockVec3Dim method getBlockState.
/**
* Get block ID at the BlockVec3Dim coordinates, with a forced chunk load if
* the coordinates are unloaded. Only works server-side.
*
* @return the block ID, or null if the y-coordinate is less than 0 or
* greater than 256 or the x or z is outside the Minecraft worldmap.
*/
public IBlockState getBlockState() {
if (this.y < 0 || this.y >= 256 || this.x < -30000000 || this.z < -30000000 || this.x >= 30000000 || this.z >= 30000000) {
return null;
}
World world = getWorldForId(this.dim);
if (world == null)
return null;
int chunkx = this.x >> 4;
int chunkz = this.z >> 4;
try {
// this will be within the same chunk
if (BlockVec3Dim.chunkCacheX == chunkx && BlockVec3Dim.chunkCacheZ == chunkz && BlockVec3Dim.chunkCacheDim == world.provider.getDimension() && BlockVec3Dim.chunkCached.isLoaded()) {
return BlockVec3Dim.chunkCached.getBlockState(this.x & 15, this.y, this.z & 15);
} else {
Chunk chunk = null;
chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
BlockVec3Dim.chunkCached = chunk;
BlockVec3Dim.chunkCacheDim = world.provider.getDimension();
BlockVec3Dim.chunkCacheX = chunkx;
BlockVec3Dim.chunkCacheZ = chunkz;
return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
}
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Oxygen Sealer thread: Exception getting block type in world");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Requested block coordinates");
crashreportcategory.addCrashSection("Location", CrashReportCategory.getCoordinateInfo(new BlockPos(this.x, this.y, this.z)));
throw new ReportedException(crashreport);
}
}
use of net.minecraft.crash.CrashReport in project Galacticraft by micdoodle8.
the class BlockVec3 method getBlockStateSafe_noChunkLoad.
/**
* Get block ID at the BlockVec3 coordinates without forcing a chunk load.
* Only call this 'safe' version if x and z coordinates are within the
* Minecraft world map (-30m to +30m)
*
* @param world
* @return the block ID, or null if the y-coordinate is less than 0 or
* greater than 256. Returns Blocks.BEDROCK if the coordinates being
* checked are in an unloaded chunk
*/
@Nullable
public IBlockState getBlockStateSafe_noChunkLoad(World world) {
if (this.y < 0 || this.y >= 256) {
return null;
}
int chunkx = this.x >> 4;
int chunkz = this.z >> 4;
try {
if (world.getChunkProvider().getLoadedChunk(chunkx, chunkz) != null) {
if (world.isRemote) {
if (BlockVec3.chunkCacheX_Client == chunkx && BlockVec3.chunkCacheZ_Client == chunkz && BlockVec3.chunkCacheDim_Client == world.provider.getDimension() && BlockVec3.chunkCached_Client.isLoaded()) {
return BlockVec3.chunkCached_Client.getBlockState(this.x & 15, this.y, this.z & 15);
} else {
final Chunk chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
BlockVec3.chunkCached_Client = chunk;
BlockVec3.chunkCacheDim_Client = world.provider.getDimension();
BlockVec3.chunkCacheX_Client = chunkx;
BlockVec3.chunkCacheZ_Client = chunkz;
return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
}
} else {
// this will be within the same chunk
if (BlockVec3.chunkCacheX == chunkx && BlockVec3.chunkCacheZ == chunkz && BlockVec3.chunkCacheDim == world.provider.getDimension() && BlockVec3.chunkCached.isLoaded()) {
return BlockVec3.chunkCached.getBlockState(this.x & 15, this.y, this.z & 15);
} else {
final Chunk chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
BlockVec3.chunkCached = chunk;
BlockVec3.chunkCacheDim = world.provider.getDimension();
BlockVec3.chunkCacheX = chunkx;
BlockVec3.chunkCacheZ = chunkz;
return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
}
}
}
// Chunk doesn't exist - meaning, it is not loaded
return Blocks.BEDROCK.getDefaultState();
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Oxygen Sealer thread: Exception getting block type in world");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Requested block coordinates");
crashreportcategory.addCrashSection("Location", CrashReportCategory.getCoordinateInfo(new BlockPos(this.x, this.y, this.z)));
throw new ReportedException(crashreport);
}
}
use of net.minecraft.crash.CrashReport in project Wizardry by TeamWizardry.
the class PotionPhase method entityMove.
@SubscribeEvent
public void entityMove(EntityMoveEvent event) {
if (!(event.entity instanceof EntityLivingBase))
return;
EntityLivingBase base = (EntityLivingBase) event.entity;
if (!base.isPotionActive(ModPotions.PHASE))
return;
// TODO: 10/6/18 fix your shit demoniaque
event.setCanceled(true);
// event.entity.noClip = true;
event.entity.fallDistance = 0;
event.entity.isAirBorne = true;
Entity entity = event.entity;
double x = event.x;
double y = event.y;
double z = event.z;
MoverType type = event.type;
entity.world.profiler.startSection("move");
double d10 = entity.posX;
double d11 = entity.posY;
double d1 = entity.posZ;
double d2 = x;
double d3 = y;
double d4 = z;
if ((type == MoverType.SELF || type == MoverType.PLAYER) && entity.onGround && entity.isSneaking() && entity instanceof EntityPlayer) {
for (; x != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), 0.0D)).isEmpty(); d2 = x) {
if (x >= 0.05D || x < -0.05D) {
if (x > 0.0D) {
x -= 0.05D;
} else {
x += 0.05D;
}
} else
x = 0.0D;
}
for (; z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(0.0D, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
if (z >= 0.05D || z < -0.05D) {
if (z > 0.0D) {
z -= 0.05D;
} else {
z += 0.05D;
}
} else
z = 0.0D;
}
for (; x != 0.0D && z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
if (x >= 0.05D || x < -0.05D) {
if (x > 0.0D) {
x -= 0.05D;
} else {
x += 0.05D;
}
} else
x = 0.0D;
d2 = x;
if (z >= 0.05D || z < -0.05D) {
if (z > 0.0D) {
z -= 0.05D;
} else {
z += 0.05D;
}
} else
y = 0.0D;
}
}
List<AxisAlignedBB> list1 = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, y, z));
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox();
if (y != 0.0D) {
int k = 0;
for (int l = list1.size(); k < l; ++k) {
double offsetY = list1.get(k).calculateYOffset(entity.getEntityBoundingBox(), y);
if (offsetY <= 0)
y = offsetY;
}
entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y + (y == 0 && entity.isSneaking() ? -0.1 : 0), 0.0D));
}
if (x != 0.0D)
entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(x, 0.0D, 0.0D));
if (z != 0.0D)
entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, 0.0D, z));
boolean flag = entity.onGround || d3 != y && d3 < 0.0D;
if (entity.stepHeight > 0.0F && flag && (d2 != x || d4 != z)) {
double d14 = x;
double d6 = y;
double d7 = z;
AxisAlignedBB axisalignedbb1 = entity.getEntityBoundingBox();
entity.setEntityBoundingBox(axisalignedbb);
y = (double) entity.stepHeight;
List<AxisAlignedBB> list = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(d2, y, d4));
AxisAlignedBB axisalignedbb2 = entity.getEntityBoundingBox();
AxisAlignedBB axisalignedbb3 = axisalignedbb2.offset(d2, 0.0D, d4);
double d8 = y;
int j1 = 0;
for (int k1 = list.size(); j1 < k1; ++j1) {
double offsetY = list1.get(j1).calculateYOffset(axisalignedbb3, y);
if (offsetY <= 0)
d8 = offsetY;
}
axisalignedbb2 = axisalignedbb2.offset(0.0D, d8, 0.0D);
axisalignedbb2 = axisalignedbb2.offset(d2, 0.0D, 0.0D);
axisalignedbb2 = axisalignedbb2.offset(0.0D, 0.0D, d4);
AxisAlignedBB axisalignedbb4 = entity.getEntityBoundingBox();
double d20 = y;
int l2 = 0;
for (int i3 = list.size(); l2 < i3; ++l2) {
double offsetY = list1.get(i3).calculateYOffset(axisalignedbb4, y);
if (offsetY <= 0)
d20 = offsetY;
}
axisalignedbb4 = axisalignedbb4.offset(0.0D, d20, 0.0D);
axisalignedbb4 = axisalignedbb4.offset(d2, 0.0D, 0.0D);
axisalignedbb4 = axisalignedbb4.offset(0.0D, 0.0D, d4);
double d23 = d2 * d2 + d4 * d4;
double d9 = d2 * d2 + d4 * d4;
if (d23 > d9) {
x = d2;
z = d4;
y = -d8;
entity.setEntityBoundingBox(axisalignedbb2);
} else {
x = d2;
z = d4;
y = -d20;
entity.setEntityBoundingBox(axisalignedbb4);
}
int j4 = 0;
for (int k4 = list.size(); j4 < k4; ++j4) {
double offsetY = list1.get(j4).calculateYOffset(entity.getEntityBoundingBox(), y);
if (offsetY <= 0)
y = offsetY;
}
entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y, 0.0D));
if (d14 * d14 + d7 * d7 >= x * x + z * z) {
x = d14;
y = d6;
z = d7;
entity.setEntityBoundingBox(axisalignedbb1);
}
}
entity.world.profiler.endSection();
entity.world.profiler.startSection("rest");
entity.resetPositionToBB();
entity.collidedHorizontally = d2 != x || d4 != z;
entity.collidedVertically = d3 != y;
entity.onGround = entity.collidedVertically && d3 < 0.0D;
entity.collided = entity.collidedHorizontally || entity.collidedVertically;
int j6 = MathHelper.floor(entity.posX);
int i1 = MathHelper.floor(entity.posY - 0.20000000298023224D);
int k6 = MathHelper.floor(entity.posZ);
BlockPos blockpos = new BlockPos(j6, i1, k6);
IBlockState iblockstate = entity.world.getBlockState(blockpos);
if (iblockstate.getMaterial() == Material.AIR) {
BlockPos blockpos1 = blockpos.down();
IBlockState iblockstate1 = entity.world.getBlockState(blockpos1);
Block block1 = iblockstate1.getBlock();
if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate) {
iblockstate = iblockstate1;
blockpos = blockpos1;
}
}
Block block = iblockstate.getBlock();
if (d3 != y) {
block.onLanded(entity.world, entity);
}
if ((!entity.onGround || !entity.isSneaking() || !(entity instanceof EntityPlayer)) && !entity.isRiding()) {
double d15 = entity.posX - d10;
double d16 = entity.posY - d11;
double d17 = entity.posZ - d1;
if (block != Blocks.LADDER) {
d16 = 0.0D;
}
if (entity.onGround) {
block.onEntityWalk(entity.world, blockpos, entity);
}
entity.distanceWalkedModified = (float) ((double) entity.distanceWalkedModified + (double) MathHelper.sqrt(d15 * d15 + d17 * d17) * 0.6D);
entity.distanceWalkedOnStepModified = (float) ((double) entity.distanceWalkedOnStepModified + (double) MathHelper.sqrt(d15 * d15 + d16 * d16 + d17 * d17) * 0.6D);
}
try {
AxisAlignedBB bb = entity.getEntityBoundingBox();
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(bb.minX + 0.001D, bb.minY + 0.001D, bb.minZ + 0.001D);
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos1 = BlockPos.PooledMutableBlockPos.retain(bb.maxX - 0.001D, bb.maxY - 0.001D, bb.maxZ - 0.001D);
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos2 = BlockPos.PooledMutableBlockPos.retain();
if (entity.world.isAreaLoaded(blockpos$pooledmutableblockpos, blockpos$pooledmutableblockpos1)) {
for (int i = blockpos$pooledmutableblockpos.getX(); i <= blockpos$pooledmutableblockpos1.getX(); ++i) {
for (int j = blockpos$pooledmutableblockpos.getY(); j <= blockpos$pooledmutableblockpos1.getY(); ++j) {
for (int k = blockpos$pooledmutableblockpos.getZ(); k <= blockpos$pooledmutableblockpos1.getZ(); ++k) {
blockpos$pooledmutableblockpos2.setPos(i, j, k);
IBlockState state = entity.world.getBlockState(blockpos$pooledmutableblockpos2);
try {
state.getBlock().onEntityCollision(entity.world, blockpos$pooledmutableblockpos2, state, entity);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with");
CrashReportCategory.addBlockInfo(crashreportcategory, blockpos$pooledmutableblockpos2, state);
throw new ReportedException(crashreport);
}
}
}
}
}
blockpos$pooledmutableblockpos.release();
blockpos$pooledmutableblockpos1.release();
blockpos$pooledmutableblockpos2.release();
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision");
entity.addEntityCrashInfo(crashreportcategory);
throw new ReportedException(crashreport);
}
entity.world.profiler.endSection();
// event.entity.noClip = false;
}
use of net.minecraft.crash.CrashReport in project MinecraftForge by MinecraftForge.
the class SplashProgress method start.
public static void start() {
File configFile = new File(Minecraft.getMinecraft().mcDataDir, "config/splash.properties");
File parent = configFile.getParentFile();
if (!parent.exists())
parent.mkdirs();
FileReader r = null;
config = new Properties();
try {
r = new FileReader(configFile);
config.load(r);
} catch (IOException e) {
FMLLog.info("Could not load splash.properties, will create a default one");
} finally {
IOUtils.closeQuietly(r);
}
//Some system do not support this and have weird effects so we need to detect and disable by default.
//The user can always force enable it if they want to take the responsibility for bugs.
//For now macs derp so disable them.
boolean defaultEnabled = !System.getProperty("os.name").toLowerCase().contains("mac");
// Enable if we have the flag, and there's either no optifine, or optifine has added a key to the blackboard ("optifine.ForgeSplashCompatible")
// Optifine authors - add this key to the blackboard if you feel your modifications are now compatible with this code.
enabled = getBool("enabled", defaultEnabled) && ((!FMLClientHandler.instance().hasOptifine()) || Launch.blackboard.containsKey("optifine.ForgeSplashCompatible"));
rotate = getBool("rotate", false);
showMemory = getBool("showMemory", true);
logoOffset = getInt("logoOffset", 0);
backgroundColor = getHex("background", 0xFFFFFF);
fontColor = getHex("font", 0x000000);
barBorderColor = getHex("barBorder", 0xC0C0C0);
barColor = getHex("bar", 0xCB3D35);
barBackgroundColor = getHex("barBackground", 0xFFFFFF);
memoryGoodColor = getHex("memoryGood", 0x78CB34);
memoryWarnColor = getHex("memoryWarn", 0xE6E84A);
memoryLowColor = getHex("memoryLow", 0xE42F2F);
final ResourceLocation fontLoc = new ResourceLocation(getString("fontTexture", "textures/font/ascii.png"));
final ResourceLocation logoLoc = new ResourceLocation(getString("logoTexture", "textures/gui/title/mojang.png"));
final ResourceLocation forgeLoc = new ResourceLocation(getString("forgeTexture", "fml:textures/gui/forge.png"));
final ResourceLocation forgeFallbackLoc = new ResourceLocation("fml:textures/gui/forge.png");
File miscPackFile = new File(Minecraft.getMinecraft().mcDataDir, getString("resourcePackPath", "resources"));
FileWriter w = null;
try {
w = new FileWriter(configFile);
config.store(w, "Splash screen properties");
} catch (IOException e) {
FMLLog.log(Level.ERROR, e, "Could not save the splash.properties file");
} finally {
IOUtils.closeQuietly(w);
}
miscPack = createResourcePack(miscPackFile);
if (!enabled)
return;
// getting debug info out of the way, while we still can
FMLCommonHandler.instance().registerCrashCallable(new ICrashCallable() {
public String call() throws Exception {
return "' Vendor: '" + glGetString(GL_VENDOR) + "' Version: '" + glGetString(GL_VERSION) + "' Renderer: '" + glGetString(GL_RENDERER) + "'";
}
public String getLabel() {
return "GL info";
}
});
CrashReport report = CrashReport.makeCrashReport(new Throwable() {
@Override
public String getMessage() {
return "This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR";
}
@Override
public void printStackTrace(final PrintWriter s) {
s.println(getMessage());
}
@Override
public void printStackTrace(final PrintStream s) {
s.println(getMessage());
}
}, "Loading screen debug info");
System.out.println(report.getCompleteReport());
try {
d = new SharedDrawable(Display.getDrawable());
Display.getDrawable().releaseContext();
d.makeCurrent();
} catch (LWJGLException e) {
e.printStackTrace();
disableSplash(e);
}
//Call this ASAP if splash is enabled so that threading doesn't cause issues later
getMaxTextureSize();
//Thread mainThread = Thread.currentThread();
thread = new Thread(new Runnable() {
private final int barWidth = 400;
private final int barHeight = 20;
private final int textHeight2 = 20;
private final int barOffset = 55;
public void run() {
setGL();
fontTexture = new Texture(fontLoc, null);
logoTexture = new Texture(logoLoc, null, false);
forgeTexture = new Texture(forgeLoc, forgeFallbackLoc);
glEnable(GL_TEXTURE_2D);
fontRenderer = new SplashFontRenderer();
glDisable(GL_TEXTURE_2D);
while (!done) {
ProgressBar first = null, penult = null, last = null;
Iterator<ProgressBar> i = ProgressManager.barIterator();
while (i.hasNext()) {
if (first == null)
first = i.next();
else {
penult = last;
last = i.next();
}
}
glClear(GL_COLOR_BUFFER_BIT);
// matrix setup
int w = Display.getWidth();
int h = Display.getHeight();
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(320 - w / 2, 320 + w / 2, 240 + h / 2, 240 - h / 2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// mojang logo
setColor(backgroundColor);
glEnable(GL_TEXTURE_2D);
logoTexture.bind();
glBegin(GL_QUADS);
logoTexture.texCoord(0, 0, 0);
glVertex2f(320 - 256, 240 - 256);
logoTexture.texCoord(0, 0, 1);
glVertex2f(320 - 256, 240 + 256);
logoTexture.texCoord(0, 1, 1);
glVertex2f(320 + 256, 240 + 256);
logoTexture.texCoord(0, 1, 0);
glVertex2f(320 + 256, 240 - 256);
glEnd();
glDisable(GL_TEXTURE_2D);
// memory usage
if (showMemory) {
glPushMatrix();
glTranslatef(320 - (float) barWidth / 2, 20, 0);
drawMemoryBar();
glPopMatrix();
}
// bars
if (first != null) {
glPushMatrix();
glTranslatef(320 - (float) barWidth / 2, 310, 0);
drawBar(first);
if (penult != null) {
glTranslatef(0, barOffset, 0);
drawBar(penult);
}
if (last != null) {
glTranslatef(0, barOffset, 0);
drawBar(last);
}
glPopMatrix();
}
angle += 1;
// forge logo
setColor(backgroundColor);
float fw = (float) forgeTexture.getWidth() / 2;
float fh = (float) forgeTexture.getHeight() / 2;
if (rotate) {
float sh = Math.max(fw, fh);
glTranslatef(320 + w / 2 - sh - logoOffset, 240 + h / 2 - sh - logoOffset, 0);
glRotatef(angle, 0, 0, 1);
} else {
glTranslatef(320 + w / 2 - fw - logoOffset, 240 + h / 2 - fh - logoOffset, 0);
}
int f = (angle / 5) % forgeTexture.getFrames();
glEnable(GL_TEXTURE_2D);
forgeTexture.bind();
glBegin(GL_QUADS);
forgeTexture.texCoord(f, 0, 0);
glVertex2f(-fw, -fh);
forgeTexture.texCoord(f, 0, 1);
glVertex2f(-fw, fh);
forgeTexture.texCoord(f, 1, 1);
glVertex2f(fw, fh);
forgeTexture.texCoord(f, 1, 0);
glVertex2f(fw, -fh);
glEnd();
glDisable(GL_TEXTURE_2D);
// We use mutex to indicate safely to the main thread that we're taking the display global lock
// So the main thread can skip processing messages while we're updating.
// There are system setups where this call can pause for a while, because the GL implementation
// is trying to impose a framerate or other thing is occurring. Without the mutex, the main
// thread would delay waiting for the same global display lock
mutex.acquireUninterruptibly();
Display.update();
// As soon as we're done, we release the mutex. The other thread can now ping the processmessages
// call as often as it wants until we get get back here again
mutex.release();
if (pause) {
clearGL();
setGL();
}
Display.sync(100);
}
clearGL();
}
private void setColor(int color) {
glColor3ub((byte) ((color >> 16) & 0xFF), (byte) ((color >> 8) & 0xFF), (byte) (color & 0xFF));
}
private void drawBox(int w, int h) {
glBegin(GL_QUADS);
glVertex2f(0, 0);
glVertex2f(0, h);
glVertex2f(w, h);
glVertex2f(w, 0);
glEnd();
}
private void drawBar(ProgressBar b) {
glPushMatrix();
// title - message
setColor(fontColor);
glScalef(2, 2, 1);
glEnable(GL_TEXTURE_2D);
fontRenderer.drawString(b.getTitle() + " - " + b.getMessage(), 0, 0, 0x000000);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
// border
glPushMatrix();
glTranslatef(0, textHeight2, 0);
setColor(barBorderColor);
drawBox(barWidth, barHeight);
// interior
setColor(barBackgroundColor);
glTranslatef(1, 1, 0);
drawBox(barWidth - 2, barHeight - 2);
// slidy part
setColor(barColor);
// Step can sometimes be 0.
drawBox((barWidth - 2) * (b.getStep() + 1) / (b.getSteps() + 1), barHeight - 2);
// progress text
String progress = "" + b.getStep() + "/" + b.getSteps();
glTranslatef(((float) barWidth - 2) / 2 - fontRenderer.getStringWidth(progress), 2, 0);
setColor(fontColor);
glScalef(2, 2, 1);
glEnable(GL_TEXTURE_2D);
fontRenderer.drawString(progress, 0, 0, 0x000000);
glPopMatrix();
}
private void drawMemoryBar() {
int maxMemory = bytesToMb(Runtime.getRuntime().maxMemory());
int totalMemory = bytesToMb(Runtime.getRuntime().totalMemory());
int freeMemory = bytesToMb(Runtime.getRuntime().freeMemory());
int usedMemory = totalMemory - freeMemory;
float usedMemoryPercent = usedMemory / (float) maxMemory;
glPushMatrix();
// title - message
setColor(fontColor);
glScalef(2, 2, 1);
glEnable(GL_TEXTURE_2D);
fontRenderer.drawString("Memory Used / Total", 0, 0, 0x000000);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
// border
glPushMatrix();
glTranslatef(0, textHeight2, 0);
setColor(barBorderColor);
drawBox(barWidth, barHeight);
// interior
setColor(barBackgroundColor);
glTranslatef(1, 1, 0);
drawBox(barWidth - 2, barHeight - 2);
// slidy part
long time = System.currentTimeMillis();
if (usedMemoryPercent > memoryColorPercent || (time - memoryColorChangeTime > 1000)) {
memoryColorChangeTime = time;
memoryColorPercent = usedMemoryPercent;
}
int memoryBarColor;
if (memoryColorPercent < 0.75f) {
memoryBarColor = memoryGoodColor;
} else if (memoryColorPercent < 0.85f) {
memoryBarColor = memoryWarnColor;
} else {
memoryBarColor = memoryLowColor;
}
setColor(memoryLowColor);
glPushMatrix();
glTranslatef((barWidth - 2) * (totalMemory) / (maxMemory) - 2, 0, 0);
drawBox(2, barHeight - 2);
glPopMatrix();
setColor(memoryBarColor);
drawBox((barWidth - 2) * (usedMemory) / (maxMemory), barHeight - 2);
// progress text
String progress = getMemoryString(usedMemory) + " / " + getMemoryString(maxMemory);
glTranslatef(((float) barWidth - 2) / 2 - fontRenderer.getStringWidth(progress), 2, 0);
setColor(fontColor);
glScalef(2, 2, 1);
glEnable(GL_TEXTURE_2D);
fontRenderer.drawString(progress, 0, 0, 0x000000);
glPopMatrix();
}
private String getMemoryString(int memory) {
return StringUtils.leftPad(Integer.toString(memory), 4, ' ') + " MB";
}
private void setGL() {
lock.lock();
try {
Display.getDrawable().makeCurrent();
} catch (LWJGLException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
glClearColor((float) ((backgroundColor >> 16) & 0xFF) / 0xFF, (float) ((backgroundColor >> 8) & 0xFF) / 0xFF, (float) (backgroundColor & 0xFF) / 0xFF, 1);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
private void clearGL() {
Minecraft mc = Minecraft.getMinecraft();
mc.displayWidth = Display.getWidth();
mc.displayHeight = Display.getHeight();
mc.resize(mc.displayWidth, mc.displayHeight);
glClearColor(1, 1, 1, 1);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, .1f);
try {
Display.getDrawable().releaseContext();
} catch (LWJGLException e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
lock.unlock();
}
}
});
thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
FMLLog.log(Level.ERROR, e, "Splash thread Exception");
threadError = e;
}
});
thread.start();
checkThreadState();
}
Aggregations