Add particle helper

visibileWires
azurelmao 2 years ago
parent 40af9121bd
commit 4ec6692f18

@ -1,4 +1,4 @@
package azurelmao.examplemod; package azurelmao.examplemod.helper;
import azurelmao.examplemod.mixin.helper.RenderPlayerInterface; import azurelmao.examplemod.mixin.helper.RenderPlayerInterface;
import net.minecraft.src.helper.DamageType; import net.minecraft.src.helper.DamageType;

@ -1,4 +1,4 @@
package azurelmao.examplemod; package azurelmao.examplemod.helper;
import azurelmao.examplemod.mixin.helper.BlockInterface; import azurelmao.examplemod.mixin.helper.BlockInterface;
import net.minecraft.src.Block; import net.minecraft.src.Block;

@ -1,4 +1,4 @@
package azurelmao.examplemod; package azurelmao.examplemod.helper;
import azurelmao.examplemod.mixin.helper.DimensionInterface; import azurelmao.examplemod.mixin.helper.DimensionInterface;
import net.minecraft.src.Block; import net.minecraft.src.Block;

@ -1,4 +1,4 @@
package azurelmao.examplemod; package azurelmao.examplemod.helper;
import azurelmao.examplemod.mixin.helper.EntityListInterface; import azurelmao.examplemod.mixin.helper.EntityListInterface;
import azurelmao.examplemod.mixin.helper.RenderManagerInterface; import azurelmao.examplemod.mixin.helper.RenderManagerInterface;

@ -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<String, Class<? extends EntityFX>> particles = new HashMap<>();
public static void createParticle(Class<? extends EntityFX> clazz, String name) {
particles.put(name, clazz);
}
}

@ -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.CraftingManagerInterface;
import azurelmao.examplemod.mixin.helper.RecipesBlastFurnaceInterface; import azurelmao.examplemod.mixin.helper.RecipesBlastFurnaceInterface;
import azurelmao.examplemod.mixin.helper.RecipesFurnaceInterface; import azurelmao.examplemod.mixin.helper.RecipesFurnaceInterface;

@ -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<String, Class<? extends EntityFX>> particles = ParticleHelper.particles;
for (String name : particles.keySet()) {
if (s.equals(name)) {
Class<? extends EntityFX> 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);
}
}
}
}
}
}
}

@ -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();
}
}

@ -4,15 +4,17 @@
"package": "azurelmao.examplemod.mixin", "package": "azurelmao.examplemod.mixin",
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"mixins": [ "mixins": [
"helper.DimensionInterface",
"helper.RenderPlayerInterface",
"helper.BlockInterface",
"fix.MinecraftServerMixin", "fix.MinecraftServerMixin",
"helper.EntityListInterface", "helper.BlockInterface",
"helper.RenderManagerInterface",
"helper.CraftingManagerInterface", "helper.CraftingManagerInterface",
"helper.DimensionInterface",
"helper.EntityListInterface",
"helper.RecipesBlastFurnaceInterface", "helper.RecipesBlastFurnaceInterface",
"helper.RecipesFurnaceInterface" "helper.RecipesFurnaceInterface",
"helper.RenderGlobalMixin",
"helper.RenderManagerInterface",
"helper.RenderPlayerInterface",
"helper.TileEntityInterface"
], ],
"client": [ "client": [
], ],

Loading…
Cancel
Save