diff --git a/build.gradle b/build.gradle index 37aba52..a47643b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { - id 'babric-loom' version '0.12-SNAPSHOT' - id 'java' + id 'babric-loom' version '0.12-SNAPSHOT' + id 'java' } group = project.mod_group @@ -8,49 +8,49 @@ archivesBaseName = project.mod_name version = project.mod_version loom { - gluedMinecraftJar() - noIntermediateMappings() - customMinecraftManifest.set("https://github.com/azurelmao/bta-manifest-repo/releases/download/v1.7.6.2_02/1.7.6.2_02.json") + gluedMinecraftJar() + noIntermediateMappings() + customMinecraftManifest.set("https://github.com/azurelmao/bta-manifest-repo/releases/download/v1.7.6.2_02/1.7.6.2_02.json") } repositories { - mavenCentral() - maven { - name = 'Babric' - url = 'https://maven.glass-launcher.net/babric' - } - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - ivy { - url = "https://github.com/Better-than-Adventure" - patternLayout { - artifact("[organisation]/releases/download/v[revision]/[module].jar") - m2compatible = true - } - metadataSources { artifact() } - } + mavenCentral() + maven { + name = 'Babric' + url = 'https://maven.glass-launcher.net/babric' + } + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + ivy { + url = "https://github.com/Better-than-Adventure" + patternLayout { + artifact("[organisation]/releases/download/v[revision]/[module].jar") + m2compatible = true + } + metadataSources { artifact() } + } } dependencies { - minecraft "bta-download-repo:bta:${project.bta_version}" - mappings loom.layered() {} + minecraft "bta-download-repo:bta:${project.bta_version}" + mappings loom.layered() {} - modRuntimeOnly files("libs/minecraft-client-base.jar") // only used to fix the Client run configuration - modImplementation "babric:fabric-loader:${project.loader_version}" + modRuntimeOnly files("libs/minecraft-client-base.jar") // only used to fix the Client run configuration + modImplementation "babric:fabric-loader:${project.loader_version}" - modImplementation "org.slf4j:slf4j-api:1.8.0-beta4" - modImplementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0" + modImplementation "org.slf4j:slf4j-api:1.8.0-beta4" + modImplementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0" - modImplementation("org.apache.commons:commons-lang3:3.12.0") - include("org.apache.commons:commons-lang3:3.12.0") + modImplementation("org.apache.commons:commons-lang3:3.12.0") + include("org.apache.commons:commons-lang3:3.12.0") } java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 - withSourcesJar() + withSourcesJar() } tasks.withType(JavaCompile) { @@ -58,15 +58,15 @@ tasks.withType(JavaCompile) { } jar { - from("LICENSE") { - rename { "${it}_${archivesBaseName}" } - } + from("LICENSE") { + rename { "${it}_${archivesBaseName}" } + } } processResources { - inputs.property "version", version + inputs.property "version", version - filesMatching("fabric.mod.json") { - expand "version": version - } + filesMatching("fabric.mod.json") { + expand "version": version + } } diff --git a/src/main/java/azurelmao/examplemod/ArmorHelper.java b/src/main/java/azurelmao/examplemod/helper/ArmorHelper.java similarity index 97% rename from src/main/java/azurelmao/examplemod/ArmorHelper.java rename to src/main/java/azurelmao/examplemod/helper/ArmorHelper.java index 98afd74..c7d71aa 100644 --- a/src/main/java/azurelmao/examplemod/ArmorHelper.java +++ b/src/main/java/azurelmao/examplemod/helper/ArmorHelper.java @@ -1,4 +1,4 @@ -package azurelmao.examplemod; +package azurelmao.examplemod.helper; import azurelmao.examplemod.mixin.helper.RenderPlayerInterface; import net.minecraft.src.helper.DamageType; diff --git a/src/main/java/azurelmao/examplemod/BlockHelper.java b/src/main/java/azurelmao/examplemod/helper/BlockHelper.java similarity index 98% rename from src/main/java/azurelmao/examplemod/BlockHelper.java rename to src/main/java/azurelmao/examplemod/helper/BlockHelper.java index 7891913..2189027 100644 --- a/src/main/java/azurelmao/examplemod/BlockHelper.java +++ b/src/main/java/azurelmao/examplemod/helper/BlockHelper.java @@ -1,4 +1,4 @@ -package azurelmao.examplemod; +package azurelmao.examplemod.helper; import azurelmao.examplemod.mixin.helper.BlockInterface; import net.minecraft.src.Block; diff --git a/src/main/java/azurelmao/examplemod/DimensionHelper.java b/src/main/java/azurelmao/examplemod/helper/DimensionHelper.java similarity index 95% rename from src/main/java/azurelmao/examplemod/DimensionHelper.java rename to src/main/java/azurelmao/examplemod/helper/DimensionHelper.java index 6add626..e2d9fc9 100644 --- a/src/main/java/azurelmao/examplemod/DimensionHelper.java +++ b/src/main/java/azurelmao/examplemod/helper/DimensionHelper.java @@ -1,4 +1,4 @@ -package azurelmao.examplemod; +package azurelmao.examplemod.helper; import azurelmao.examplemod.mixin.helper.DimensionInterface; import net.minecraft.src.Block; diff --git a/src/main/java/azurelmao/examplemod/EntityHelper.java b/src/main/java/azurelmao/examplemod/helper/EntityHelper.java similarity index 94% rename from src/main/java/azurelmao/examplemod/EntityHelper.java rename to src/main/java/azurelmao/examplemod/helper/EntityHelper.java index 821183c..e474cf4 100644 --- a/src/main/java/azurelmao/examplemod/EntityHelper.java +++ b/src/main/java/azurelmao/examplemod/helper/EntityHelper.java @@ -1,4 +1,4 @@ -package azurelmao.examplemod; +package azurelmao.examplemod.helper; import azurelmao.examplemod.mixin.helper.EntityListInterface; import azurelmao.examplemod.mixin.helper.RenderManagerInterface; diff --git a/src/main/java/azurelmao/examplemod/helper/ParticleHelper.java b/src/main/java/azurelmao/examplemod/helper/ParticleHelper.java new file mode 100644 index 0000000..36048a3 --- /dev/null +++ b/src/main/java/azurelmao/examplemod/helper/ParticleHelper.java @@ -0,0 +1,15 @@ +package azurelmao.examplemod.helper; + +import net.minecraft.src.EntityFX; + +import java.util.HashMap; +import java.util.Map; + +public class ParticleHelper { + + public static Map> particles = new HashMap<>(); + + public static void createParticle(Class clazz, String name) { + particles.put(name, clazz); + } +} diff --git a/src/main/java/azurelmao/examplemod/RecipeHelper.java b/src/main/java/azurelmao/examplemod/helper/RecipeHelper.java similarity index 98% rename from src/main/java/azurelmao/examplemod/RecipeHelper.java rename to src/main/java/azurelmao/examplemod/helper/RecipeHelper.java index 18560b9..75d394d 100644 --- a/src/main/java/azurelmao/examplemod/RecipeHelper.java +++ b/src/main/java/azurelmao/examplemod/helper/RecipeHelper.java @@ -1,5 +1,6 @@ -package azurelmao.examplemod; +package azurelmao.examplemod.helper; +import azurelmao.examplemod.ExampleMod; import azurelmao.examplemod.mixin.helper.CraftingManagerInterface; import azurelmao.examplemod.mixin.helper.RecipesBlastFurnaceInterface; import azurelmao.examplemod.mixin.helper.RecipesFurnaceInterface; diff --git a/src/main/java/azurelmao/examplemod/mixin/helper/RenderGlobalMixin.java b/src/main/java/azurelmao/examplemod/mixin/helper/RenderGlobalMixin.java new file mode 100644 index 0000000..07b100b --- /dev/null +++ b/src/main/java/azurelmao/examplemod/mixin/helper/RenderGlobalMixin.java @@ -0,0 +1,51 @@ +package azurelmao.examplemod.mixin.helper; + +import azurelmao.examplemod.helper.ParticleHelper; +import net.minecraft.client.Minecraft; +import net.minecraft.src.EntityFX; +import net.minecraft.src.RenderGlobal; +import net.minecraft.src.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Map; + +@Mixin(value = RenderGlobal.class, remap = false) +public class RenderGlobalMixin { + + @Shadow + private Minecraft mc; + + @Shadow + private World worldObj; + + @Inject(method = "spawnParticle", at = @At(value = "RETURN")) + private void examplemod_spawnParticle(String s, double x, double y, double z, double motionX, double motionY, double motionZ, CallbackInfo ci) { + if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) { + double d6 = this.mc.renderViewEntity.posX - x; + double d7 = this.mc.renderViewEntity.posY - y; + double d8 = this.mc.renderViewEntity.posZ - z; + double d9 = 16.0; + + if (!(d6 * d6 + d7 * d7 + d8 * d8 > d9 * d9)) { + Map> particles = ParticleHelper.particles; + for (String name : particles.keySet()) { + if (s.equals(name)) { + Class clazz = particles.get(name); + + try { + mc.effectRenderer.addEffect(clazz.getDeclaredConstructor(World.class, double.class, double.class, double.class, double.class, double.class, double.class).newInstance(worldObj, x, y, z, motionX, motionY, motionZ)); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + } + } + } + } + +} diff --git a/src/main/java/azurelmao/examplemod/mixin/helper/TileEntityInterface.java b/src/main/java/azurelmao/examplemod/mixin/helper/TileEntityInterface.java new file mode 100644 index 0000000..0755033 --- /dev/null +++ b/src/main/java/azurelmao/examplemod/mixin/helper/TileEntityInterface.java @@ -0,0 +1,14 @@ +package azurelmao.examplemod.mixin.helper; + +import net.minecraft.src.TileEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(value = TileEntity.class, remap = false) +public interface TileEntityInterface { + + @Invoker("addMapping") + static void callAddMapping(Class clazz, String s) { + throw new AssertionError(); + } +} diff --git a/src/main/resources/examplemod.mixins.json b/src/main/resources/examplemod.mixins.json index 937665a..1e7cdbc 100644 --- a/src/main/resources/examplemod.mixins.json +++ b/src/main/resources/examplemod.mixins.json @@ -4,15 +4,17 @@ "package": "azurelmao.examplemod.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "helper.DimensionInterface", - "helper.RenderPlayerInterface", - "helper.BlockInterface", "fix.MinecraftServerMixin", - "helper.EntityListInterface", - "helper.RenderManagerInterface", + "helper.BlockInterface", "helper.CraftingManagerInterface", + "helper.DimensionInterface", + "helper.EntityListInterface", "helper.RecipesBlastFurnaceInterface", - "helper.RecipesFurnaceInterface" + "helper.RecipesFurnaceInterface", + "helper.RenderGlobalMixin", + "helper.RenderManagerInterface", + "helper.RenderPlayerInterface", + "helper.TileEntityInterface" ], "client": [ ],