Jump to content

[1.7.10]Entity Rendering Problem


Recommended Posts

ok, so here is my problem. the entity that I have spawned in the game is a ghost on the client. there for I cant see it. I have searched on the web for a solution, but I was unable to come to a conclusion on what to do. in eclipse the difference in my code is an exclamation point before a string. this(!world.isRemote) after removing the explanation point I have now rendered the classes ability to spawn my explosion created from the impact of the entity in the server, so the entity never explodes. How should I fix this here is the code from my Client Proxy and other stuff

 

ClientProxy

package com.OlympiansMod.Main;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;

import com.OlympiansMod.Item.ModItems;
import com.OlympiansMod.entity.EntityGreekFire;

import cpw.mods.fml.client.registry.RenderingRegistry;


public class ClientProxy extends ServerProxy{
public void registerRenderInfo(){
	RenderingRegistry.registerEntityRenderingHandler(EntityGreekFire.class, new RenderSnowball(ModItems.GreekFire));

                       





}
public int addArmor(String armor){
	return RenderingRegistry.addNewArmourRendererPrefix(armor);

}

}

 

Entity Classes

package com.OlympiansMod.entity;

import net.minecraft.entity.EntityList;

import com.OlympiansMod.Main.MainRegistry;

import cpw.mods.fml.common.registry.EntityRegistry;

public class MEntity {
public static void MainRegistry(){

}
public static void registerEntity(){
	createEntity(EntityGreekFire.class, "GreekFire", 0x008521, 0x00FF0800);
}
public static void createEntity(Class entityClass, String entityName, int solidColour, int spotColour){
	int randomId = EntityRegistry.findGlobalUniqueEntityId();

	EntityRegistry.registerModEntity(entityClass, entityName, randomId, MainRegistry.modInstance, 80, 1, false);
	createEgg(randomId, solidColour, spotColour);
}
private static void createEgg(int randomId, int solidColour, int spotColour){
	EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(randomId, solidColour, spotColour));

}
}

package com.OlympiansMod.entity;

import com.OlympiansMod.Item.ModItems;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityGreekFire extends EntityThrowable{

public EntityGreekFire(World p_i1776_1_) {
	super(p_i1776_1_);
}
public EntityGreekFire(World world, EntityLivingBase entity){
	super(world, entity);
}
@Override
protected void onImpact(MovingObjectPosition p_70184_1_) {
	for(int i = 0; i < 10; i++){
		this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0f, 0f, 0f);
		this.worldObj.playSound(this.posX, this.posY, this.posZ, "random.explode", 10.0f, 1.0f, inGround);


	}

	if(!this.worldObj.isRemote){
		this.setDead();
		this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 15.0f, true);
		}
	}
}	



 

ok this is were my item extends off of greek fire, the problem that I can see is here.

package com.OlympiansMod.entity;

import com.OlympiansMod.Item.ModItems;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityGreekFire extends EntityThrowable{

public EntityGreekFire(World p_i1776_1_) {
	super(p_i1776_1_);
}
public EntityGreekFire(World world, EntityLivingBase entity){
	super(world, entity);
}
@Override
protected void onImpact(MovingObjectPosition p_70184_1_) {
	for(int i = 0; i < 10; i++){
		this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0f, 0f, 0f);
		this.worldObj.playSound(this.posX, this.posY, this.posZ, "random.explode", 10.0f, 1.0f, inGround);


	}

	if(!this.worldObj.isRemote){
		this.setDead();
		this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 15.0f, true);
		}
	}
}	



 

what is the problem?

Im serious don't look at it!!

Link to comment
Share on other sites

sorry lol, here is Itemspawn code.

package com.OlympiansMod.Item;

import com.OlympiansMod.entity.EntityGreekFire;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class GreekFire extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(!player.capabilities.isCreativeMode){
		--itemstack.stackSize;
	}
	world.playSoundAtEntity(player, "random.fizz", 0.7f, 0.8f);

	if(!world.isRemote){
		world.spawnEntityInWorld(new EntityGreekFire(world, player));
	}
	return itemstack;
}

}

the problem is here

Im serious don't look at it!!

Link to comment
Share on other sites

Main

package com.OlympiansMod.Main;

import net.minecraft.client.renderer.entity.RenderSnowball;

import com.OlympiansMod.Block.ModBlocks;
import com.OlympiansMod.Item.ModItems;
import com.OlympiansMod.creativetabs.MCreativeTabs;
import com.OlympiansMod.entity.EntityGreekFire;
import com.OlympiansMod.entity.MEntity;
import com.OlympiansMod.lib.Refstrings;
import com.OlympiansMod.world.MWorld;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = Refstrings.MODID , name = Refstrings.NAME , version = Refstrings.VERSION)
public class MainRegistry {

@SidedProxy(clientSide = Refstrings.CLIENTSIDE , serverSide = Refstrings.SERVERSIDE)
public static ServerProxy proxy;

@Instance
public static MainRegistry modInstance;

@EventHandler
public static void PreLoad(FMLPreInitializationEvent PreEvent) {
	MCreativeTabs.initialiseTabs();
	ModBlocks.MainRegistry();
	MEntity.MainRegistry();
	ModItems.MainRegistry();
	MWorld.MainRegistry();
        CraftingManager.mainRegistry(); 
              

}
@EventHandler
public static void Load(FMLInitializationEvent event) {
	 proxy.registerRenderInfo(); 

}
@EventHandler
public static void PostLoad(FMLPostInitializationEvent PostEvent) {

}

}

client proxy

just for the future heres everything else

package com.OlympiansMod.Main;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;

import com.OlympiansMod.Item.ModItems;
import com.OlympiansMod.entity.EntityGreekFire;

import cpw.mods.fml.client.registry.RenderingRegistry;


public class ClientProxy extends ServerProxy{
public void registerRenderInfo(){
	RenderingRegistry.registerEntityRenderingHandler(EntityGreekFire.class, new RenderSnowball(ModItems.GreekFire));

                       
}
public int addArmor(String armor){
	return RenderingRegistry.addNewArmourRendererPrefix(armor);

}

}

GreekFire

package com.OlympiansMod.Item;

import com.OlympiansMod.entity.EntityGreekFire;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class GreekFire extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(!player.capabilities.isCreativeMode){
		--itemstack.stackSize;
	}
	world.playSoundAtEntity(player, "random.fizz", 0.7f, 0.8f);

	if(!world.isRemote){
		world.spawnEntityInWorld(new EntityGreekFire(world, player));
	}
	return itemstack;
}

}

GreekFireEntity

package com.OlympiansMod.entity;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityGreekFire extends EntityThrowable{

public EntityGreekFire(World p_i1776_1_) {
	super(p_i1776_1_);
}
public EntityGreekFire(World world, EntityLivingBase entity){
	super(world, entity);
}
@Override
protected void onImpact(MovingObjectPosition p_70184_1_) {
	for(int i = 0; i < 10; i++){
		this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0f, 0f, 0f);
		this.worldObj.playSound(this.posX, this.posY, this.posZ, "random.explode", 10.0f, 1.0f, inGround);
		this.worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, posX, posY, posZ));


	}

	if (!this.worldObj.isRemote){
		this.setDead();
		this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 15.0f, true);
		}
	}
}	



MEntity

package com.OlympiansMod.entity;

import net.minecraft.entity.EntityList;

import com.OlympiansMod.Main.MainRegistry;

import cpw.mods.fml.common.registry.EntityRegistry;

public class MEntity {
public static void MainRegistry(){

}
public static void registerEntity(){
	createEntity(EntityGreekFire.class, "GreekFire");
}
public static void createEntity(Class entityClass, String entityName){

	EntityRegistry.registerModEntity(entityClass, entityName, 5, MainRegistry.modInstance, 80, 1, true);

}
}

 

Im serious don't look at it!!

Link to comment
Share on other sites

I have 3 walking ghosts when you are drunk in my 1.7.10 magiccookies mod. The hop, dance and move to the player.

 

You need to spawn them with if(world.isRemote)// means is client

Then you need to hook into a tick event that ticks every client tick to steer the entities. Also make sure your client isnt set to peaceful.

You need to manually give them commands what to do. stuff like pathfinding etc... doesnt work. you need to manually write the code what they should do.

You need to sever all links to the server, because the server will mark them as invalid and kill them off, so dont call any methods that do server updates(like onupdate, hitplayer etc...) just do things like movearm, crouch, etc... all the clientside stuff.

 

As soon as something expects server input it sees its not valid, and it kills itself.

How much wood could a woodchuck chuck if a wood chuck could chuck wood - Guybrush Treepwood

 

I wrote my own mod ish... still a few bugs to fix. http://thaumcraft.duckdns.org/downloads/MagicCookies-1.0.6.4.jar

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.