Skip to content

Commit

Permalink
Update to stable_39 mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Runemoro committed Aug 24, 2018
1 parent afee62b commit 1c84a50
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 94 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ targetCompatibility = 1.8
minecraft {
version "1.12.2-14.23.4.2703"
runDir "run"
mappings "snapshot_20180607"
mappings "stable_39"
makeObfSourceJar false

def args = [
Expand Down
36 changes: 0 additions & 36 deletions src/main/java/org/dimdev/vanillafix/VanillaFix.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package org.dimdev.vanillafix;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.crash.CrashReport;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistry;
import org.apache.logging.log4j.Logger;

import java.io.File;
Expand All @@ -30,8 +22,6 @@
updateJSON = "https://gist.githubusercontent.com/Runemoro/28e8cf4c24a5f17f508a5d34f66d229f/raw/vanillafix_update.json")
public class VanillaFix {
private static final int CONFIG_VERSION = 1;
private static final boolean DEBUG_BLOCK_IDS = false;
private static final boolean DEBUG_ITEM_IDS = false;
private static final boolean DEBUG_INIT_ERROR = false; // For testing the init error screen outside of dev. Don't forget to unset!

@Mod.EventHandler
Expand Down Expand Up @@ -77,32 +67,6 @@ public void onPreInit(FMLPreInitializationEvent event) {
// Don't render terrain on main thread for higher FPS, but possibly seeing missing chunks
ForgeModContainer.alwaysSetupTerrainOffThread = true;

IForgeRegistry<Block> blockRegistry = GameRegistry.findRegistry(Block.class);
IForgeRegistry<Item> itemRegistry = GameRegistry.findRegistry(Item.class);

if (DEBUG_BLOCK_IDS) {
for (int i = 0; i < 5000; i++) {
Block block = new Block(Material.GROUND)
.setCreativeTab(CreativeTabs.BUILDING_BLOCKS)
.setUnlocalizedName("block_" + i)
.setRegistryName(new ResourceLocation("vanillafix:block_" + i));

blockRegistry.register(block);
itemRegistry.register(new ItemBlock(block).setRegistryName(new ResourceLocation("vanillafix:block_" + i)));
}
}

if (DEBUG_ITEM_IDS) {
for (int i = 0; i < 40000; i++) {
Item item = new Item()
.setCreativeTab(CreativeTabs.FOOD)
.setUnlocalizedName("item_" + i)
.setRegistryName(new ResourceLocation("vanillafix:item_" + i));

itemRegistry.register(item);
}
}

if (DEBUG_INIT_ERROR) throw new ReportedException(new CrashReport("Debug init crash", new Throwable()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
@IFMLLoadingPlugin.SortingIndex(Integer.MIN_VALUE + 10000)
public class VanillaFixLoadingPlugin implements IFMLLoadingPlugin {
private static final Logger log = LogManager.getLogger();
private static final String MCP_VERSION = "20180618-1.12"; // TODO: Use version for current Minecraft version!
private static boolean initialized = false;

public static LoadingConfig config;
Expand Down Expand Up @@ -124,13 +123,13 @@ public static void initialize() {
// Initialize StacktraceDeobfuscator
log.info("Initializing StacktraceDeobfuscator");
try {
File mappings = new File(modDir, "methods-" + MCP_VERSION + ".csv");
File mappings = new File(modDir, "methods-stable_39.csv");
if (mappings.exists()) {
log.info("Found MCP method mappings: " + mappings.getName());
} else {
log.info("Downloading MCP method mappings to: " + mappings.getName());
}
StacktraceDeobfuscator.init(mappings, MCP_VERSION);
StacktraceDeobfuscator.init(mappings);
} catch (Exception e) {
log.error("Failed to get MCP data!", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ public int getStrongPower(IBlockAccess blockAccess, BlockPos pos, EnumFacing sid
}

@Override
public EnumPushReaction getMobilityFlag() {
return block.getMobilityFlag(this);
public EnumPushReaction getPushReaction() {
return block.getPushReaction(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ public int getStrongPower(IBlockAccess blockAccess, BlockPos pos, EnumFacing sid
}

@Override
public EnumPushReaction getMobilityFlag() {
return normalState.getMobilityFlag();
public EnumPushReaction getPushReaction() {
return normalState.getPushReaction();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Mixin(Minecraft.class)
public abstract class MixinMinecraft implements IThreadListener, ISnooperInfo {
@Shadow @Final private static Logger LOGGER;
@Shadow @Final public Profiler mcProfiler;
@Shadow @Final public Profiler profiler;

@Shadow public GuiIngame ingameGUI;

Expand All @@ -42,9 +42,9 @@ private void endStartGUISection(Profiler profiler, String name) {
/** @reason Part 2 of GUI logic fix. */
@Redirect(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureManager;tick()V", ordinal = 0))
private void tickTextureManagerWithCorrectProfiler(TextureManager textureManager) {
mcProfiler.endStartSection("textures");
profiler.endStartSection("textures");
textureManager.tick();
mcProfiler.endStartSection("gui");
profiler.endStartSection("gui");
}

/** @reason Make saving screenshots async (https://bugs.mojang.com/browse/MC-33383) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void handleRespawn(SPacketRespawn packetIn) {
client.displayGuiScreen(null);

Scoreboard scoreboard = world.getScoreboard();
world = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, client.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), client.mcProfiler);
world = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, client.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), client.profiler);
world.setWorldScoreboard(scoreboard);
client.loadWorld(world);
client.player.dimension = packetIn.getDimensionID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void outputReport(CrashReport report) {
reportName += Minecraft.getMinecraft().isCallingFromMinecraftThread() ? "-client" : "-server";
reportName += ".txt";

File reportsDir = isClient() ? new File(Minecraft.getMinecraft().mcDataDir, "crash-reports") : new File("crash-reports");
File reportsDir = isClient() ? new File(Minecraft.getMinecraft().gameDir, "crash-reports") : new File("crash-reports");
File reportFile = new File(reportsDir, reportName);

report.saveToFile(reportFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public final class StacktraceDeobfuscator {
* If the file does not exits, downloads latest method mappings and saves them to it.
* Initializes a HashMap between obfuscated and deobfuscated names from that file.
*/
public static void init(File mappings, String version) {
public static void init(File mappings) {
if (srgMcpMethodMap != null) return;

// Download the file if necessary
if (!mappings.exists()) {
HttpURLConnection connection = null;
try {
URL mappingsURL = new URL("http://export.mcpbot.bspk.rs/mcp_snapshot_nodoc/" + version + "/mcp_snapshot_nodoc-" + version + ".zip");
URL mappingsURL = new URL("http://export.mcpbot.bspk.rs/mcp_stable_nodoc/39-1.12/mcp_stable_nodoc-39-1.12.zip");
connection = (HttpURLConnection) mappingsURL.openConnection();
connection.setDoInput(true);
connection.connect();
Expand Down Expand Up @@ -110,7 +110,7 @@ public static String deobfuscateMethodName(String srgName) {
}

public static void main(String[] args) {
init(new File("methods.csv"), "20180519-1.12");
init(new File("methods.csv"));
for (Map.Entry<String, String> entry : srgMcpMethodMap.entrySet()) {
System.out.println(entry.getKey() + " <=> " + entry.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public abstract class MixinMinecraft implements IThreadListener, ISnooperInfo, I
@Shadow public TextureManager renderEngine;
@Shadow public FontRenderer fontRenderer;
@Shadow private int leftClickCounter;
@Shadow private Framebuffer framebufferMc;
@Shadow private IReloadableResourceManager mcResourceManager;
@Shadow private SoundHandler mcSoundHandler;
@Shadow private Framebuffer framebuffer;
@Shadow private IReloadableResourceManager resourceManager;
@Shadow private SoundHandler soundHandler;
@Shadow @Final private List<IResourcePack> defaultResourcePacks;
@Shadow private LanguageManager mcLanguageManager;
@Shadow @Final private MetadataSerializer metadataSerializer_;
@Shadow private LanguageManager languageManager;
@Shadow @Final private MetadataSerializer metadataSerializer;

@Shadow @SuppressWarnings("RedundantThrows") private void init() throws LWJGLException, IOException {}
@Shadow @SuppressWarnings("RedundantThrows") private void runGameLoop() throws IOException {}
Expand Down Expand Up @@ -178,19 +178,19 @@ public void displayInitErrorScreen(CrashReport report) {
LOGGER.error("Failed to load VanillaFix resource pack", t);
}

mcResourceManager = new SimpleReloadableResourceManager(metadataSerializer_);
renderEngine = new TextureManager(mcResourceManager);
mcResourceManager.registerReloadListener(renderEngine);
resourceManager = new SimpleReloadableResourceManager(metadataSerializer);
renderEngine = new TextureManager(resourceManager);
resourceManager.registerReloadListener(renderEngine);

mcLanguageManager = new LanguageManager(metadataSerializer_, gameSettings.language);
mcResourceManager.registerReloadListener(mcLanguageManager);
languageManager = new LanguageManager(metadataSerializer, gameSettings.language);
resourceManager.registerReloadListener(languageManager);

refreshResources(); // TODO: Why is this necessary?
fontRenderer = new FontRenderer(gameSettings, new ResourceLocation("textures/font/ascii.png"), renderEngine, false);
mcResourceManager.registerReloadListener(fontRenderer);
resourceManager.registerReloadListener(fontRenderer);

mcSoundHandler = new SoundHandler(mcResourceManager, gameSettings);
mcResourceManager.registerReloadListener(mcSoundHandler);
soundHandler = new SoundHandler(resourceManager, gameSettings);
resourceManager.registerReloadListener(soundHandler);

running = true;
try {
Expand All @@ -215,7 +215,7 @@ private void runGUILoop(GuiScreen screen) throws IOException {

GlStateManager.pushMatrix();
GlStateManager.clear(16640);
framebufferMc.bindFramebuffer(true);
framebuffer.bindFramebuffer(true);
GlStateManager.enableTexture2D();

GlStateManager.viewport(0, 0, displayWidth, displayHeight);
Expand All @@ -237,11 +237,11 @@ private void runGUILoop(GuiScreen screen) throws IOException {
int mouseY = height - Mouse.getY() * height / displayHeight - 1;
currentScreen.drawScreen(mouseX, mouseY, 0);

framebufferMc.unbindFramebuffer();
framebuffer.unbindFramebuffer();
GlStateManager.popMatrix();

GlStateManager.pushMatrix();
framebufferMc.framebufferRender(displayWidth, displayHeight);
framebuffer.framebufferRender(displayWidth, displayHeight);
GlStateManager.popMatrix();

updateDisplay();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ protected TextureAtlasSprite loadSprite(String iconName) {
}

public void update() {
Minecraft.getMinecraft().mcProfiler.startSection("updateTextureMap");
Minecraft.getMinecraft().profiler.startSection("updateTextureMap");

if (atlasNeedsExpansion) {
atlasNeedsExpansion = false;

Minecraft.getMinecraft().mcProfiler.startSection("expandAtlas");
Minecraft.getMinecraft().profiler.startSection("expandAtlas");
LOGGER.info("Expanding texture atlas to {}x{}", stitcher.getCurrentWidth(), stitcher.getCurrentHeight());

TextureUtil.allocateTextureImpl(getGlTextureId(), mipmapLevels, stitcher.getCurrentWidth(), stitcher.getCurrentHeight());
Expand All @@ -151,17 +151,17 @@ public void update() {
TextureUtil.uploadTextureMipmap(loadedSprite.getFrameTextureData(0), loadedSprite.getIconWidth(), loadedSprite.getIconHeight(), loadedSprite.getOriginX(), loadedSprite.getOriginY(), false, false);
}

Minecraft.getMinecraft().mcProfiler.endSection();
Minecraft.getMinecraft().profiler.endSection();
}

Minecraft.getMinecraft().mcProfiler.startSection("uploadTexture");
Minecraft.getMinecraft().profiler.startSection("uploadTexture");
GlStateManager.bindTexture(getGlTextureId());
for (TextureAtlasSprite sprite : spritesNeedingUpload) {
spritesNeedingUpload.remove(sprite);
TextureUtil.uploadTextureMipmap(sprite.getFrameTextureData(0), sprite.getIconWidth(), sprite.getIconHeight(), sprite.getOriginX(), sprite.getOriginY(), false, false);
}
Minecraft.getMinecraft().mcProfiler.endSection();
Minecraft.getMinecraft().profiler.endSection();

Minecraft.getMinecraft().mcProfiler.endSection();
Minecraft.getMinecraft().profiler.endSection();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MixinModelBlockAnimation {
* @reason This is missing for almost all models, causing an IOException to be
* thrown, which makes model loading very slow. Instead, use getAllResources.
* <p>
* See <a href="https://github.com/MinecraftForge/MinecraftForge/issues/5048">https://github.com/MinecraftForge/MinecraftForge/issues/5048</a>
* See <a href="https://github.com/MinecraftForge/MincraftForge/issues/5048">https://github.com/MinecraftForge/MinecraftForge/issues/5048</a>
* <p>
* TODO: Optimize this, or disable this for certain forge versions once Forge fixes it
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class BuiltinLoader implements ICustomModelLoader {

@Override
public boolean accepts(ResourceLocation modelLocation) {
return modelLocation.getResourcePath().startsWith("builtin/");
return modelLocation.getPath().startsWith("builtin/");
}

@Override
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
String path = modelLocation.getResourcePath();
String path = modelLocation.getPath();

if ("builtin/generated".equals(path)) {
return new VanillaModelWrapper(modelLocation, MODEL_GENERATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static void addInventoryVariantLocation(ModelResourceLocation inventoryVa

public static ResourceLocation getItemLocation(String location) {
ResourceLocation resourcelocation = new ResourceLocation(location.replaceAll("#.*", ""));
return new ResourceLocation(resourcelocation.getResourceDomain(), "item/" + resourcelocation.getResourcePath());
return new ResourceLocation(resourcelocation.getNamespace(), "item/" + resourcelocation.getPath());
}

public static ModelResourceLocation getInventoryVariant(String variant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public boolean accepts(ResourceLocation modelLocation) {
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
// Load vanilla model
ModelBlock vanillaModel;
ResourceLocation vanillaModelLocation = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath() + ".json");
ResourceLocation vanillaModelLocation = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath() + ".json");
try (IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(vanillaModelLocation);
Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) {
vanillaModel = ModelBlock.deserialize(reader);
vanillaModel.name = modelLocation.toString();
}

// Load armature animation (currently disabled for efficiency, see MixinModelBlockAnimation)
String modelPath = modelLocation.getResourcePath();
String modelPath = modelLocation.getPath();
if (modelPath.startsWith("models/")) {
modelPath = modelPath.substring("models/".length());
}
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getResourceDomain(), "armatures/" + modelPath + ".json");
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getNamespace(), "armatures/" + modelPath + ".json");
ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(Minecraft.getMinecraft().getResourceManager(), armatureLocation);

// Return the vanilla model weapped in a VanillaModelWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Collection<ResourceLocation> getDependencies() {
set.add(dep);
}
}
if (model.getParentLocation() != null && !model.getParentLocation().getResourcePath().startsWith("builtin/")) {
if (model.getParentLocation() != null && !model.getParentLocation().getPath().startsWith("builtin/")) {
set.add(model.getParentLocation());
}
return ImmutableSet.copyOf(set);
Expand All @@ -77,7 +77,7 @@ public Collection<ResourceLocation> getDependencies() {
public Collection<ResourceLocation> getTextures() {
// Setting parent here to make textures resolve properly
if (model.getParentLocation() != null) {
if (model.getParentLocation().getResourcePath().equals("builtin/generated")) {
if (model.getParentLocation().getPath().equals("builtin/generated")) {
model.parent = BuiltinLoader.MODEL_GENERATED;
} else {
IModel parent = ModelLoaderRegistry.getModelOrLogError(model.getParentLocation(), "Could not load vanilla model parent '" + model.getParentLocation() + "' for '" + model);
Expand Down
Loading

0 comments on commit 1c84a50

Please sign in to comment.