Jump to content

[1.8] make my items work in a server. ¿ is my code wrong


perromercenary00

Recommended Posts

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 ?

 

Link to comment
Share on other sites

    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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • My modded minecraft world don't go past 100% on the loading screen. My backup still work, but i've made a lot of progress from the point i was that save. i have already checked online and did some suggestions i found, but nothing worked. Here is my latest log + i don´t have crash reports: https://github.com/GmsantosPT/Minecraft-mod-problems/tree/main   Pls Help, Santos
    • Please share a link to your crash report, as explained in the FAQ
    • I have a block already registered in my mod, which I have used in some worlds. The problem arises when in code, I add a property called CURRENT_AGE, when running Minecraft it freezes. In the console it doesn't appear any excpetion except that it stays in this phase: [Render thread/DEBUG] [ne.mi.co.ca.CapabilityManager/CAPABILITIES]: Attempting to automatically register: Lnet/minecraftforge/items/IItemHandler; Does anyone have an idea what it could be? I show the block and its registration public class SoulLichenBlock extends MultifaceBlock implements SimpleWaterloggedBlock, EntityBlock { public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final IntegerProperty SKILL_LEVEL = IntegerProperty.create("soullichen_level", 0, 30); public static final DirectionProperty FACE = DirectionProperty.create("soullichen_face"); public static final DirectionProperty DIRECTION = DirectionProperty.create("soullichen_direction"); public static final IntegerProperty CURRENT_AGE = BlockStateProperties.AGE_25; private final MultifaceSpreader spreader = new MultifaceSpreader(this); private final MultifaceSpreader.DefaultSpreaderConfig config = new MultifaceSpreader.DefaultSpreaderConfig(this); private LivingEntity owner; //private static final Integer MAX_AGE = 25; public SoulLichenBlock(Properties properties) { super(properties); this.registerDefaultState(this .defaultBlockState() .setValue(WATERLOGGED, Boolean.FALSE) .setValue(SKILL_LEVEL, 0) .setValue(FACE, Direction.DOWN) .setValue(DIRECTION, Direction.DOWN) .trySetValue(CURRENT_AGE, 0) ); } public static ToIntFunction<BlockState> emission(int p_181223_) { return (p_181221_) -> MultifaceBlock.hasAnyFace(p_181221_) ? p_181223_ : 0; } public static boolean hasFace(BlockState p_153901_, @NotNull Direction p_153902_) { BooleanProperty booleanproperty = getFaceProperty(p_153902_); return p_153901_.hasProperty(booleanproperty) && p_153901_.getValue(booleanproperty); } protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block, BlockState> stateDefinition) { stateDefinition.add(WATERLOGGED).add(SKILL_LEVEL).add(FACE).add(DIRECTION).add(CURRENT_AGE); super.createBlockStateDefinition(stateDefinition); } public @NotNull BlockState updateShape(BlockState p_153302_, @NotNull Direction p_153303_, @NotNull BlockState p_153304_, @NotNull LevelAccessor p_153305_, @NotNull BlockPos p_153306_, @NotNull BlockPos p_153307_) { if (p_153302_.getValue(WATERLOGGED)) { p_153305_.scheduleTick(p_153306_, Fluids.WATER, Fluids.WATER.getTickDelay(p_153305_)); } return super.updateShape(p_153302_, p_153303_, p_153304_, p_153305_, p_153306_, p_153307_); } @SuppressWarnings("deprecation") public @NotNull FluidState getFluidState(BlockState fluidState) { return fluidState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(fluidState); } public boolean propagatesSkylightDown(BlockState p_181225_, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos) { return p_181225_.getFluidState().isEmpty(); } public @NotNull MultifaceSpreader getSpreader() { return this.spreader; } public Optional<MultifaceSpreader.SpreadPos> spreadFromRandomFaceTowardRandomDirection( BlockState p_221620_, LevelAccessor p_221621_, BlockPos p_221622_, RandomSource p_221623_, int skillPoints, int age) { return Direction.allShuffled(p_221623_).stream().filter((p_221680_) -> { return this.config.canSpreadFrom(p_221620_, p_221680_); }).map((p_221629_) -> { return this.spreadFromFaceTowardRandomDirection(p_221620_, p_221621_, p_221622_, p_221629_, p_221623_, false, skillPoints, age); }).filter(Optional::isPresent).findFirst().orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardRandomDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, RandomSource randomSource, boolean aBoolean, int skillPoints, int age) { return Direction.allShuffled(randomSource).stream().map((direction) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, aBoolean, skillPoints, age)) .filter(Optional::isPresent) .findFirst() .orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, Direction direction, boolean aBoolean, int skillPoints, int age) { //DevilRpg.LOGGER.debug("BEGIN ==================================== spreadFromFaceTowardDirection skillPoints {}", skillPoints); return skillPoints < 0 ? Optional.empty() : getSpreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, this::canSpreadInto) .flatMap((spreadPos) -> { //DevilRpg.LOGGER.debug("END ================================ spreadFromFaceTowardDirection spreadPos {}", spreadPos); return this.spreadToFace(levelAccessor, spreadPos, aBoolean, skillPoints, direction, age); }); } public boolean canSpreadInto(BlockGetter p_221685_, BlockPos p_221686_, MultifaceSpreader.SpreadPos p_221687_) { BlockState blockstate = p_221685_.getBlockState(p_221687_.pos()); return this.stateCanBeReplaced(p_221685_, p_221686_, p_221687_.pos(), p_221687_.face(), blockstate) && isValidStateForPlacement(p_221685_, blockstate, p_221687_.pos(), p_221687_.face()); } protected boolean stateCanBeReplaced(BlockGetter p_221688_, BlockPos p_221689_, BlockPos p_221690_, Direction p_221691_, BlockState p_221692_) { return p_221692_.isAir() || p_221692_.is(this) || p_221692_.is(Blocks.WATER) && p_221692_.getFluidState().isSource(); } public Optional<MultifaceSpreader.SpreadPos> getSpreadFromFaceTowardDirection(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, Direction face, Direction direction, MultifaceSpreader.SpreadPredicate spreadPredicate) { //DevilRpg.LOGGER.debug("--- getSpreadFromFaceTowardDirection direction.getAxis() == face.getAxis(): {}", direction.getAxis() == face.getAxis()); ArrayList<Direction> directions = new ArrayList<>(); directions.add(direction); if (direction.getAxis() == face.getAxis()) { if (direction.getAxis().isHorizontal()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isVertical()).collect(Collectors.toCollection(ArrayList::new)); } if (direction.getAxis().isVertical()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isHorizontal()).collect(Collectors.toCollection(ArrayList::new)); } } for (Direction directionElement : directions) { /*DevilRpg.LOGGER.debug("--->> getSpreadFromFaceTowardDirection config.isOtherBlockValidAsSource(blockState) {} || " + "hasFace(blockState, face) {} && " + "!hasFace(blockState, direction) {}", config.isOtherBlockValidAsSource(blockState), hasFace(blockState, face), !hasFace(blockState, directionElement));*/ if (config.isOtherBlockValidAsSource(blockState) || hasFace(blockState, face) && !hasFace(blockState, directionElement)) { for (MultifaceSpreader.SpreadType multifacespreader$spreadtype : config.getSpreadTypes()) { MultifaceSpreader.SpreadPos multifacespreader$spreadpos = multifacespreader$spreadtype.getSpreadPos(blockPos, directionElement, face); //DevilRpg.LOGGER.debug("--- test SpreadPos: {} direction {} face {} ", multifacespreader$spreadpos, directionElement, face); if (spreadPredicate.test(blockGetter, blockPos, multifacespreader$spreadpos)) { //DevilRpg.LOGGER.debug("--- spreadPredicate success:"); return Optional.of(multifacespreader$spreadpos); } } } } return Optional.empty(); } public boolean isValidStateForPlacement(@NotNull BlockGetter blockGetter, @NotNull BlockState blockState, @NotNull BlockPos blockPos, @NotNull Direction face) { //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 1st condition: {} && ({} || {})", this.isFaceSupported(face), !blockState.is(this), !hasFace(blockState, face)); if (this.isFaceSupported(face) && (!blockState.is(this) || !hasFace(blockState, face))) { BlockPos blockpos = blockPos.relative(face); //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 2nd condition: canAttachTo {} ", secondCondition); return canAttachTo(blockGetter, face, blockpos, blockGetter.getBlockState(blockpos)); } else { return false; } } @Nullable public BlockState getStateForPlacement(@NotNull BlockState blockState, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos, @NotNull Direction face, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("--- getStateForPlacement"); boolean isNotValidStateForPlacement = !this.isValidStateForPlacement(blockGetter, blockState, blockPos, face); //DevilRpg.LOGGER.debug("------- isNotValidStateForPlacement: {}", isNotValidStateForPlacement); if (isNotValidStateForPlacement) { return null; } else { BlockState blockstate; if (blockState.is(this)) { blockstate = blockState; } else if (this.isWaterloggable() && blockState.getFluidState().isSourceOfType(Fluids.WATER)) { blockstate = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, Boolean.TRUE); } else { blockstate = this.defaultBlockState(); } //DevilRpg.LOGGER.debug("------- getStateForPlacement -> blockStateResult "); return blockstate .setValue(getFaceProperty(face), Boolean.TRUE) .setValue(SKILL_LEVEL, skillPoints).setValue(FACE, face) .setValue(DIRECTION, direction) .setValue(CURRENT_AGE,age) ; } } public Optional<MultifaceSpreader.SpreadPos> spreadToFace(LevelAccessor levelAccessor, MultifaceSpreader.SpreadPos spreadPos, boolean p_221596_, int skillPoints, Direction direction, int age) { BlockState blockstate = levelAccessor.getBlockState(spreadPos.pos()); //DevilRpg.LOGGER.debug("---> spreadToFace blockstate{} direction: {}", blockstate, direction); return this.placeBlock(levelAccessor, spreadPos, blockstate, p_221596_, skillPoints, direction, age) ? Optional.of(spreadPos) : Optional.empty(); } public boolean placeBlock(LevelAccessor p_221702_, MultifaceSpreader.SpreadPos p_221703_, BlockState p_221704_, boolean p_221705_, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("---> placeBlock {} direction {} ", p_221703_, direction); BlockState blockstate = this.getStateForPlacement(p_221704_, p_221702_, p_221703_.pos(), p_221703_.face(), skillPoints, direction, age); if (blockstate != null) { if (p_221705_) { p_221702_.getChunk(p_221703_.pos()).markPosForPostprocessing(p_221703_.pos()); } //DevilRpg.LOGGER.debug("------> setBlock"); return p_221702_.setBlock(p_221703_.pos(), blockstate, 2); } else { return false; } } public long spreadFromFaceTowardAllDirections( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, boolean aBoolean, int skillPoints, int age) { return Direction.stream().map((p_221656_) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, p_221656_, aBoolean, skillPoints, age)) .filter(Optional::isPresent).count(); } private boolean isWaterloggable() { return this.stateDefinition.getProperties().contains(BlockStateProperties.WATERLOGGED); } @Override public void setPlacedBy(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull BlockState blockState, @Nullable LivingEntity livingEntity, @NotNull ItemStack itemStack) { super.setPlacedBy(level, blockPos, blockState, livingEntity, itemStack); this.setOwner(livingEntity); } public LivingEntity getOwner() { return this.owner; } private void setOwner(LivingEntity livingEntity) { this.owner = livingEntity; } @Deprecated @Override public void entityInside(@NotNull BlockState blockState, @NotNull Level level, @NotNull BlockPos blockPos, @NotNull Entity entity) { if (entity instanceof LivingEntity /*&& entity.getType() != EntityType.BEE*/ && entity.getType() != ModEntities.LICHEN_SEEDBALL.get()) { entity.makeStuckInBlock(blockState, new Vec3(0.8D, 0.75D, 0.8D)); if (!level.isClientSide /*&& (entity.xOld != entity.getX() || entity.zOld != entity.getZ())*/) { // double d0 = Math.abs(entity.getX() - entity.xOld); // double d1 = Math.abs(entity.getZ() - entity.zOld); // if (d0 >= (double) 0.003F || d1 >= (double) 0.003F) { entity.hurt(level.damageSources().playerAttack((Player) owner), 1.0F); // Aplicar aceleración al movimiento double speedBoost = -0.4; // Ajusta este valor según lo rápido que quieras que sea el impulso double motionX = entity.getX() - entity.xOld; double motionZ = entity.getZ() - entity.zOld; double speed = Math.sqrt(motionX * motionX + motionZ * motionZ); //if (speed > 0.0) { entity.setDeltaMovement(entity.getDeltaMovement().multiply( (motionX / speed) * speedBoost, 0.0, (motionZ / speed) * speedBoost )); // } //} } } } @Nullable @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return ModEntityBlocks.SOUL_LICHEN_ENTITY_BLOCK.get().create(pos, state); } @Nullable @Override public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, @NotNull BlockState blockState, @NotNull BlockEntityType<T> type) { return level.isClientSide ? null : (alevel, pos, aBlockstate, blockEntity) -> { if (blockEntity instanceof SoulLichenBlockEntity soulLichenBlockEntity && alevel.getGameTime() % 5 == 0) { soulLichenBlockEntity.tick(blockState, (ServerLevel) alevel, pos, alevel.getRandom()); //DevilRpg.LOGGER.info("-------->tick. this: {}", this.getClass().getSimpleName()); } }; } }   This is the registration:   public final class ModBlocks { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, DevilRpg.MODID); ... public static final RegistryObject<SoulLichenBlock> SOUL_LICHEN_BLOCK = BLOCKS.register("soullichen", () -> new SoulLichenBlock( Block.Properties.copy(Blocks.GLOW_LICHEN).lightLevel(SoulLichenBlock.emission(7)).randomTicks() )); }  
    • If you are using AMD/ATI, check for driver updates on their website - do not update via system
    • Hi, Create a new class that extends "Block" class and you need json for it in resources/assets/modid/blockstates directory and resources/assets/modid/models. You can generate json for it using a tool like misodes model generator. Here, atleast, are blocks explained at forge docs.  Don't forge to look at vanilla code, like Magma Block is a good reference if you're trying a "green fire block".  Modid should be replaced with your actual forge mod namespace!
  • Topics

×
×
  • Create New...

Important Information

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