The_SlayerMC Posted January 7, 2015 Share Posted January 7, 2015 So I'm trying to make my custom particle have a custom texture, and that doesn't seem to be working... Here is my particle class: package net.industrial_magic.client.particle; import net.industrial_magic.event.TextureMagicParticle; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.IParticleFactory; import net.minecraft.client.renderer.texture.TextureClock; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.slayer.api.SlayerAPI; @SideOnly(Side.CLIENT) public class EntityMagicFX extends EntityFX { private float scale; private double x; private double y; private double z; public EntityMagicFX(World worldIn, double p_i1204_2_, double p_i1204_4_, double p_i1204_6_, double p_i1204_8_, double p_i1204_10_, double p_i1204_12_) { super(worldIn, p_i1204_2_, p_i1204_4_, p_i1204_6_, p_i1204_8_, p_i1204_10_, p_i1204_12_); this.motionX = p_i1204_8_; this.motionY = p_i1204_10_; this.motionZ = p_i1204_12_; this.x = p_i1204_2_; this.y = p_i1204_4_; this.z = p_i1204_6_; this.posX = this.prevPosX = p_i1204_2_ + p_i1204_8_; this.posY = this.prevPosY = p_i1204_4_ + p_i1204_10_; this.posZ = this.prevPosZ = p_i1204_6_ + p_i1204_12_; float f = this.rand.nextFloat() * 0.6F + 0.4F; this.scale = this.particleScale = this.rand.nextFloat() * 0.5F + 0.2F; this.particleRed = this.particleGreen = this.particleBlue = 1.0F * f; this.particleGreen *= 0.9F; this.particleRed *= 0.9F; this.particleMaxAge = (int)(Math.random() * 10.0D) + 30; this.noClip = true; func_180435_a(new TextureMagicParticle("builtin/particles")); //this.setParticleTextureIndex(rand.nextInt(3)); } @Override public int getFXLayer() { return 1; } @Override public int getBrightnessForRender(float f) { return 100; } @Override public float getBrightness(float p_70013_1_) { return 100F; } @Override public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; float f = (float)this.particleAge / (float)this.particleMaxAge; f = 1.0F - f; float f1 = 1.0F - f; f1 *= f1; f1 *= f1; this.posX = this.x + this.motionX * (double)f; this.posY = this.y + this.motionY * (double)f - (double)(f1 * 1.2F); this.posZ = this.z + this.motionZ * (double)f; if(this.particleAge++ >= this.particleMaxAge) this.setDead(); } } And here is my TextureMagicParticle: package net.industrial_magic.event; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.slayer.api.SlayerAPI; public class TextureMagicParticle extends TextureAtlasSprite { public TextureMagicParticle(String spriteName) { super(spriteName); makeAtlasSprite(new ResourceLocation(SlayerAPI.PREFIX + "textures/misc/particles.png")); } @Override public boolean hasCustomLoader(IResourceManager manager, ResourceLocation location) { return true; } } Now with the 1.8 update, it seems difficult making custom a texture Quote Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods Link to comment Share on other sites More sharing options...
The_SlayerMC Posted January 7, 2015 Author Share Posted January 7, 2015 I should also state, the particle only renders as a solid orange rectangles Quote Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods Link to comment Share on other sites More sharing options...
Guichaguri Posted January 21, 2015 Share Posted January 21, 2015 *BUMP* I need it too Quote Link to comment Share on other sites More sharing options...
TheGreyGhost Posted January 21, 2015 Share Posted January 21, 2015 If you solve it, pls give me some snippets so I can add it to my example code project? -TGG Quote Link to comment Share on other sites More sharing options...
Abastro Posted January 21, 2015 Share Posted January 21, 2015 SlayerAPI.PREFIX + "textures/misc/particles.png": please show us the location. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium. Link to comment Share on other sites More sharing options...
Guichaguri Posted January 22, 2015 Share Posted January 22, 2015 My code: @SideOnly(Side.CLIENT) public class TestParticle extends EntityFX { public TestParticle(World w, double x, double y, double z, double offsetX, double offsetY, double offsetZ) { super(w, x, y, z, offsetX, offsetY, offsetZ); this.particleIcon = TestTextureManager.createTexture(new ResourceLocation("MyModID", "textures/particle/custom.png")); this.particleTextureIndexX = 0; this.particleTextureIndexY = 0; this.noClip = false; this.particleAge = 0; this.particleMaxAge = 500; this.particleScale *= 1.4F; this.particleRed = this.particleGreen = this.particleBlue = 1; this.particleAlpha = 1; } @Override public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; particleAge++; if(particleAge > particleMaxAge) { this.setDead(); return; } moveEntity(motionX, motionY, motionZ); motionX *= motionX > 0.04 ? 1 : 1.03; motionY *= motionY > 0.04 ? 1 : 1.03; motionZ *= motionZ > 0.04 ? 1 : 1.03; } } PS: "MyModID" have the correct value, i just changed here TestTextureManager: public class TestTextureManager extends TextureAtlasSprite { public static TextureAtlasSprite createTexture(ResourceLocation loc) { return TextureAtlasSprite.makeAtlasSprite(loc); } private TestTextureManager(String sprite) { super(sprite); } } If I comment the line of "particleIcon", everything works fine but it uses vanilla texture sprite. I think the problem is with the "createTexture" Quote Link to comment Share on other sites More sharing options...
Draco18s Posted January 22, 2015 Share Posted January 22, 2015 When I poked at custom particles last, I had to manually bind a new texture (and then rebind the vanilla one). https://github.com/Draco18s/Artifacts/blob/master/main/java/com/draco18s/artifacts/client/AntibuilderParticle.java#L59 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
delpi Posted January 22, 2015 Share Posted January 22, 2015 I'm assuming from this you want to create your own particle shape. If, you want to use one of the standard shapes, you can just extend them and then change the color to match what you want. Quote Long time Bukkit & Forge Programmer Happy to try and help Link to comment Share on other sites More sharing options...
Guichaguri Posted January 22, 2015 Share Posted January 22, 2015 When I poked at custom particles last, I had to manually bind a new texture (and then rebind the vanilla one). https://github.com/Draco18s/Artifacts/blob/master/main/java/com/draco18s/artifacts/client/AntibuilderParticle.java#L59 1.8 don't have "renderParticle" anymore.. Quote Link to comment Share on other sites More sharing options...
Draco18s Posted January 22, 2015 Share Posted January 22, 2015 When I poked at custom particles last, I had to manually bind a new texture (and then rebind the vanilla one). https://github.com/Draco18s/Artifacts/blob/master/main/java/com/draco18s/artifacts/client/AntibuilderParticle.java#L59 1.8 don't have "renderParticle" anymore.. Well shucks. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Guichaguri Posted February 7, 2015 Share Posted February 7, 2015 I did it! Probably it's not the best solution, but it works. I took a look at the EffectRenderer (the class where particles were rendered) and as I could see, the custom texture was never used, but I found a method that is used to render the particle after binding the texture: func_180434_a This is not the best solution for it, vanilla particles will render with your sprite (i already filled a bug report on github, so particleIcon should work soon) My working code: @SideOnly(Side.CLIENT) public class ParticleTest extends EntityFX { private static ResourceLocation loc = new ResourceLocation("MODID", "textures/particle/custom.png"); public ParticleTest(World w, double x, double y, double z, double offsetX, double offsetY, double offsetZ) { super(w, x, y, z, offsetX, offsetY, offsetZ); this.particleTextureIndexX = 0; this.particleTextureIndexY = 0; this.noClip = false; this.particleAge = 0; this.particleMaxAge = 500; this.particleScale *= 1.4F; this.particleRed = this.particleGreen = this.particleBlue = 1; this.particleAlpha = 1; } @Override public void func_180434_a(WorldRenderer w, Entity e, float f1, float f2, float f3, float f4, float f5, float f6) { Minecraft.getMinecraft().renderEngine.bindTexture(loc); // THE MAGIC super.func_180434_a(w, e, f1, f2, f3, f4, f5, f6); } @Override public void onUpdate() { // ... } } *YOU SHOULD KEEP particleIcon NULL FOR THIS TO WORK* Someone should commit to forge creating a patch to make "particleIcon" work, maybe I do it by myself Also, sorry for my bad english. Quote Link to comment Share on other sites More sharing options...
Guichaguri Posted February 8, 2015 Share Posted February 8, 2015 To avoid overwriting vanilla particle texture, theres a easy solution: @Override public void func_180434_a(WorldRenderer worldRenderer, Entity e, float f1, float f2, float f3, float f4, float f5, float f6) { Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation); GlStateManager.enableBlend(); GlStateManager.blendFunc(770, 771); worldRenderer.startDrawingQuads(); super.func_180434_a(worldRender, e, f1, f2, f3, f4, f5, f6); Tessellator.getInstance().draw(); GlStateManager.disableBlend(); GlStateManager.enableLighting(); } @Override public int getFXLayer() { return 3; // THE IMPORTANT PART } With getFXLayer returning 3, I can draw the particle by myself. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.