Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] Particle problems!!
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
The_SlayerMC

[1.7.10] Particle problems!!

By The_SlayerMC, November 25, 2014 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 25, 2014

So I have a strange crash with making my items spawn particles when they get hit using this:

 

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase hit, EntityLivingBase player) {
	Random r = new Random();
		for(int i = 0; i < 10; i++)
			ClientProxy.spawnParticle(EnumParticlesClasses.SNOWBALL_POOF, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F, false);
	return super.hitEntity(par1ItemStack, hit, player);
}

 

 

public static void spawnParticle(EnumParticlesClasses particle, World worldObj, double posX, double posY, double posZ, boolean b) {
	try {
		EntityFX fx = null;
		if(b) {
			fx = (EntityFX)particle.getParticle().getConstructor(World.class, double.class, double.class, double.class).newInstance(worldObj, posX, posY, posZ);
		} else {
			fx = (EntityFX)particle.getParticle().getConstructor(World.class, double.class, double.class, double.class, double.class, double.class, double.class).newInstance(worldObj, posX, posY, posZ, 0D, 0D, 0D);
		}
		Minecraft.getMinecraft().effectRenderer.addEffect(fx);
	} catch (Exception e) {
		e.printStackTrace();
	}
}

 

 

public enum EnumParticlesClasses {

LAVA(EntityLavaFX.class),
SMOKE(EntitySmokeFX.class),
FLAME(EntityFlameFX.class),
SNOWBALL_POOF(EntitySnowShovelFX.class);

private Class particle;

private EnumParticlesClasses(Class<? extends EntityFX> clazz) {
	particle = clazz;
}

public Class getParticle() {
	return particle;
}

 

Crash report:

 

 

net.minecraft.util.ReportedException: Ticking Particle
at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:102) ~[EffectRenderer.class:?]
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2135) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_67]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_67]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_67]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_67]
at GradleStart.bounce(GradleStart.java:107) [start/:?]
at GradleStart.startClient(GradleStart.java:100) [start/:?]
at GradleStart.main(GradleStart.java:65) [start/:?]
Caused by: java.lang.NullPointerException
at net.minecraft.entity.Entity.moveEntity(Entity.java:692) ~[Entity.class:?]
at net.minecraft.client.particle.EntitySnowShovelFX.onUpdate(EntitySnowShovelFX.java:71) ~[EntitySnowShovelFX.class:?]
at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:79) ~[EffectRenderer.class:?]
... 17 more
[16:58:31] [server thread/INFO] [FML]: Holder lookups applied
[16:58:31] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----
// Oh - I know what I did wrong!

Time: 25/11/14 4:58 PM
Description: Ticking Particle

java.lang.NullPointerException: Ticking Particle
at net.minecraft.entity.Entity.moveEntity(Entity.java:692)
at net.minecraft.client.particle.EntitySnowShovelFX.onUpdate(EntitySnowShovelFX.java:71)
at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:79)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2135)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:65)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraft.entity.Entity.moveEntity(Entity.java:692)
at net.minecraft.client.particle.EntitySnowShovelFX.onUpdate(EntitySnowShovelFX.java:71)

-- Particle being ticked --
Details:
Particle: EntitySnowShovelFX, Pos (784.3270931128927,4.699137304786724,1217.2007122882326), RGBA (0.9067198,0.9067198,0.9067198,1.0), Age 4
Particle Type: MISC_TEXTURE
Stacktrace:
at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:79)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['The_SlayerMC'/203, l='MpServer', x=786.55, y=5.62, z=1218.62]]
Chunk stats: MultiplayerChunkCache: 625, 625
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: 
Level spawn location: World: (727,4,1129), Chunk: (at 7,0,9 in 45,70; contains blocks 720,0,1120 to 735,255,1135), Region: (1,2; contains chunks 32,64 to 63,95, blocks 512,0,1024 to 1023,255,1535)
Level time: 5833 game time, 5833 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 54 total; [EntityItem['item.item.leather'/139, l='MpServer', x=821.63, y=4.13, z=1226.41], EntityXPOrb['Experience Orb'/141, l='MpServer', x=818.69, y=4.25, z=1222.44], EntityItem['item.item.beefRaw'/140, l='MpServer', x=820.56, y=4.13, z=1226.84], EntityItem['item.item.beefRaw'/143, l='MpServer', x=825.91, y=4.13, z=1274.66], EntityItem['item.item.leather'/142, l='MpServer', x=827.03, y=4.13, z=1274.88], EntityItem['item.item.beefRaw'/152, l='MpServer', x=846.84, y=4.13, z=1239.47], EntityXPOrb['Experience Orb'/153, l='MpServer', x=846.13, y=4.25, z=1243.03], EntityXPOrb['Experience Orb'/154, l='MpServer', x=847.78, y=4.25, z=1237.97], EntityItem['item.item.feather'/155, l='MpServer', x=839.84, y=4.13, z=1241.91], EntityItem['item.item.chickenRaw'/156, l='MpServer', x=838.91, y=4.13, z=1242.91], EntityXPOrb['Experience Orb'/157, l='MpServer', x=841.81, y=4.25, z=1240.13], EntityItem['item.item.beefRaw'/144, l='MpServer', x=830.72, y=4.13, z=1273.38], EntityXPOrb['Experience Orb'/145, l='MpServer', x=827.22, y=4.25, z=1270.13], EntityXPOrb['Experience Orb'/146, l='MpServer', x=826.78, y=4.25, z=1267.03], EntityItem['item.item.beefRaw'/147, l='MpServer', x=825.28, y=4.13, z=1280.34], EntityXPOrb['Experience Orb'/149, l='MpServer', x=827.91, y=4.25, z=1286.94], EntityItem['item.tile.cloth.white'/150, l='MpServer', x=846.72, y=4.13, z=1238.75], EntityItem['item.item.leather'/151, l='MpServer', x=846.69, y=4.13, z=1239.81], EntityPig['Pig'/174, l='MpServer', x=867.09, y=4.00, z=1166.81], EntityChicken['Chicken'/172, l='MpServer', x=866.47, y=4.00, z=1164.44], EntityHorse['Horse'/163, l='MpServer', x=857.56, y=4.00, z=1188.81], EntityChicken['Chicken'/162, l='MpServer', x=861.53, y=4.00, z=1161.53], EntityChicken['Chicken'/165, l='MpServer', x=851.63, y=4.00, z=1189.44], EntityChicken['Chicken'/164, l='MpServer', x=853.59, y=4.00, z=1169.56], EntityChicken['Chicken'/184, l='MpServer', x=864.38, y=4.00, z=1178.41], EntityChicken['Chicken'/178, l='MpServer', x=867.78, y=4.00, z=1180.28], EntityPig['Pig'/182, l='MpServer', x=866.16, y=4.00, z=1168.41], EntityHorse['Horse'/180, l='MpServer', x=862.25, y=4.00, z=1184.59], EntityChicken['Chicken'/70, l='MpServer', x=718.44, y=4.00, z=1292.56], EntityBat['Bat'/37849, l='MpServer', x=764.75, y=9.32, z=1253.00], EntitySheep['Sheep'/73, l='MpServer', x=733.06, y=4.00, z=1172.13], EntityPig['Pig'/85, l='MpServer', x=748.75, y=4.00, z=1176.38], EntityPig['Pig'/84, l='MpServer', x=730.56, y=4.00, z=1185.84], EntitySheep['Sheep'/87, l='MpServer', x=744.41, y=4.00, z=1181.06], EntityPig['Pig'/86, l='MpServer', x=743.28, y=4.00, z=1160.19], EntityBat['Bat'/78952, l='MpServer', x=761.50, y=9.00, z=1252.50], EntityCow['Cow'/81, l='MpServer', x=729.22, y=4.00, z=1188.25], EntityCow['Cow'/80, l='MpServer', x=737.69, y=4.00, z=1164.28], EntitySheep['Sheep'/83, l='MpServer', x=744.16, y=4.00, z=1183.91], EntitySheep['Sheep'/82, l='MpServer', x=741.44, y=4.00, z=1182.66], EntityPig['Pig'/89, l='MpServer', x=733.66, y=4.00, z=1192.75], EntityCow['Cow'/88, l='MpServer', x=738.78, y=4.00, z=1189.81], EntityBat['Bat'/102, l='MpServer', x=760.50, y=11.10, z=1251.47], EntityBat['Bat'/103, l='MpServer', x=759.78, y=11.10, z=1254.75], EntityBat['Bat'/100, l='MpServer', x=755.25, y=11.10, z=1254.75], EntityBat['Bat'/101, l='MpServer', x=752.25, y=15.10, z=1249.50], EntityCow['Cow'/98, l='MpServer', x=765.97, y=4.00, z=1188.97], EntityBat['Bat'/99, l='MpServer', x=764.53, y=19.10, z=1247.47], EntityBat['Bat'/106, l='MpServer', x=763.63, y=19.10, z=1248.63], EntityBat['Bat'/107, l='MpServer', x=764.75, y=19.10, z=1248.84], EntityBat['Bat'/104, l='MpServer', x=763.84, y=11.10, z=1248.69], EntityBat['Bat'/105, l='MpServer', x=742.66, y=4.12, z=1244.91], EntityHorse['Horse'/118, l='MpServer', x=783.56, y=4.45, z=1216.82], EntityClientPlayerMP['The_SlayerMC'/203, l='MpServer', x=786.55, y=5.62, z=1218.62]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2555)
at net.minecraft.client.Minecraft.run(Minecraft.java:973)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:65)

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_67, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 701732976 bytes (669 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.84.1219 Minecraft Forge 10.13.1.1219 7 mods loaded, 7 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.10.84.1219} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.1.1219.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.13.1.1219} [Minecraft Forge] (forgeSrc-1.7.10-10.13.1.1219.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
CodeChickenCore{1.0.4.29} [CodeChicken Core] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
NotEnoughItems{1.0.3.62} [Not Enough Items] (NotEnoughItems-1.7.10-1.0.3.62-universal.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
eotg{1.6} [Essence Of The Gods] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
DamageIndicatorsMod{3.2.0} [Damage Indicators] ([1.7.10]DamageIndicatorsMod-3.2.0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: GeForce GT 230/PCI/SSE2 GL version 3.2.0, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.

Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)
[16:58:31] [server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[16:58:31] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Development\Forge Youtube\eclipse\.\crash-reports\crash-2014-11-25_16.58.31-client.txt
[16:58:31] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[16:58:31] [Client thread/INFO] [FML]: Server terminated.
AL lib: (EE) alc_cleanup: 1 device not closed

 

 

 

The crash seems to be caused at "moveEntity(Entity)".

 

The particles spawn but when they hit the ground they crash.

 

So if anyone can help, that would be great... :)

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 25, 2014

That's not how proxies work. Your method should not be static. Also you need to check world.isRemote before spawning.

And that method of spawning particles is inefficient at best.

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 25, 2014

Okay, so I added this to my main class:

public static ClientProxy clientProxy;

 

this is now the particle method:

public void spawnParticle(EnumParticlesClasses particle, World worldObj, double posX, double posY, double posZ, boolean b) {
	try {
		EntityFX fx = null;
		if(b) {
			fx = (EntityFX)particle.getParticle().getConstructor(World.class, double.class, double.class, double.class).newInstance(worldObj, posX, posY, posZ);
		} else {
			fx = (EntityFX)particle.getParticle().getConstructor(World.class, double.class, double.class, double.class, double.class, double.class, double.class).newInstance(worldObj, posX, posY, posZ, 0D, 0D, 0D);
		}
		Minecraft.getMinecraft().effectRenderer.addEffect(fx);
	} catch (Exception e) {
		e.printStackTrace();
	}
}

 

and am now using this in the item class:

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase hit, EntityLivingBase player) {
	Random r = new Random();
		for(int i = 0; i < 40; i++) {
			if(!player.worldObj.isRemote) {
				Essence.clientProxy.spawnParticle(EnumParticlesClasses.FLAME, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F, false);
				Essence.clientProxy.spawnParticle(EnumParticlesClasses.SMOKE, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F, false);
				Essence.clientProxy.spawnParticle(EnumParticlesClasses.LAVA, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F, true);
	}
	return super.hitEntity(par1ItemStack, hit, player);
}

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 25, 2014

No... No no no.

You should never reference ClientProxy anywhere, except as a String in your @SidedProxy declaration. Every (public) ClientProxy method needs a dummy method in your CommonProxy which is overridden in your ClientProxy. It is obvious that you have not understood the concept of proxies.

 

Also you are now calling a ClientProxy method from the server thread (world.isRemote is false). That is not right.

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

Wait... you don't think that i think that just because the method is in the ClientProxy that it automatically get called on the client do you?! I just put it there because I don't want to make a new class for client methods.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 26, 2014

Yes, I understand that. But you call the method from common code (your Item). As such it will load the ClientProxy class even on a server. Which defeats the whole purpose.

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

So i changed this to make it be called on the client only:

 

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase hit, EntityLivingBase player) {
	Random r = new Random();
	hit.setFire(10);
	if(Config.spawnSwordParticles) {
		for(int i = 0; i < 70; i++) {
			Essence.proxy.spawnParticle(EnumParticlesClasses.FLAME, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F, false);
			Essence.proxy.spawnParticle(EnumParticlesClasses.SMOKE, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F, false);
			Essence.proxy.spawnParticle(EnumParticlesClasses.LAVA, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F, true);
		}
	}
	return super.hitEntity(par1ItemStack, hit, player);
}

 

common proxy

public void spawnParticle(EnumParticlesClasses particle, World worldObj, double posX, double posY, double posZ, boolean b) { }

 

and it now overrides the method in the client proxy

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 26, 2014

You'll still need to surround the call to the proxy with an isRemote check, otherwise the integrated server will call your particle code as well, which you don't want. Other than that it looks ok.

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

I forgot to mention, this is the new method:

 

@Override
public void spawnParticle(EnumParticlesClasses particle, World worldObj, double posX, double posY, double posZ, boolean b) {
	if(!worldObj.isRemote) {
		try {
			EntityFX fx = null;
			if(b) {
				fx = (EntityFX)particle.getParticle().getConstructor(World.class, double.class, double.class, double.class).newInstance(worldObj, posX, posY, posZ);
			} else {
				fx = (EntityFX)particle.getParticle().getConstructor(World.class, double.class, double.class, double.class, double.class, double.class, double.class).newInstance(worldObj, posX, posY, posZ, 0D, 0D, 0D);
			}
			Minecraft.getMinecraft().effectRenderer.addEffect(fx);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 26, 2014

Oh, right. You cannot use the particle-class enum you have on the server either (so it cannot occur in common code), because it references the client-only particle classes.

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

So i basically cannot use the particle classes, i have to stay with the Strings?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 26, 2014

Well, you could use an Enum, but then you'll have to make a Switch statement that translates that Enum into the classes, instead of storing the class inside the Enum itself.

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

So i basically changed these:

 

@Override
public void spawnParticle(EnumParticlesClasses particle, World worldObj, double x, double y, double z) {
	if(!worldObj.isRemote) {
		try {
			worldObj.spawnParticle(particle.getParticle(), x, y, z, 0D, 0D, 0D);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

 

public enum EnumParticlesClasses {

LAVA("lava"),
SMOKE("smoke"),
FLAME("flame"),
SNOWBALL_POOF("snowballpoof");

private String particle;

private EnumParticlesClasses(String name) {
	particle = name;
}

public String getParticle() {
	return particle;
}
}

 

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase hit, EntityLivingBase player) {
	Random r = new Random();
	hit.setFire(10);
	if(Config.spawnSwordParticles) {
		for(int i = 0; i < 70; i++) {
			Essence.proxy.spawnParticle(EnumParticlesClasses.FLAME, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F);
			Essence.proxy.spawnParticle(EnumParticlesClasses.SMOKE, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F);
			Essence.proxy.spawnParticle(EnumParticlesClasses.LAVA, player.worldObj, hit.posX + r.nextFloat() - 0.5F, hit.posY + 0.5D + r.nextFloat(), hit.posZ + r.nextFloat() - 0.5F);
		}
	}
	return super.hitEntity(par1ItemStack, hit, player);
}

 

And it doesn't spawn any particles at all

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 26, 2014

You are checking for the server, not for the client.

Also why are you catching exceptions?

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

Uhg the isRemote should be isClient then to solve confusions :P and to be honest, i actually don't know why i still am

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

This is still not spawning anything...

@Override
public void spawnParticle(EnumParticlesClasses particle, World worldObj, double x, double y, double z) {
	if(worldObj.isRemote) {
		worldObj.spawnParticle(particle.getParticle(), x, y, z, 0D, 0D, 0D);
	}
}

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 26, 2014

I can't see anything else that's wrong. Use the Debugger of your IDE to step through the code and find out where things fail.

  • Quote

Share this post


Link to post
Share on other sites

The_SlayerMC    7

The_SlayerMC

The_SlayerMC    7

  • Creeper Killer
  • The_SlayerMC
  • Members
  • 7
  • 201 posts
Posted November 26, 2014

Yeah... ill see what i can do... If worst comes to worst, i wont have particles :P

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • TomPlayzs
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By TomPlayzs · Posted 20 minutes ago

      I have this problem too! How do i fix it?
    • Oliviafrostpaw
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw · Posted 31 minutes ago

      Making it easier for showing the code, please see GitHub repository that I ideally should have set up to begin with so that I would have known when exactly all of this broke Github Link
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      i think whoever's bugging me in the HorseEntity Class is, here: private static final String[] HORSE_TEXTURES = new String[]{"textures/entity/horse/horse_white.png", "textures/entity/horse/horse_creamy.png", "textures/entity/horse/horse_chestnut.png", "textures/entity/horse/horse_brown.png", "textures/entity/horse/horse_black.png", "textures/entity/horse/horse_gray.png", "textures/entity/horse/horse_darkbrown.png"};  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.client.models; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.entity.model.RendererModel; import net.minecraft.client.renderer.model.ModelBox; import net.minecraft.entity.LivingEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class ModelUnicornWitoutAbstracHorse<T extends LivingEntity> extends EntityModel<T> { protected final RendererModel field_217127_a; protected final RendererModel field_217128_b; private final RendererModel CornGroup; private final RendererModel Corn1; private final RendererModel Corn2; private final RendererModel Corn3; public ModelUnicornWitoutAbstracHorse(float p_i51065_1_) { this.field_217127_a = null; this.field_217128_b = null; this.textureWidth = 128; this.textureHeight = 64; CornGroup = new RendererModel(this); CornGroup.setRotationPoint(0.0F, 0.0F, 0.0F); Corn1 = new RendererModel(this, 64, 0); Corn1.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn1.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn1); Corn1.cubeList.add(new ModelBox(Corn1, 52, 57, -3.0F, -3.0F, -4.0F, 3, 4, 3, 0.0F, true)); Corn2 = new RendererModel(this, 64, 28); Corn2.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn2.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn2); Corn2.cubeList.add(new ModelBox(Corn2, 0, 0, -2.4F, -5.3F, -3.6F, 2, 3, 2, 0.0F, true)); Corn3 = new RendererModel(this, 96, 32); Corn3.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn3.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn3); Corn3.cubeList.add(new ModelBox(Corn3, 0, 0, -1.8F, -8.1F, -3.2F, 1, 3, 1, 0.0F, true)); } protected void func_199047_a(RendererModel p_199047_1_) { RendererModel renderermodel = new RendererModel(this, 19, 16); renderermodel.addBox(0.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); RendererModel renderermodel1 = new RendererModel(this, 19, 16); renderermodel1.addBox(-2.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); p_199047_1_.addChild(renderermodel); p_199047_1_.addChild(renderermodel1); } }  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.entities; import net.batonfack.fantasymod.init.FantasyModEntities; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.horse.HorseEntity; import net.minecraft.world.World; public class UnicornEntity extends HorseEntity { @SuppressWarnings("unchecked") public UnicornEntity(EntityType<? extends HorseEntity> type, World worldIn) { super((EntityType<? extends HorseEntity>) FantasyModEntities.UNICORN_ENTITY, worldIn); } }  
  • Topics

    • WinneonSword
      2
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By WinneonSword
      Started September 1, 2013

    • Oliviafrostpaw
      8
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw
      Started December 8

    • DragonITA
      40
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 12:06 PM

    • DarkZapato
      2
      Optifine 1.14.4 U HD F4 crash froge

      By DarkZapato
      Started Thursday at 06:09 PM

    • troyvs
      0
      [1.12.2]help me to attach capability to player

      By troyvs
      Started 1 hour ago

  • Who's Online (See full list)

    • TolgacanM
    • Choonster
    • Misterboy64
    • Yanny7
    • ricoc90
    • Oliviafrostpaw
    • TomPlayzs
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] Particle problems!!
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community