Skip to content

Commit

Permalink
Added better mappings, faster beacon beam rendering, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Guichaguri committed Oct 30, 2016
1 parent 590a04c commit 2452f85
Show file tree
Hide file tree
Showing 22 changed files with 531 additions and 312 deletions.
68 changes: 63 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,30 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}

apply plugin: 'net.minecraftforge.gradle.tweaker-client'

version = "1.3.0"
version = "1.3.3"
group = "guichaguri.betterfps"
archivesBaseName = "BetterFps"

minecraft {
version = "1.9.4"
version = "1.10.2"
runDir = "run"
tweakClass = "guichaguri.betterfps.tweaker.BetterFpsTweaker";
mappings = "snapshot_20160518"

at 'betterfps_at.cfg'
}

sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = "1.6"
}

jar {
manifest {
attributes 'TweakClass': project.minecraft.tweakClass,
Expand All @@ -47,6 +52,7 @@ jar {
dependencies {
//compile 'org.ow2.asm:asm-debug-all:5.0.3'
//compile 'net.minecraft:launchwrapper:1.12'
testCompile 'junit:junit:4.12'
}

processResources {
Expand All @@ -61,11 +67,63 @@ processResources {
expand 'version': project.version
}

// copy everything else, thats not the json
// copy everything else, except the json
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/betterfps.json'
}
}

String srgInput = 'mappings.srg'
String srgOutput = 'src/main/resources/betterfps.srg'

runClient.args "--username", "BetterFps"
/**
* Task created by Guichaguri to update the requested mappings of a SRG file
* You might have to update the input file when the mappings version change.
*/
task updateMappings(dependsOn: 'genSrgs') {
def classes = [:];
def fields = [:];
def methods = [:];
def i = 0;

println 'Searching mappings to update'
String[] reqMapping = file(srgInput).readLines()
reqMapping.each {
String[] mapping = it.split(' ')
if(it.startsWith('#')) {
// Comment
} else if(mapping[0].equals('CL:')) { // Class
if(mapping.length >= 2) classes.put(mapping[2], mapping[1]);
} else if(mapping[0].equals('FD:')) { // Field
if(mapping.length >= 2) fields.put(mapping[2], mapping[1]);
} else if(mapping[0].equals('MD:')) { // Method
if(mapping.length >= 3) methods.put(mapping[2] + mapping[3], mapping[1]);
}
}
println 'Updating mappings'
file(srgOutput).withWriter { out ->
String[] mappings = tasks['genSrgs'].getNotchToMcp().readLines()
mappings.each {
String[] mapping = it.split(' ')
if (mapping[0].equals('CL:')) { // Class
if(mapping.length >= 3 && classes.containsKey(mapping[2])) {
out.println it + ' ' + classes.get(mapping[2])
i++
}
} else if(mapping[0].equals('FD:')) { // Field
if(mapping.length >= 3 && fields.containsKey(mapping[2])) {
out.println it + ' ' + fields.get(mapping[2])
i++
}
} else if(mapping[0].equals('MD:')) { // Method
if(mapping.length >= 5 && methods.containsKey(mapping[3] + mapping[4])) {
out.println it + ' ' + methods.get(mapping[3] + mapping[4])
i++
}
}
}
def entries = classes.size() + fields.size() + methods.size();
println 'Done. Updated ' + i + '/' + entries + ' entries'
if(i < entries) println 'WARNING: ' + (entries - i) + ' entries were not found! You should check them'
}
}
41 changes: 41 additions & 0 deletions mappings.srg
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# The names will be obfuscated and written in resources/betterfps.srg by my gradle task automatically
# Prefixes: CL for classes, FD for fields and MD for methods
# Make sure all names are correct for the current version before compiling

# PREFIX: IDENTIFIER NAME [DESC]

CL: Minecraft net/minecraft/client/Minecraft
CL: World net/minecraft/world/World
CL: Chunk net/minecraft/world/chunk/Chunk
CL: EntityPlayer net/minecraft/entity/player/EntityPlayer
CL: MathHelper net/minecraft/util/math/MathHelper
CL: EntityTNTPrimed net/minecraft/entity/item/EntityTNTPrimed
CL: ClientBrandRetriever net/minecraft/client/ClientBrandRetriever
CL: GuiOptions net/minecraft/client/gui/GuiOptions
CL: WorldClient net/minecraft/client/multiplayer/WorldClient
CL: WorldServer net/minecraft/world/WorldServer
CL: IntegratedServer net/minecraft/server/integrated/IntegratedServer
CL: DedicatedServer net/minecraft/server/dedicated/DedicatedServer
CL: TileEntityBeacon net/minecraft/tileentity/TileEntityBeacon
CL: BeamSegment net/minecraft/tileentity/TileEntityBeacon$BeamSegment
CL: TileEntityBeaconRenderer net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer
CL: TileEntityHopper net/minecraft/tileentity/TileEntityHopper
CL: BlockHopper net/minecraft/block/BlockHopper
CL: ModelBox net/minecraft/client/model/ModelBox
CL: EntityRenderer net/minecraft/client/renderer/EntityRenderer

MD: startGame net/minecraft/client/Minecraft/startGame ()V
MD: freeMemory net/minecraft/client/Minecraft/freeMemory ()V
MD: sin net/minecraft/util/math/MathHelper/sin (F)F
MD: cos net/minecraft/util/math/MathHelper/cos (F)F
MD: tick net/minecraft/world/World/tick ()V
MD: updateBlocks net/minecraft/world/World/updateBlocks ()V
MD: onUpdate net/minecraft/entity/Entity/onUpdate ()V
MD: getClientModName net/minecraft/client/ClientBrandRetriever/getClientModName ()Ljava/lang/String;
MD: initGui net/minecraft/client/gui/GuiScreen/initGui ()V
MD: startServer net/minecraft/server/MinecraftServer/startServer ()Z
MD: captureDroppedItems net/minecraft/tileentity/TileEntityHopper/captureDroppedItems (Lnet/minecraft/tileentity/IHopper;)Z
MD: renderBeamSegment net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer/renderBeamSegment (DDDDDDII[FDD)V

FD: memoryReserve net/minecraft/client/Minecraft/memoryReserve [B
FD: SIN_TABLE net/minecraft/util/math/MathHelper/SIN_TABLE [F
10 changes: 5 additions & 5 deletions src/main/java/guichaguri/betterfps/ASMUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package guichaguri.betterfps;

import guichaguri.betterfps.tweaker.Naming;
import guichaguri.betterfps.tweaker.Mappings;
import java.util.List;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
Expand All @@ -25,16 +25,16 @@ public static byte[] writeClass(ClassNode node, int flags) {
return writer.toByteArray();
}

public static MethodNode findMethod(ClassNode node, Naming naming) {
public static MethodNode findMethod(ClassNode node, Mappings mappings) {
for(MethodNode m : node.methods) {
if(naming.is(m.name, m.desc)) return m;
if(mappings.is(m.name, m.desc)) return m;
}
return null;
}

public static FieldNode findField(ClassNode node, Naming naming) {
public static FieldNode findField(ClassNode node, Mappings mappings) {
for(FieldNode m : node.fields) {
if(naming.is(m.name, m.desc)) return m;
if(mappings.is(m.name, m.desc)) return m;
}
return null;
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/guichaguri/betterfps/BetterFps.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package guichaguri.betterfps;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* Common event handling
* @author Guilherme Chaguri
*/
public class BetterFps {
public static final Logger log = LogManager.getLogger("BetterFps");

public static boolean isClient = false;

Expand Down
15 changes: 0 additions & 15 deletions src/main/java/guichaguri/betterfps/BetterFpsClient.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package guichaguri.betterfps;

import guichaguri.betterfps.gui.GuiBetterFpsConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import org.lwjgl.input.Keyboard;

/**
* Client event handling
* @author Guilherme Chaguri
*/
public class BetterFpsClient {
protected static Minecraft mc;
private static KeyBinding MENU_KEY = new KeyBinding("BetterFps", Keyboard.KEY_F12, "key.categories.misc");

// Called in Minecraft.startGame
public static void start(Minecraft minecraft) {
Expand All @@ -23,10 +19,6 @@ public static void start(Minecraft minecraft) {
}
BetterFpsHelper.init();

// TODO unused. remove it
//mc.gameSettings.keyBindings = ArrayUtils.add(mc.gameSettings.keyBindings, MENU_KEY);
//mc.gameSettings.loadOptions();

UpdateChecker.check();
}

Expand All @@ -35,11 +27,4 @@ public static void worldLoad() {
UpdateChecker.showChat();
}

// Called at the end of KeyBinding.onTick
public static void keyEvent(int key) {//TODO unused. remove it
if(MENU_KEY.getKeyCode() == key) {
mc.displayGuiScreen(new GuiBetterFpsConfig(mc.currentScreen));
}
}

}
2 changes: 2 additions & 0 deletions src/main/java/guichaguri/betterfps/BetterFpsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ public static Object getValue(String key) {

public boolean fastBeacon = true;

public boolean fastBeaconRender = false;

}
8 changes: 6 additions & 2 deletions src/main/java/guichaguri/betterfps/BetterFpsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
import java.util.LinkedHashMap;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* @author Guilherme Chaguri
*/
public class BetterFpsHelper {

public static final String MC_VERSION = "1.9";
public static final String VERSION = "1.2.1";
public static final String MC_VERSION = "1.10.2";
public static final String VERSION = "1.3.3";

public static final String URL = "http://guichaguri.github.io/BetterFps/";

public static final String UPDATE_URL = "http://widget.mcf.li/mc-mods/minecraft/229876-betterfps.json";

public static final Logger LOG = LogManager.getLogger("BetterFps");

// Config Name, Class Name
public static final LinkedHashMap<String, String> helpers = new LinkedHashMap<String, String>();

Expand Down
29 changes: 16 additions & 13 deletions src/main/java/guichaguri/betterfps/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
Expand Down Expand Up @@ -32,12 +31,17 @@ public static void check() {
}
if(!updateCheck) {
updateCheck = true;
Thread thread = new Thread(new UpdateChecker(), "BetterFps Update Checker");
thread.setDaemon(true);
thread.start();
checkForced();
}
}

public static void checkForced() {
done = false;
Thread thread = new Thread(new UpdateChecker(), "BetterFps Update Checker");
thread.setDaemon(true);
thread.start();
}

public static void showChat() {
if(!done) return;
if(updateVersion == null && updateDownload == null) return;
Expand Down Expand Up @@ -76,10 +80,10 @@ public static void showConsole() {
if(!done) return;
if(updateVersion == null && updateDownload == null) return;

BetterFps.log.info("BetterFps " + updateVersion + " is available");
BetterFps.log.info(getRandomPhrase());
BetterFps.log.info("Download: " + updateDownload);
BetterFps.log.info("More: " + BetterFpsHelper.URL);
BetterFpsHelper.LOG.info("BetterFps " + updateVersion + " is available");
BetterFpsHelper.LOG.info(getRandomPhrase());
BetterFpsHelper.LOG.info("Download: " + updateDownload);
BetterFpsHelper.LOG.info("More: " + BetterFpsHelper.URL);

updateVersion = null;
updateDownload = null;
Expand All @@ -97,6 +101,7 @@ private static TextComponentString createButton(String label, String link, Strin
}

private static String getRandomPhrase() {
// Thanks to Kevin8082 for some of this phrases
String[] phrases = new String[]{
"Just another annoying update.",
"Babe are you a new update? Because not now.",
Expand All @@ -105,9 +110,9 @@ private static String getRandomPhrase() {
"Not again D:",
"<3",
"You will probably update just to get rid of this reminder",
"HARD WARE FAILURE! HARD WARE FAILURE! No wait, I derped out.",
"HARDWARE FAILURE! HARDWARE FAILURE! No wait, I derped out.",
"Less annoying than Windows Updater... I think",
"Rope is cut, loot is mine, 90 second timer, and the entire server is after me now, great...",
"Rope is cut, update is out, and the entire server is after me now, great...",
"It's free. Go get it ;)",
"Some bugs are now fixed, but new ones have been introduced",
"It will not update automagically, you know...",
Expand Down Expand Up @@ -147,10 +152,8 @@ public void run() {
showChat();
}
}
} catch(IOException ex) {
BetterFps.log.warn("Could not check for updates: " + ex.getLocalizedMessage());
} catch(Exception ex) {
ex.printStackTrace();
BetterFpsHelper.LOG.warn("Could not check for updates: " + ex.getMessage());
} finally {
done = true;
}
Expand Down
Loading

0 comments on commit 2452f85

Please sign in to comment.