AlexDGr8r Posted October 31, 2012 Posted October 31, 2012 I'm having issues with my falling meteors mod in which the meteors that are "summoned" do not render properly. When the entity summoner is thrown on the ground, it creates a new instance of my EntityMeteor that passes in arguments for position, size, meteor type, etc. Then I use worldObj.spawnEntityInWorld(meteor) and it only does this when worldObj.isRemote == false. I put some debug code in my entity meteor constructors to notice that after I call my custom constructor to set the position and such, it then calls another instance of the meteor but only through the constructor that has just the world argument (e.g. public EntityMeteor(World world)). This new meteor however does not have the properties of the meteor I spawned. It is just a default regular, small meteor. So I only see that meteor rendering in the game and not the custom meteor I told it to spawn. However, when it crashes to the ground, it has the effects of the custom meteor I spawned. I know this is a lot of rambling on, but I have everything setup properly I believe. I do have rendering setup to where it only renders client side with my proxy. I shall throw some of the code and see if anyone can help me. Ask me if you need more information on the topic. EntitySummoner onImpact method: protected void onImpact(MovingObjectPosition movingobjectposition) { if (!worldObj.isRemote) { EntityMeteor meteorToSpawn = new EntityMeteor(worldObj, MeteorHandler.getMeteorSize(), posX, posZ, MeteorHandler.getMeteorType(), true); worldObj.spawnEntityInWorld(meteorToSpawn); setDead(); } } EntityMeteor class (I've stripped all the useless code) public EntityMeteor(World world) { super(world); preventEntitySpawning = true; setSize(0.98F, 0.98F); yOffset = height / 2.0F; meteorStage = MeteorStage.Falling; fallOnlyAtNight = MeteorsMod.instance.meteorsFallOnlyAtNight; MeteorsMod.log.info("Instantiated meteor: World"); meteorType = EnumMeteor.METEORITE; } public EntityMeteor(World world, int mSize, double x, double z, EnumMeteor metType, boolean summon) { this(world); size = mSize; meteorType = metType; summoned = summon; setPosition(x, 250D, z); prevPosX = x; prevPosY = 250D; prevPosZ = z; meteorStage = MeteorStage.Falling; MeteorsMod.log.info("Instantiated new meteor through passed args."); } public void onUpdate() { prevPosX = posX; prevPosY = posY; prevPosZ = posZ; motionY -= 0.039999999105930328D; moveEntity(motionX, motionY, motionZ); motionX *= 0.98000001907348633D; motionY *= 0.98000001907348633D; motionZ *= 0.98000001907348633D; if(onGround) { setDead(); if(!worldObj.isRemote) { // Does all explosions and generation of crash site WorldGenMeteorCrash worldGen = getWorldGen(); if (worldGen.generate(worldObj, rand, (int)posX, (int)posY, (int)posZ)) { worldGen.afterCrashCompleted(worldObj, (int)posX, (int)posY, (int)posZ); } } meteorStage = MeteorStage.HitGround; } } public void writeEntityToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setInteger("size", size); nbttagcompound.setInteger("meteorstage", getMeteorStageInt()); nbttagcompound.setBoolean("summoned", summoned); MeteorsMod.log.info("Writing NBT"); nbttagcompound.setInteger("metTypeID", meteorType.getID()); } public void readEntityFromNBT(NBTTagCompound nbttagcompound) { size = nbttagcompound.getInteger("size"); setMeteorStage(nbttagcompound.getInteger("meteorstage")); summoned = nbttagcompound.getBoolean("summoned"); MeteorsMod.log.info("Reading NBT"); meteorType = EnumMeteor.getTypeFromID(nbttagcompound.getInteger("metTypeID")); } Often what I get after I spawn the entity into the world is this debug code so you can see what happens: 2012-10-31 13:11:41 [iNFO] [ForgeModLoader] Instantiated meteor: World 2012-10-31 13:11:41 [iNFO] [ForgeModLoader] Instantiated new meteor through passed args. 2012-10-31 13:11:41 [iNFO] [ForgeModLoader] Instantiated meteor: World If someone has general info on this situation such as which side (client/server) things need to be done please inform me of those as well. Quote
shadowmage4513 Posted November 1, 2012 Posted November 1, 2012 Is your MeteorHandler setup with the same information for both client and server side? Also, when creatures are spawned client side, they are spawned using the default one arg (World world) constructor. If you have additional data set by your server-side constructor, you need to pass that through the IEntityAdditionalSpawnData read and write streams interface so that the client receives the data after spawning the entity and applies it correctly (such as entity size, textures, entityType, all of the values you are putting in your constructor/setting up in your constructor). Quote
AlexDGr8r Posted November 1, 2012 Author Posted November 1, 2012 Is your MeteorHandler setup with the same information for both client and server side? Also, when creatures are spawned client side, they are spawned using the default one arg (World world) constructor. If you have additional data set by your server-side constructor, you need to pass that through the IEntityAdditionalSpawnData read and write streams interface so that the client receives the data after spawning the entity and applies it correctly (such as entity size, textures, entityType, all of the values you are putting in your constructor/setting up in your constructor). The meteor handler in this case is to just call my random functions for getting the meteor types and size and such. But the main purpose of the meteor handler is handle the flow of how often meteors spawn as well as where they spawn. The ticks and updates for this are on server-side though and appears to be working fine. But thank you so much for giving me this information. I was unaware of that interface and will use it to try and get things working. EDIT: Works great now. Thanks again! Quote
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.