Browse Source

0.1.4, improve compat with Forge 2623+

master
Adrian Siekierka 1 year ago
parent
commit
0612671310

+ 3
- 3
build.gradle View File

@@ -22,7 +22,7 @@ apply plugin: 'net.minecrell.licenser'
22 22
 sourceCompatibility = JavaVersion.VERSION_1_8
23 23
 targetCompatibility = JavaVersion.VERSION_1_8
24 24
 
25
-version = "0.1.3"
25
+version = "0.1.4"
26 26
 group = "pl.asie.smoothwater"
27 27
 archivesBaseName = "SmoothWater"
28 28
 
@@ -38,12 +38,12 @@ dependencies {
38 38
 }
39 39
 
40 40
 minecraft {
41
-	version = "1.12.2-14.23.1.2604"
41
+	version = "1.12.2-14.23.2.2624"
42 42
 
43 43
 	runDir = "run"
44 44
 	useDepAts = true
45 45
 	makeObfSourceJar = false
46
-	mappings = "snapshot_20180128"
46
+	mappings = "snapshot_20180302"
47 47
 
48 48
 	replace '@VERSION@', project.version
49 49
 	replace '@MC_VERSION@', version

+ 1
- 5
src/main/java/pl/asie/smoothwater/BlockLiquidForged.java View File

@@ -20,17 +20,13 @@ package pl.asie.smoothwater;
20 20
 
21 21
 import net.minecraft.block.BlockLiquid;
22 22
 import net.minecraft.block.material.Material;
23
-import net.minecraft.block.properties.IProperty;
24
-import net.minecraft.block.state.BlockStateContainer;
25 23
 import net.minecraft.block.state.IBlockState;
26 24
 import net.minecraft.util.EnumBlockRenderType;
27 25
 import net.minecraft.util.EnumFacing;
28 26
 import net.minecraft.util.math.BlockPos;
29 27
 import net.minecraft.util.math.Vec3d;
30 28
 import net.minecraft.world.IBlockAccess;
31
-import net.minecraftforge.common.property.ExtendedBlockState;
32 29
 import net.minecraftforge.common.property.IExtendedBlockState;
33
-import net.minecraftforge.common.property.IUnlistedProperty;
34 30
 import net.minecraftforge.fluids.BlockFluidBase;
35 31
 import net.minecraftforge.fluids.IFluidBlock;
36 32
 
@@ -52,7 +48,7 @@ public abstract class BlockLiquidForged extends BlockLiquid {
52 48
 
53 49
 	@Override
54 50
 	public boolean isTranslucent(IBlockState state) {
55
-		return SmoothWaterMod.isActive || super.isTranslucent(state);
51
+		return (SmoothWaterMod.isActive && SmoothWaterCore.patchFluidTranslucency) || super.isTranslucent(state);
56 52
 	}
57 53
 
58 54
 	@Override

+ 14
- 2
src/main/java/pl/asie/smoothwater/SmoothWaterCore.java View File

@@ -18,7 +18,11 @@
18 18
 
19 19
 package pl.asie.smoothwater;
20 20
 
21
+import net.minecraftforge.common.ForgeVersion;
21 22
 import net.minecraftforge.common.config.Configuration;
23
+import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
24
+import net.minecraftforge.fml.common.versioning.VersionParser;
25
+import net.minecraftforge.fml.common.versioning.VersionRange;
22 26
 import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
23 27
 
24 28
 import javax.annotation.Nullable;
@@ -29,7 +33,7 @@ import java.util.Map;
29 33
 @IFMLLoadingPlugin.TransformerExclusions({"pl.asie.smoothwater"})
30 34
 public class SmoothWaterCore implements IFMLLoadingPlugin {
31 35
 	public static Configuration config;
32
-	public static boolean patchModdedFluids;
36
+	public static boolean patchModdedFluidTranslucency, patchFluidTranslucency;
33 37
 
34 38
 	@Override
35 39
 	public String[] getASMTransformerClass() {
@@ -51,7 +55,15 @@ public class SmoothWaterCore implements IFMLLoadingPlugin {
51 55
 	public void injectData(Map<String, Object> data) {
52 56
 		config = new Configuration(new File(new File("config"), "smoothwater.cfg"));
53 57
 
54
-		patchModdedFluids = config.getBoolean("patchModdedFluidAO", "general", true, "Patches default ambient occlusion handling in modded fluids.");
58
+		VersionRange range = VersionParser.parseRange("(,14.23.2.2623)");
59
+		DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion("Forge", range);
60
+
61
+		patchFluidTranslucency = requiredVersion.containsVersion(new DefaultArtifactVersion("Forge", ForgeVersion.getVersion()));
62
+		if (patchFluidTranslucency) {
63
+			patchModdedFluidTranslucency = config.getBoolean("patchModdedFluidAO", "general", true, "Patches default ambient occlusion handling in modded fluids.");
64
+		} else {
65
+			patchModdedFluidTranslucency = false;
66
+		}
55 67
 
56 68
 		if (config.hasChanged()) {
57 69
 			config.save();

+ 1
- 9
src/main/java/pl/asie/smoothwater/SmoothWaterTransformer.java View File

@@ -18,18 +18,10 @@
18 18
 
19 19
 package pl.asie.smoothwater;
20 20
 
21
-import com.google.common.collect.HashMultimap;
22
-import com.google.common.collect.Multimap;
23 21
 import net.minecraft.launchwrapper.IClassTransformer;
24
-import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
25 22
 import org.objectweb.asm.*;
26 23
 import org.objectweb.asm.tree.*;
27 24
 
28
-import java.io.IOException;
29
-import java.io.InputStream;
30
-import java.util.HashMap;
31
-import java.util.Map;
32
-
33 25
 public class SmoothWaterTransformer implements IClassTransformer {
34 26
 	public static void appendIsTranslucentPatch(ClassNode cn, String methodName, String transformedName) {
35 27
 		MethodNode methodNode = new MethodNode(Opcodes.ACC_PUBLIC, methodName, "(Lnet/minecraft/block/state/IBlockState;)Z", null, null);
@@ -110,7 +102,7 @@ public class SmoothWaterTransformer implements IClassTransformer {
110 102
 
111 103
 			reader.accept(visitor, 0);
112 104
 			return writer.toByteArray();
113
-		} else if ("net/minecraftforge/fluids/BlockFluidBase".equals(reader.getClassName()) && SmoothWaterCore.patchModdedFluids) {
105
+		} else if ("net/minecraftforge/fluids/BlockFluidBase".equals(reader.getClassName()) && SmoothWaterCore.patchModdedFluidTranslucency) {
114 106
 			System.out.println("[SmoothWaterCore] Patched " + transformedName + "!");
115 107
 
116 108
 			ClassNode node = new ClassNode(Opcodes.ASM5);

Loading…
Cancel
Save