Jump to content

Recommended Posts

Posted

good nigths

 

i have this issue from some long weeks , and lately i have little time to spend whith code for working reasons.

 

i have made a lot of items , tools mostly  and some fireguns , all of them works well on single player but on a server do absolutly nothing and sometimes  disapear or become another items.

 

to aknowledge why is this happend i create a simple item a bow, reducing the code to the simples thing  trying to realize whats its making this items useless    but reach the point of not idea what its the trouble

 

in this video:

 

 

i set the server and the normal minecraft whith just mi mod and fireup the two at same time, in the first part i test the bow and the shotgun on a normal world in the vainilla minecraft and this two items work well, in the second part i test the items in the server world neither the shotgun or the bow works and the first shotgun becomes in to  two musrooms whithout aparent reason.

 

this is the code from the bow for now it just work whith vainilla arrows

 

arcoMercenario.java

package mercenarymod.items.arcos;

import mercenarymod.Mercenary;
import mercenarymod.items.MercenaryModItems;
import mercenarymod.utilidades.chat;
import mercenarymod.utilidades.nbtMercenaria;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class arcoMercenario extends Item
{
    
   
    public static String name = "arcoMercenario";
    
    int tick=0;
    int texturajson=0;
    boolean tighten=false;
    boolean animacion=false;
    boolean continuar=false;
        
    float f=0.0F;
    int municion=0;
    int municionMax=0;
    static int municionMax0=32;

    public arcoMercenario()
    {
    	
    	setUnlocalizedName(Mercenary.MODID + "_" + name);
    	GameRegistry.registerItem(this, name);
    	setCreativeTab(Mercenary.herramientas);
        this.maxStackSize = 1;
        this.setMaxDamage(500);
        
    }
    
  //######################################################################################3	
  	 @Override
  public ModelResourceLocation getModel(ItemStack arco, EntityPlayer playerIn, int useRemaining){
  	
  	ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory");	 
  	animacion(arco, playerIn);
  	
  	if ((tick%10)==0){ //just to not check it every tick or  it lags
  		
  	animacion=nbtMercenaria.getBooleantag(arco, "animacion");
  	//System.out.println("Animacion="+animacion);
  		
  	if(!animacion){
  	
  	tighten=false;
  	
  	}
  	}
  		
  	//System.out.println("textura="+textura);
  	switch(this.texturajson){
    default:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory") ;break;
  	case  1:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario01", "inventory") ;break;
  	case  2:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario02", "inventory") ;break;	
  	case  3:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario03", "inventory") ;break;
  	    	                }
  	  	
  	tick++;
  	if (tick>100){tick=0;nbtMercenaria.setBooleantag(arco, "animacion",false);animacion=false;}
    	return modelresourcelocation;
    	
  		}

  //####################################################################################3	
  void animacion(ItemStack arco, EntityPlayer playerIn){	 //int tick
  	
  	//System.out.println("()this.thick="+tick+" cambioDeBotella="+cambioDeBotella+" giro="+giro);
  	 
  	 if ((tighten)){
  	 System.out.println("tighten="+tick);	 
  	 switch (tick){
  	 case 0:  texturajson=0;f=0.50F;break;
  	 case 7:  texturajson=1;f=1.00F;break;
  	 case 14: texturajson=2;f=1.50F;break;
  	 case 21: texturajson=3;f=2.00F;break;
  	 case 28: if(continuar){tick=20;};break;
  	 case 30: texturajson=0;tick=0;nbtMercenaria.setBooleantag(arco, "animacion",false);tighten=false;break;
  	          }   }
  	 else{texturajson=0;}
  	 
  	 
  	 
  }

//####################################################################################3		

void inicializar(ItemStack arco){  //this do nothing for now

int municion=0;
int metadata=arco.getMetadata();

switch(metadata){
case 1: municion=municionMax0/2;break;
case 2: municion=municionMax0;break;
default:municion=0;break;
            	}

nbtMercenaria.setInttag(arco, "municion", municion);
nbtMercenaria.setBooleantag(arco, "animacion", false);
nbtMercenaria.setBooleantag(arco, "liberar", false);
nbtMercenaria.setInttag(arco, "cargador", 0);
nbtMercenaria.setInttag(arco, "textura", 0);			


}
  
//####################################################################################3
    public void onPlayerStoppedUsing(ItemStack arco, World worldIn, EntityPlayer playerIn, int timeLeft)
    {
    	
    	
    	if (!worldIn.isRemote){
    		
    	playerIn.inventory.consumeInventoryItem(MercenaryModItems.flechaMercenaria);	
    		
    	EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f );	
    		
    	worldIn.spawnEntityInWorld(entityarrow);	
    	
    	chat.chatdp(playerIn, "shooting f="+f);
    	
    	f=0.0F;
    	
    	nbtMercenaria.setBooleantag(arco, "animacion", false);
    	    	
    		
    	                       }
    	
    	
    	
    	texturajson=0;tick=0;tighten=false;continuar=false;
    	
    }

    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
    {
    	//texturajson=0;tick=0;tighten=false;
        return stack;
        
    }

    public int getMaxItemUseDuration(ItemStack stack)
    {
        return 72000;
    }

    public EnumAction getItemUseAction(ItemStack stack)
    {
        return EnumAction.BOW;
    }

    
    //#####################################################################################3
    public ItemStack onItemRightClick(ItemStack arco, World worldIn, EntityPlayer playerIn)
    {
    	
    	if (!worldIn.isRemote){
    		
    		if (playerIn.capabilities.isCreativeMode 
    		|| playerIn.inventory.hasItem(MercenaryModItems.flechaMercenaria)){ //mercenaryArrow
    		//|| playerIn.inventory.hasItem(Items.arrow)){
    		
    		//municion=nbtMercenaria.getInttag(arco, "municion"); //not now
    		nbtMercenaria.setBooleantag(arco, "animacion", true);
    		animacion=true;
    		tighten=true;   //  tight the bow 
    		//chat.chatdp(playerIn, "has item "+tick);
    		
    	                     }}
    	
    	
    	if (tighten){
    		playerIn.setItemInUse(arco, this.getMaxItemUseDuration(arco));	
    		tick=0;
    		continuar=true;     //  tighten it until i tell you to release the arrow
    		//chat.chatdp(playerIn, "En Uso"+tick);  // in use
    		}
    	
    	
      
        
        return arco;
    }

    public int getItemEnchantability()
    {
        return 1;
    }
}

 

 

what do you think i coulbe doing wrong ?

 

Posted

    int tick=0;
    int texturajson=0;
    boolean tighten=false;
    boolean animacion=false;
    boolean continuar=false;
        
    float f=0.0F;
    int municion=0;
    int municionMax=0;

You can't do that, Item is just a singleton, shared between all items that use this class. You need to store NBT in ItemStack of Item.

http://www.minecraftforge.net/wiki/Creating_NBT_for_items

1.7.10 is no longer supported by forge, you are on your own.

Posted

What do these variables and where they are used?

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

not english

perfecto entonces

pero se quedan afuera los usuarios que solo hablan ingles,

 

por el lado de los nombres de las variables, creia que solo afectaban a esta instancia de este item especifico, a menos de que se declaren como public static, entonces si afectarian a todas las instancias de este mismo item, bueno mas tarde hago unas pruebas tengo eso en duda aun

 

hace tiempo trate de meter todas las variables como nbttags en el itemStack pero me estrelle con el problemita de que si trato de leer cada nbt cada tick entonces

int municion= nbtMercenaria.getInttag(arco, "municion");

int texturajson = nbtMercenaria.getInttag(arco, "texturajson");  //define la textura que se va  a usar en este instante

empiezan a devolver null, bueno por la forma en que hize la classe nbtMercenaria devuelve 9999 al encuentrar error al leer nbttag  asi que me frustre y deje de hacerlo de esa manera,  lo reduje a una sola nbttag "animacion" que solo se comprueba cada 10 tics y si es false no deja que el item cambie o actue de ninguna manera.

 

de cualquier manera ese es otro problema y otro post,

siendo este el unico arco en el servidor nada mas deberia interferir con el.

aun asi onItemRightClick  bueno en general las partes del codigo que se suponen corren cuando if (!worldIn.isRemote){} no estan funcionando, o hacen cosas raras 

 

bueno nunca e vista el codigo para un arma de fuego en minecraft todo esto que tengo hecho a salido de experimentar, preguntar en los foros y guiarme con lo que hay en la classe bow, y lo que me trae loco es ver que mi codigo funciona en el mundo normal pero no  funciona en el servidor,  entonces pense hay que hacer un arco sencillo  el arco vainilla funciona bien tanto en el mundo local como en el servidor asi que si hago un arco sencillo este deberia funcionar el server sin dar problemas , pero no lo hace  entonces  falta algo

 

 

for the names of the variables, i believe that only affect this instance of this specific item, unless it is declared as public static, then if would affect all instances of the same item, may is wrong but later test will done

 

time ago i try to  set all variables as nbttags in the itemStack but I stuck with this little problem, if I try to read every nbt each tick then

int ammunition = nbtMercenaria.getInttag (bow, "ammunition");

int texturajson = nbtMercenaria.getInttag (bow, "texturajson");  //set current texture for the item

they begin to return null, for the way I code the class nbtMercenaria it returns 9999 when it encounters an error reading nbt, just get tired of this and quit to do that way , so I reduced to a single nbttag "animation" this one is checked only every 10 tics and if false it shall not allow the item to changed or acts in any way.

 

anyway that's another problem and another post,

 

in this case

being the only bow on the server nothing else should interfere with it .

but still  onItemRightClick well the parts in the code that are supposed to run when if (! worldIn.isRemote) {} are not working, or do strange things.

 

well i never see the code the for a gun in minecraft before, all i have done has come from experiment whith code do questions on the forums and lok what is inside the bow class, drives me mad  see mi code work on normal minecraft, but do nothing when on a server, then i think  the bow class works well on normal and on server then if i do a custom bow based on thath code it may worksl, but  dont' it dont' work  there must be something i miss.

 

 

bueno gracias.

Posted

bueno

 

its goes this way

the server i download for minecrafts web is minecraft_server.1.8.3.jar, when install forge it creates the minecraft_server.1.8.jar

 

so i launch the server whith

cd server/
java -Xmx1024M -Xms1024M -jar minecraft_server.1.8.jar 

 

and launch normal vainilla minecraft whith

java -jar Minecraft.jar

 

this two has the same forge version instaled  forge-1.8-11.14.1.1322-installer.jar

 

aniway i do the test launching minecraft_server.1.8.3.jar for server but happends the same.

mods are in  server/mods/

 

there is some command to return the list of mods the server has loaded ? may server is not loading the mod

 

Posted

soo this was all about

 

i have wrong installed the forged server, an this is just the begin p

 

[18:42:32] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker
[18:42:32] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker
[18:42:32] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLServerTweaker
[18:42:33] [main/INFO] [FML]: Forge Mod Loader version 8.0.32.1322 for Minecraft 1.8 loading
[18:42:33] [main/INFO] [FML]: Java is Java HotSpot(TM) Server VM, version 1.7.0_76, running on Linux:i386:3.16.0-4-686-pae, installed at /usr/lib/jvm/java-7-oracle/jre
[18:42:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:42:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:42:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:42:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:42:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[18:42:35] [main/INFO] [FML]: Found valid fingerprint for Minecraft Forge. Certificate fingerprint e3c3d50c7c986df74c645c0ac54639741c90a557
[18:42:35] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[18:42:35] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:42:37] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:42:37] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:42:39] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.server.MinecraftServer}
[18:42:48] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting minecraft server version 1.8
[18:42:48] [server thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization
[18:42:49] [server thread/INFO] [FML]: MinecraftForge v11.14.1.1322 Initialized
[18:42:49] [server thread/INFO] [FML]: Replaced 204 ore recipies
[18:42:49] [server thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization
[18:42:50] [server thread/INFO] [FML]: Searching /home/tenchi/server/mods for mods
[18:42:51] [server thread/INFO] [modmercenario]: Mod modmercenario is missing the required element 'name'. Substituting modmercenario
[18:42:52] [server thread/INFO] [estructurasmercenarias]: Mod estructurasmercenarias is missing the required element 'name'. Substituting estructurasmercenarias
[18:42:52] [server thread/INFO] [FML]: Forge Mod Loader has identified 6 mods to load
[18:42:53] [server thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, modmercenario, examplemod, estructurasmercenarias] at CLIENT
[18:42:53] [server thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, modmercenario, examplemod, estructurasmercenarias] at SERVER
[18:42:57] [server thread/INFO] [FML]: Processing ObjectHolder annotations
[18:42:57] [server thread/INFO] [FML]: Found 384 ObjectHolder annotations
[18:42:57] [server thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[18:42:58] [server thread/INFO] [FML]: Applying holder lookups
[18:42:58] [server thread/INFO] [FML]: Holder lookups applied
[18:42:58] [server thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue
[18:42:58] [server thread/ERROR] [FML]: 
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{8.0.32.1322} [Forge Mod Loader] (forge-1.8-11.14.1.1322-universal.jar) Unloaded->Constructed->Pre-initialized
Forge{11.14.1.1322} [Minecraft Forge] (forge-1.8-11.14.1.1322-universal.jar) Unloaded->Constructed->Pre-initialized
modmercenario{1.5} [modmercenario] (modMercenario-1.6.jar) Unloaded->Constructed->Errored
examplemod{1.0} [Example Mod] (modMercenario-1.6.jar) Unloaded->Constructed->Pre-initialized
estructurasmercenarias{0.0} [estructurasmercenarias] (modMercenario-1.6.jar) Unloaded->Constructed->Pre-initialized
[18:42:58] [server thread/ERROR] [FML]: The following problems were captured during this phase
[18:42:58] [server thread/ERROR] [FML]: Caught exception from modmercenario
java.lang.NoClassDefFoundError: net/minecraft/client/settings/KeyBinding
at mercenarymod.utilidades.KeyBindings.init(KeyBindings.java:23) ~[KeyBindings.class:?]
at mercenarymod.Mercenary.preInit(Mercenary.java:57) ~[Mercenary.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:517) ~[FMLModContainer.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) [Loader.class:?]
at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88) [FMLServerHandler.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:355) [FMLCommonHandler.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:117) [po.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_76]
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.settings.KeyBinding
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.11.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[?:1.7.0_76]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[?:1.7.0_76]
... 34 more
Caused by: java.lang.NullPointerException
[18:42:58] [server thread/ERROR] [net.minecraft.server.MinecraftServer]: Encountered an unexpected exception
net.minecraftforge.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/settings/KeyBinding
at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:162) ~[LoadController.class:?]
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:516) ~[Loader.class:?]
at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88) ~[FMLServerHandler.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:355) ~[FMLCommonHandler.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:117) ~[po.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_76]
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/settings/KeyBinding
at mercenarymod.utilidades.KeyBindings.init(KeyBindings.java:23) ~[KeyBindings.class:?]
at mercenarymod.Mercenary.preInit(Mercenary.java:57) ~[Mercenary.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:517) ~[FMLModContainer.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) ~[LoadController.class:?]
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) ~[Loader.class:?]
... 5 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.settings.KeyBinding
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.11.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[?:1.7.0_76]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[?:1.7.0_76]
at mercenarymod.utilidades.KeyBindings.init(KeyBindings.java:23) ~[KeyBindings.class:?]
at mercenarymod.Mercenary.preInit(Mercenary.java:57) ~[Mercenary.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:517) ~[FMLModContainer.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) ~[LoadController.class:?]
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) ~[Loader.class:?]
... 5 more
Caused by: java.lang.NullPointerException
[18:42:58] [server thread/ERROR] [net.minecraft.server.MinecraftServer]: This crash report has been saved to: /home/tenchi/server/./crash-reports/crash-2015-03-05_18.42.58-server.txt

 

mi code is full of errors that crash server

and is curious coz  eclipse tell mi nothing about all this, and normal minecraft either show errors in the console it just works 

 

arrfff

what comes next s a long journey of remake the mod looking in every class for the defectives lines an maiby redoo the code for the more complez tools

Posted

Your crash is because you referenced an @SideOnly(Side.CLIENT) class (KeyBinding) somewhere in your code that is not only on the client side.

 

If you have keybindings, you should only register them through your ClientProxy - same with any Render classes and that type of thing.

 

Btw, the visibility and 'static'-ness of a class member has no impact on whether it actually behaves as a static member: every single Item is declared as a singleton, thus only one of each item exists and thus every Item class' members automatically behave as though they were static, because there is only ONE instance. Make sense?

Posted

yap  but

 

I alredy  take another way, an in that way another troubles apear  the keybind i shall solv later,

 

well tere is not only the keybind error but a lot of diferent things failing in the logs , so i decide to clean up.

I download the lastest version of forge and start again,

 

just the basic mercenarimod whith the first basic 10 materials, the bow and the arrow

so until this, all works well on eclipse, compile the mod, and put it on the server  now get

 

[20:54:03] [server thread/ERROR] [FML]: Caught exception from modmercenario
java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft
at mercenarymod.Mercenary.init(Mercenary.java:67) ~[Mercenary.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76] 


 

there is an error in the line 67 from mi main class and that is in the textures part 

 

    @Mod.EventHandler
    public void init(FMLInitializationEvent event) {
    
    	// materials
    		
    		
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.aceroMercenario,0,new     //this is line 67     
                ModelResourceLocation("modmercenario:aceromercenario", "inventory"));  //steel
    		
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.redstoneMercenaria,0 , 
    		new ModelResourceLocation("modmercenario:redstonemercenaria", "inventory"));  
    				
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.carbonoMercenario,0 , 
    		new ModelResourceLocation("modmercenario:carbonomercenario", "inventory"));   //graphene
    				
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.inertebarradeCarbon,0 , 
    		new ModelResourceLocation("modmercenario:inertebarradecarbon", "inventory"));  //graphene bar
    		
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.hierroAlrojo,0 , 
    		new ModelResourceLocation("modmercenario:hierroalrojo", "inventory"));  //red hot iron
    			
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.coalCompreso,0 , 
    		new ModelResourceLocation("modmercenario:coalcompreso", "inventory"));
    				
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.charcoalCompreso,0 , 
    		new ModelResourceLocation("modmercenario:charcoalcompreso", "inventory"));
    		
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.obsidianaMercenaria,0 , 
    		new ModelResourceLocation("modmercenario:obsidianamercenaria", "inventory"));
    		
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.nokiaMercenaria,0 , 
    		new ModelResourceLocation("modmercenario:nokiamercenaria", "inventory"));  //nokia material just for fun 
    		
    		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.barradeAcero,0 , 
    		new ModelResourceLocation("modmercenario:barradeacero", "inventory"));   //steel pipe 
    					
    		
    		//bows
    	        ModelBakery.addVariantName(MercenaryModItems.arcoMercenario, new String[]{
    	    		
    	    		"modmercenario:arcos/arcomercenario/arcomercenario00",
    	    		"modmercenario:arcos/arcomercenario/arcomercenario01",
    	    		"modmercenario:arcos/arcomercenario/arcomercenario02",
    	    		"modmercenario:arcos/arcomercenario/arcomercenario03",
    	    		"modmercenario:arcos/arcomercenario/flechaMercenaria" });
    	    
    	    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.arcoMercenario,0 , 
    	    new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory"));
    	    		
            //arrows
    	    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.flechaMercenaria,0 , 
    	    new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria", "inventory"));
    	    	    
    }

 

for some reason the sever dont like the way i declare the textures for the items

 

repet miself in eclipse it gives no error of any kind this 12 items works and has their current texture at display, everiting is normal the errors ocurr in the server console at the moment of fire up server

 

 

very tankfull

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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