Skip to content

Commit e93f0a3

Browse files
The big update (aka 1.0.10 without the breaking stuff)
- Updated mappings to stable_39 - Cherrypicked PR for Ping bugs - Made sure OptiFine compat works again - Cherrypicked fix for CustomMainMenu and ReplayMod throwing a fit with us - Finally got Chisel textures to animate again (Shocking, I know) - Added BlockStateContainer fix from Aaron - Lots and lots of refractoring to get it to even compile - Stuff for ru_ru and pt_br - Probably more, but I give up at this point More fixes coming before the new release
1 parent a0764f2 commit e93f0a3

32 files changed

Lines changed: 376 additions & 145 deletions

build.gradle

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ apply plugin: "org.spongepowered.mixin"
1919
repositories {
2020
maven { url "http://repo.spongepowered.org/maven" }
2121
maven { url "http://chickenbones.net/maven/" }
22+
maven { url "http://www.dimdev.org/maven" }
23+
maven { url "http://maven.tterrag.com/" }
2224
ivy {
2325
url "https://google.com/404"
2426
ivyPattern("https://google.com/404") // Workaround for https://github.com/gradle/gradle/issues/4107
@@ -27,7 +29,7 @@ repositories {
2729
}
2830

2931
dependencies {
30-
implementation("org.spongepowered:mixin:0.7.10-SNAPSHOT") {
32+
implementation("org.dimdev:mixin:0.7.11-SNAPSHOT") {
3133
exclude module: "asm-commons"
3234
exclude module: "asm-tree"
3335
exclude module: "launchwrapper"
@@ -43,12 +45,14 @@ dependencies {
4345
compileOnly "2568:0:TConstruct-1.12.2-2.10.1.84@jar"
4446
compileOnly "2511:625:Avaritia-1.12-3.2.0.13-universal@jar"
4547
compileOnly "codechicken:CodeChickenLib:1.12.2-3.1.9.344:deobf"
48+
compileOnly "2482:584:CustomMainMenu-MC1.12.2-2.0.8@jar"
49+
compileOnly "team.chisel.ctm:CTM:MC1.12-0.2.3.12"
4650
}
4751

4852
def travisBuildNumber = System.getenv("TRAVIS_BUILD_NUMBER")
4953
def versionSuffix = travisBuildNumber != null ? travisBuildNumber : "SNAPSHOT"
5054

51-
version "1.0.9-$versionSuffix"
55+
version "1.0.10-$versionSuffix"
5256
group "org.dimdev.vanillafix"
5357
archivesBaseName = "VanillaFix"
5458

@@ -58,13 +62,14 @@ targetCompatibility = 1.8
5862
minecraft {
5963
version "1.12.2-14.23.4.2703"
6064
runDir "run"
61-
mappings "snapshot_20180607"
65+
mappings "stable_39"
6266
makeObfSourceJar false
6367

6468
def args = [
6569
"-Dfml.coreMods.load=org.dimdev.vanillafix.VanillaFixLoadingPlugin",
6670
"-Dmixin.hotSwap=true",
67-
"-Dmixin.checks.interfaces=true"
71+
"-Dmixin.checks.interfaces=true",
72+
"-Dmixin.debug.export=true"
6873
]
6974
clientJvmArgs.addAll(args)
7075
serverJvmArgs.addAll(args)
@@ -119,4 +124,4 @@ artifacts {
119124

120125
// These are broken
121126
runClient.group "other"
122-
runServer.group "other"
127+
runServer.group "other"

src/main/java/org/dimdev/vanillafix/VanillaFix.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.minecraft.item.ItemBlock;
99
import net.minecraft.util.ReportedException;
1010
import net.minecraft.util.ResourceLocation;
11+
import net.minecraftforge.common.ForgeModContainer;
1112
import net.minecraftforge.common.MinecraftForge;
1213
import net.minecraftforge.common.config.Config;
1314
import net.minecraftforge.common.config.ConfigManager;
@@ -29,8 +30,6 @@
2930
updateJSON = "https://gist.githubusercontent.com/Runemoro/28e8cf4c24a5f17f508a5d34f66d229f/raw/vanillafix_update.json")
3031
public class VanillaFix {
3132
private static final int CONFIG_VERSION = 1;
32-
private static final boolean DEBUG_BLOCK_IDS = false;
33-
private static final boolean DEBUG_ITEM_IDS = false;
3433
private static final boolean DEBUG_INIT_ERROR = false; // For testing the init error screen outside of dev. Don't forget to unset!
3534

3635
@Mod.EventHandler
@@ -73,31 +72,8 @@ public void onPreInit(FMLPreInitializationEvent event) {
7372
// Register event listeners
7473
MinecraftForge.EVENT_BUS.register(ModConfig.class);
7574

76-
IForgeRegistry<Block> blockRegistry = GameRegistry.findRegistry(Block.class);
77-
IForgeRegistry<Item> itemRegistry = GameRegistry.findRegistry(Item.class);
78-
79-
if (DEBUG_BLOCK_IDS) {
80-
for (int i = 0; i < 5000; i++) {
81-
Block block = new Block(Material.GROUND)
82-
.setCreativeTab(CreativeTabs.BUILDING_BLOCKS)
83-
.setUnlocalizedName("block_" + i)
84-
.setRegistryName(new ResourceLocation("vanillafix:block_" + i));
85-
86-
blockRegistry.register(block);
87-
itemRegistry.register(new ItemBlock(block).setRegistryName(new ResourceLocation("vanillafix:block_" + i)));
88-
}
89-
}
90-
91-
if (DEBUG_ITEM_IDS) {
92-
for (int i = 0; i < 40000; i++) {
93-
Item item = new Item()
94-
.setCreativeTab(CreativeTabs.FOOD)
95-
.setUnlocalizedName("item_" + i)
96-
.setRegistryName(new ResourceLocation("vanillafix:item_" + i));
97-
98-
itemRegistry.register(item);
99-
}
100-
}
75+
// Don't render terrain on main thread for higher FPS, but possibly seeing missing chunks
76+
ForgeModContainer.alwaysSetupTerrainOffThread = true;
10177

10278
if (DEBUG_INIT_ERROR) throw new ReportedException(new CrashReport("Debug init crash", new Throwable()));
10379
}

src/main/java/org/dimdev/vanillafix/VanillaFixLoadingPlugin.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
@IFMLLoadingPlugin.SortingIndex(-100000)
2626
public class VanillaFixLoadingPlugin implements IFMLLoadingPlugin {
2727
private static final Logger log = LogManager.getLogger();
28-
private static final String MCP_VERSION = "20180618-1.12"; // TODO: Use version for current Minecraft version!
2928
private static boolean initialized = false;
3029

3130
public static LoadingConfig config;
@@ -68,13 +67,13 @@ public static void initialize() {
6867
// Initialize StacktraceDeobfuscator
6968
log.info("Initializing StacktraceDeobfuscator");
7069
try {
71-
File mappings = new File(modDir, "methods-" + MCP_VERSION + ".csv");
70+
File mappings = new File(modDir, "methods-stable_39.csv");
7271
if (mappings.exists()) {
7372
log.info("Found MCP method mappings: " + mappings.getName());
7473
} else {
7574
log.info("Downloading MCP method mappings to: " + mappings.getName());
7675
}
77-
StacktraceDeobfuscator.init(mappings, MCP_VERSION);
76+
StacktraceDeobfuscator.init(mappings);
7877
} catch (Exception e) {
7978
log.error("Failed to get MCP data!", e);
8079
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.dimdev.vanillafix.bugs;
2+
public interface IPatchedSPacketPong {
3+
long getClientTime();
4+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.dimdev.vanillafix.bugs.mixins;
2+
3+
import net.minecraft.util.BitArray;
4+
import net.minecraft.world.chunk.BlockStateContainer;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Redirect;
8+
9+
/**
10+
* Provided by Aaron from Sponge. All code on this page is used in rights
11+
* with the Sponge license and was taken from SpongeCommon
12+
*/
13+
@Mixin(BlockStateContainer.class)
14+
public class MixinBlockStateContainer {
15+
16+
/**
17+
* Serializing a BlockStateContainer to a PacketBuffer is done in two parts:
18+
* calculating the size of the allocation needed in the PacketBuffer, and actually
19+
* writing it.
20+
*
21+
* When the BlockStateContainer is actually written to the PacketBuffer,
22+
* its 'storage.BitArray.getBackingLongArray' is written as a VarInt-length-prefixed
23+
* array. However, when calculating the size of the allocation needed, the size of
24+
* 'storage.size()' encoded as a VarInt is used, not the size of 'getBackingLongArray'
25+
* encoded as a VarInt. If the size of getBackingLongArray is ever large enough to require
26+
* an extra byte in its VarInt encoding, the allocated buffer will be too small, resuling in a crash.
27+
*
28+
* To fix this issue, we calculate the length of getBackingLongArray encoded as a VarInt,
29+
* when we're calculating the necessary allocation size.
30+
* @param bits
31+
* @return
32+
*/
33+
@Redirect(method = "getSerializedSize", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/BitArray;size()I"))
34+
private int onGetStorageSize$FixVanillaBug(BitArray bits) {
35+
return bits.getBackingLongArray().length;
36+
}
37+
38+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.dimdev.vanillafix.bugs.mixins;
2+
import net.minecraft.server.MinecraftServer;
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.Overwrite;
5+
@Mixin(MinecraftServer.class)
6+
public class MixinMinecraftServer {
7+
/**
8+
* @reason Disable initial world chunk load. This makes world load much faster, but in exchange
9+
* the player may see incomplete chunks (like when teleporting to a new area).
10+
*/
11+
@Overwrite
12+
public void initialWorldChunkLoad() {}
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.dimdev.vanillafix.bugs.mixins;
2+
3+
import net.minecraft.network.status.server.SPacketPong;
4+
import org.dimdev.vanillafix.bugs.IPatchedSPacketPong;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.Shadow;
7+
8+
@Mixin(SPacketPong.class)
9+
public class MixinSPacketPong implements IPatchedSPacketPong {
10+
@Shadow private long clientTime;
11+
12+
@Override
13+
public long getClientTime() {
14+
return clientTime;
15+
}
16+
}

src/main/java/org/dimdev/vanillafix/bugs/mixins/client/MixinIntegratedServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ public abstract class MixinIntegratedServer {
1919
private <V> V getUnchecked(Future<V> future) {
2020
return null;
2121
}
22-
}
22+
}

src/main/java/org/dimdev/vanillafix/bugs/mixins/client/MixinMinecraft.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@Mixin(Minecraft.class)
3030
public abstract class MixinMinecraft implements IThreadListener, ISnooperInfo {
3131
@Shadow @Final private static Logger LOGGER;
32-
@Shadow @Final public Profiler mcProfiler;
32+
@Shadow @Final public Profiler profiler;
3333

3434
@Shadow public GuiIngame ingameGUI;
3535

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

5050
/** @reason Make saving screenshots async (https://bugs.mojang.com/browse/MC-33383) */

src/main/java/org/dimdev/vanillafix/bugs/mixins/client/MixinNetHandlerPlayClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.spongepowered.asm.mixin.Overwrite;
1313
import org.spongepowered.asm.mixin.Shadow;
1414

15-
@Mixin(NetHandlerPlayClient.class)
15+
@Mixin(value = NetHandlerPlayClient.class, priority = 500)
1616
public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient {
1717
@Shadow private boolean doneLoadingTerrain;
1818
@Shadow(aliases = "clientWorldController") private WorldClient world;
@@ -35,7 +35,7 @@ public void handleRespawn(SPacketRespawn packetIn) {
3535
client.displayGuiScreen(null);
3636

3737
Scoreboard scoreboard = world.getScoreboard();
38-
world = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, client.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), client.mcProfiler);
38+
world = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, client.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), client.profiler);
3939
world.setWorldScoreboard(scoreboard);
4040
client.loadWorld(world);
4141
client.player.dimension = packetIn.getDimensionID();

0 commit comments

Comments
 (0)