Jump to content

[1.8] proxy thing i have doubs about how to use them.<SOLVED>


perromercenary00

Recommended Posts

good days

im trying to fix some omisions in my first mod and there is this proxy thing, in the basic guides they dont speak much about proxy's,

now i been reading MinecraftByExample codes to realize how to use proxies, for whath i habe understood, there is this this to proxy's

for the way , commonProxy run in local world and server and here goes every item/block registry and the unlocalizated name variable

and clienProxy run just in local world and has the register textures to use whith the items,

 

so there is mi piece of mod whit just one item a bow "arcoMercenario"

 

package mercenarymod;

import mercenarymod.blocks.MercenaryModBlocks;
import mercenarymod.items.MercenaryModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;

@Mod(modid = Mercenary.MODID, version = Mercenary.VERSION)
public class Mercenary
{
    public static final String MODID = "modmercenario";
    public static final String VERSION = "1.7";
    
    public static SimpleNetworkWrapper network;
    
    // Says where the client and server 'proxy' code is loaded.
    @SidedProxy(clientSide="mercenario.ClientProxy", serverSide="mercenarymod.CommonProxy")
    public static CommonProxy proxy;
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    proxy.preInit(event);
    }
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    proxy.init(event);
    }
    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    proxy.postInit(event);
    }
    
    public static CreativeTabs herramientas = new CreativeTabs("Herraminetas armas y\n armaduras mercenarias") {
        @Override
        @SideOnly(Side.CLIENT)
        public Item getTabIconItem() {
            //return MercenaryModItems.aceroMercenario;
              return Items.potato;
         }
    };

    public static CreativeTabs materiales = new CreativeTabs("materiales mercenarios") {
        @Override
        @SideOnly(Side.CLIENT)
        public Item getTabIconItem() {
            //return MercenaryModItems.nokiaMercenaria;
              return Items.potato;
        }
    };

      
    
}

 

eclipse make my add the "event" inside  proxy.preInit(event);  coz "The method preInit(FMLPreInitializationEvent) in the type CommonProxy is not applicable for the arguments ()"

 

 

mercenario.ClientProxy

package mercenarymod;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import mercenarymod.CommonProxy;
import mercenarymod.blocks.MercenaryModBlocks;
import mercenarymod.items.MercenaryModItems;

public class ClientProxy extends CommonProxy {
       
        @Override
        public void registerRenderers() {
                // This is for rendering entities and so forth later on
        }
        
        @Mod.EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        Configuration config = new Configuration(event.getSuggestedConfigurationFile());	

        }
     
        @Mod.EventHandler
        public void init(FMLInitializationEvent event) {

        	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"));
        }
     
        @Mod.EventHandler
        public void postInit(FMLPostInitializationEvent event) {
        }
}

 

mercenarymod.CommonProxy

package mercenarymod;

import mercenarymod.blocks.MercenaryModBlocks;
import mercenarymod.items.MercenaryModItems;
import net.minecraft.item.Item;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class CommonProxy {

        // Client stuff
        public void registerRenderers() {
                // Nothing here as the server doesn't render graphics or entities!
        }
        
        public static Item arcoMercenario;
        
        @Mod.EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        	
        	arcoMercenario = (mercenarymod.items.arcos.arcoMercenario)(new mercenarymod.items.arcos.arcoMercenario().setUnlocalizedName("arcoMercenario"));
        	GameRegistry.registerItem(arcoMercenario, "arcoMercenario");
        }
     
        @Mod.EventHandler
        public void init(FMLInitializationEvent event) {
        }
     
        @Mod.EventHandler
        public void postInit(FMLPostInitializationEvent event) {
        }
}

 

the bow

 

mercenarymod.items.arcos.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.util.BlockPos;
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, 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, "disparando 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){
    		/*
    		BlockPos ppos=playerIn.getPosition();
    		double x=ppos.getX();
    		double y=ppos.getY();
    		double z=ppos.getZ();
    		
    		EntityBreakingFX(worldIn, x, y, z, Items.emerald);
    		*/
    		
    		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;
    		//chat.chatdp(playerIn, "has item "+tick);
    		
    	                     }}
    	
    	if (tighten){
    		playerIn.setItemInUse(arco, this.getMaxItemUseDuration(arco));	
    		tick=0;
    		continuar=true;
    		//chat.chatdp(playerIn, "En Uso"+tick);  // in use
    		}
        
        return arco;
    }

    public int getItemEnchantability()
    {
        return 1;
    }
}

 

it shows no errors in eclipse but when try to run

 

08:00:08] [Client thread/ERROR] [FML]: Caught exception from modmercenario
java.lang.NullPointerException
at net.minecraft.client.resources.model.ModelBakery.addVariantName(ModelBakery.java:835) ~[forgeSrc-1.8-11.14.1.1336.jar:?]
at mercenarymod.ClientProxy.init(ClientProxy.java:38) ~[bin/:?]
at mercenarymod.Mercenary.init(Mercenary.java:61) ~[bin/:?]
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:518) ~[forgeSrc-1.8-11.14.1.1336.jar:?]
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) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forgeSrc-1.8-11.14.1.1336.jar:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forgeSrc-1.8-11.14.1.1336.jar:?]
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) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:692) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:291) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.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.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:85) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]
[08:00:08] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: ---- Minecraft Crash Report ----
// On the bright side, I bought you a teddy bear!

 

 

i need thath modelBakery  in CommonProxy to register the json's for the pulling animation but  lets remove it to later fix

 

now minecraft runs but there is no bow anywhere the register dont works i dunnot now why , an the modelBakery is an importan issue

coz eclipse says nothings wrong whith code i get mas i dont have any idea of whath coul be posibly wrong here

 

 

help please

 

 


 

 

Link to comment
Share on other sites

Don't put @Mod.EventHandler in any class except the main class - it does not belong in your proxies at all.

 

Your client proxy extends the common, so you need to call 'super.whateverMethod' from each of your methods, otherwise the stuff in common proxy never gets called, meaning that your Item was never initialized and thus the crash.

Link to comment
Share on other sites

good days 

 

alredy remove the notations "@Mod.EventHandler" in clienproxy and commondproxy and now i have some progress and some new questions

 

I set some systemouts to see whats working and now eclipse its ignoring the CommonProxy but is loading ClientProxy and CommonProxy is the one registering the items in to workaround i have to move the mercenaryModItems.init();  to the preInit() in the main class

 

whit this fix i get the items registered and now the bow works in eclipse

then compile it and put the jar in the server and this is odd very odd cos server is loading CommonProxy and do it whitout show any error

eclipse ignores commond proxy so i cant'n initialize mi items there,  but in minecraftServer it loads

 

anyway still having the same issue from long before, i have this item bow, it works in eclipse and if i put it in normal vainilla minecraft its works as well ,but when in a server it does nothing and sometimes desapear or become another item.

 

jumm so long the questions are,

 

-why is eclipse and vainilla minecraft ignoring this commond proxy  but server dont

-why this bow works in eclipse and vainilla minecraft but not in server

 

 

 

this is the source code https://drive.google.com/file/d/0B8sU_NyZQBd7Rk9VcXpLWWZTNXc/view?usp=sharing

 

this is the compiled mod https://drive.google.com/file/d/0B8sU_NyZQBd7ZmhNZThUZE9JSEU/view?usp=sharing

 

 

 

thi is log from server cmd

[08:43:27] [server thread/INFO] [sTDOUT]: [mercenarymod.CommonProxy:preInit:26]: ########


CommonProxy preInit()
08:43:27] [server thread/INFO] [FML]: Applying holder lookups
[08:43:27] [server thread/INFO] [FML]: Holder lookups applied
[08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Loading properties
[08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Default game type: SURVIVAL
[08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Generating keypair
[08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting Minecraft server on *:25565
[08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
[08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: The server will make no attempt to authenticate usernames. Beware.
[08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
[08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: To change this, set "online-mode" to "true" in the server.properties file.
[08:43:27] [server thread/INFO] [sTDOUT]: [mercenarymod.CommonProxy:init:40]: ########


CommonProxy init()
[08:43:27] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:init:18]: DIRT BLOCK >> tile.dirt
[08:43:28] [server thread/INFO] [sTDOUT]: [mercenarymod.CommonProxy:postInit:53]: ########


CommonProxy postInit()

 

clean

CommonProxy

package mercenarymod;

import mercenarymod.blocks.MercenaryModBlocks;
import mercenarymod.items.MercenaryModItems;
import net.minecraft.item.Item;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class CommonProxy {

        // Client stuff
        public void registerRenderers() {
                // Nothing here as the server doesn't render graphics or entities!
        }
        
        //@Mod.EventHandler
        public void preInit() {
        System.out.println("########\n\n\n CommonProxy preInit()");	       	
        
        //MercenaryModItems.init();
        }
   
        //@Mod.EventHandler
        public void init() {
       	System.out.println("########\n\n\n CommonProxy init()");	
        }
     
        //@Mod.EventHandler
        public void postInit() {
        System.out.println("########\n\n\n CommonProxy postInit()");	   		
        }
        
}

 

 

clean

ClientProxy

package mercenarymod;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import mercenarymod.CommonProxy;
import mercenarymod.blocks.MercenaryModBlocks;
import mercenarymod.items.MercenaryModItems;

public class ClientProxy extends CommonProxy {
     
        //@Override
        public void registerRenderers() {
        // This is for rendering entities and so forth later on
        }
        
        public void preInit(){
        System.out.println("########\n\n\n ClientProxy preInit()");	
        }
     
        public void init() {
  	System.out.println("########\n\n\n ClientProxy init()");
        mercenarymod.MercenaryModTexturas.init();
        }
     
        public void postInit() {	
        System.out.println("########\n\n\n ClientProxy postInit()");
        }
}

 

Link to comment
Share on other sites

bueno

 

then this is the normal behavior

that whas the first thing i think,

but

in the greywolfs code he puts the items gameregistry and unlocalizated name in commonProxy, that dont work in mi code i dunot know why

 

then the mercenaryModitems.class  must be in the preinit from the main class to initializate all mi items this is the way i been seen it other codes

 

 

about the bow not working, this is just a scrap from all mi code i just get remove everything else, recipes, blocks, events, to make more easy the reason way this items fail, 

 

i have made a lot of items thath do something when rigth click, guns that shoot, chainsaw  , drills dinamite  but any of this items works when runing on a server

and now i I think the fault lies in the proxyes

 

in this case the bow must consume an arrow, thingten then release the arrow this is not happening when runing in the server but in eclipse or in minecraft normal game this works i have a video here to prove it

 

and this post is the begining of this threath 

http://www.minecraftforge.net/forum/index.php/topic,28397.0.html

 

and now then the question is the code i put on 7zip file this is the rigth way of using proxyes. ?

 

 

Link to comment
Share on other sites

good nigths

this afthernoon

i get epiphany in a hangover and realize mi troubles

 

the magic word Override when i do long time ago the first handgun i forget to override the onitemrigthclick from then i do all the rest items reusing  this code  changing only just things i need to change, and realize to the trouble whith nbttags returning null was just becoze some tags get written on local world

 

this is the new clean code i gonna use to redo all the rest 

this one its workin on the server 

 

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.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class arcoMercenario extends Item
{
    
    public arcoMercenario()
    {
    	String name = "arcoMercenario";
    	setUnlocalizedName(Mercenary.MODID + "_" + name);
    	GameRegistry.registerItem(this, name);
    	setCreativeTab(Mercenary.herramientas);
        this.maxStackSize = 1;
        this.setMaxDamage(1000);
        
    }

   
//####################################################################################3	    
@Override
public ModelResourceLocation getModel(ItemStack arco, EntityPlayer playerIn, int useRemaining){

int tick;
    if (useRemaining>970){tick=30-(useRemaining-970);}
    else {tick=30;}
    
    
	ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory");	 

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

	if(municion < 0 | municion > 9998){intialize(arco,playerIn);}

	int texturajson=getInttag(arco, "texturajson");
	boolean shoot = getBooleantag(arco, "shoot");


    switch(texturajson){
    case   0: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;
	    	            }

    if (shoot){
        	
    switch(tick){
    case 0:          setInttag(arco, "texturajson",0 );break;
    case 1:          setInttag(arco, "texturajson",1 );break;
    case 12:         setInttag(arco, "texturajson",2 );break;
    case 24:         setInttag(arco, "texturajson",3 );break;
       
                 }
    
        
    //System.out.println("useRemaining="+useRemaining+"\ntexturajson="+texturajson+"\n f="+getFloattag(arco, "strength")+" tick="+tick);
    //System.out.println("tick="+tick);
               }
     

	//setInttag(arco, "municion",10 );
   	return modelresourcelocation;
   	
		}



//#########################################################################3
@Override
public ItemStack onItemRightClick(ItemStack arco, World worldIn, EntityPlayer playerIn)
{

 //System.out.println(" On rigth click ");
 setBooleantag(arco, "shoot", true);
 playerIn.setItemInUse(arco, this.getMaxItemUseDuration(arco));

return arco; 
}

//####################################################################################3
@Override
public void onUsingTick(ItemStack arco, EntityPlayer player, int count)
{

}	 
@Override
public void onPlayerStoppedUsing(ItemStack arco, World worldIn, EntityPlayer playerIn, int timeLeft)
{
	int tick;
    if (timeLeft>970){tick=30-(timeLeft-970);}
    else {tick=30;}

 float f=((tick/30F)*3F);

  
 if (!worldIn.isRemote){

	    		 
    	playerIn.inventory.consumeInventoryItem(MercenaryModItems.flechaMercenaria);	
    		
    	EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f );	
    		
    	worldIn.spawnEntityInWorld(entityarrow);	
    	
    	//chat.chatdp(playerIn, "shooting force f="+f);
    		    	
    	setBooleantag(arco, "shoot", false);
    	
    	arco.damageItem(1, playerIn);//dañar con el uso
    	    	
    		
    	                       }
    	

}
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
      return stack;
}


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

@Override
public EnumAction getItemUseAction(ItemStack stack)
{

     return EnumAction.BOW;
}

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

public static void intialize(ItemStack arco, EntityPlayer playerIn){

//System.out.println("#\n#\n#\n Incializacion");

setInttag(arco, "texturajson", 0);
setInttag(arco, "municion", 0);
setBooleantag(arco, "reload", false);
setBooleantag(arco, "shoot", false);
setBooleantag(arco, "unload", false);
setFloattag(arco, "strength", 0.0F);


}

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

public static int getInttag(ItemStack its, String tag){	

NBTTagCompound nsInt = new NBTTagCompound();

try {

	NBTTagCompound exi= its.getTagCompound();
	int ex=exi.getInteger(tag); 
	return ex;
  
} catch (Throwable any) {
 	return 9999;

}

}

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

public static void setInttag(ItemStack its, String tag, int value){

try{
NBTTagCompound nsInt= its.getTagCompound();
nsInt.setInteger(tag, value);
its.setTagCompound(nsInt);

}catch(Throwable any) {

NBTTagCompound nsInt = new NBTTagCompound();
nsInt.setInteger(tag, value);	
its.setTagCompound(nsInt);	

}}
//#########################################################################3
public static float getFloattag(ItemStack its, String tag){	

NBTTagCompound nsInt = new NBTTagCompound();

try {

	NBTTagCompound exi= its.getTagCompound();
	float ex=exi.getFloat(tag); 
	return ex;
  
} catch (Throwable any) {
 	return 9999.00F;

}

}

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

public static void setFloattag(ItemStack its, String tag, float value){

try{
NBTTagCompound nsInt= its.getTagCompound();
nsInt.setFloat(tag, value);
its.setTagCompound(nsInt);

}catch(Throwable any) {

NBTTagCompound nsInt = new NBTTagCompound();
nsInt.setFloat(tag, value);	
its.setTagCompound(nsInt);	

}}
//#########################################################################3

public static Boolean getBooleantag(ItemStack its, String tag){	

	NBTTagCompound nsInt = new NBTTagCompound();

	try {

		NBTTagCompound exi= its.getTagCompound();
		boolean ex=exi.getBoolean(tag);  
		return ex;
	  
 } catch (Throwable any) {
	 	return false;

 }

}

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

public static void setBooleantag(ItemStack its, String tag, boolean value){

	try{
	NBTTagCompound nsInt= its.getTagCompound();
	nsInt.setBoolean(tag, value);
	its.setTagCompound(nsInt);

	}catch(Throwable any) {

	NBTTagCompound nsInt = new NBTTagCompound();
	nsInt.setBoolean(tag, value);	
	its.setTagCompound(nsInt);	

}}	



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

public int getItemEnchantability()
{
    return 1;
}
    
//#########################################################################3	
    
    
}

 

there is still this little one misbehavior

when using the bow it begins to swing the bow , but is not like the swing of the pickaxe  this is more like,

let say i have a rawMutton on slot 0 of the hotbar and a block of wool in the second slot

and i change from slot 0 to slot 2 the rawMutton goes down and the block of wool cames up,

i think this is the behaviour of changin json files but dont understand why is happen to my items but is not hapening in the vainilla bow change texture

 

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

    • I cannot find the answer anywhere public static void onPlayerConsumeXp(PlayerXpEvent.PickupXp event){ if(event.getEntity().getMainHandItem().getAllEnchantments().get(*value i need*) != null){ int shorthand = event.getEntity().getMainHandItem().getAllEnchantments().get(*value i need*); I am trying to get my custom enchant inside that *value i need*, I have tried using strings and Enchantments. does not show my enchantment. This is my enchantment class package net.test.tutorialmod.enchants; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentCategory; public class clever extends Enchantment { public clever(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { super(pRarity, pCategory, pApplicableSlots); } @Override public int getMaxLevel() { return 10; } @Override public int getMinLevel() { return 1; } }  What am i doing wrong?  
    • I had this same issue, it was one of the mods I had installed, some mods seem to break with certain versions of forge and cause others to break as well, trial and error different mods till you find the broken one.  
    • Hi, I'm asking for your help because I can't figure out how to make it so that when an item is crafted on the Crafting Table, it returns the item to the player's inventory and makes the item lose durability. I've tried looking everywhere without success. Like for the crafting of the cake which returns the empty bucket to the player, but also makes it lose durability.  
    • Description of issue: Tried to run MC client, crashing with java.lang.NoSuchFieldError. I Went into SRG fields, found that f_271198 does exist, but Forge thinks this field does not exist.   Crash Report: ---- Minecraft Crash Report ---- // I let you down. Sorry Time: 2024-02-22 09:21:29 Description: Mod loading error has occurred java.lang.Exception: Mod Loading has failed     at net.minecraftforge.logging.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:48) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading}     at net.minecraftforge.client.loading.ClientModLoader.completeModLoading(ClientModLoader.java:119) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.lambda$new$6(Minecraft.java:611) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.Util.ifElse(Util.java:432) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$new$7(Minecraft.java:602) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraftforge.client.loading.ForgeLoadingOverlay.render(ForgeLoadingOverlay.java:146) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading}     at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:931) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.runTick(Minecraft.java:1250) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.run(Minecraft.java:801) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:234) ~[forge-1.20.4-49.0.30_mapped_official_1.20.4.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:91) ~[fmlloader-1.20.4-49.0.30.jar:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.lambda$makeService$0(CommonLaunchHandler.java:75) ~[fmlloader-1.20.4-49.0.30.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) ~[modlauncher-10.1.2.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:74) ~[modlauncher-10.1.2.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:114) ~[modlauncher-10.1.2.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:73) ~[modlauncher-10.1.2.jar:?] {}     at cpw.mods.modlauncher.BootstrapEntry.main(BootstrapEntry.java:17) ~[modlauncher-10.1.2.jar:?] {}     at net.minecraftforge.bootstrap.Bootstrap.moduleMain(Bootstrap.java:97) ~[bootstrap-2.0.0.jar!/:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at net.minecraftforge.bootstrap.Bootstrap.start(Bootstrap.java:48) ~[bootstrap-2.0.0.jar!/:?] {}     at net.minecraftforge.bootstrap.ForgeBootstrap.main(ForgeBootstrap.java:18) ~[bootstrap-2.0.0.jar!/:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Suspected Mod:      Better Biomes (betterbiomes), Version: 0.1.4.3         at TRANSFORMER/betterbiomes@0.1.4.3/net.crypticverse.betterbiomes.util.BetterBiomeWoodTypes.<clinit>(BetterBiomeWoodTypes.java:8) Stacktrace:     at net.crypticverse.betterbiomes.util.BetterBiomeWoodTypes.<clinit>(BetterBiomeWoodTypes.java:8) ~[betterbiomes-forge-2.1.4.6-1.20.4.jar!/:2.1.4.6-1.20.4] {re:classloading} -- MOD betterbiomes -- Details:     Mod File: /C:/Users/myUser/BetterBiomes-Forge/run/mods/betterbiomes-forge-2.1.4.6-1.20.4.jar     Failure message: Better Biomes (betterbiomes) has failed to load correctly         java.lang.NoSuchFieldError: f_271198_     Mod Version: 0.1.4.3     Mod Issue URL: NOT PROVIDED     Exception message: java.lang.NoSuchFieldError: f_271198_ Stacktrace:     at net.crypticverse.betterbiomes.util.BetterBiomeWoodTypes.<clinit>(BetterBiomeWoodTypes.java:8) ~[main/:?] {re:classloading}     at net.crypticverse.betterbiomes.BetterBiomes.<init>(BetterBiomes.java:55) ~[main/:?] {re:classloading}     at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?] {}     at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?] {}     at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?] {}     at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:66) ~[javafmllanguage-1.20.4-49.0.30.jar!/:49.0.30] {}     at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$5(ModContainer.java:125) ~[fmlcore-1.20.4-49.0.30.jar!/:1.0] {}     at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?] {}     at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?] {}     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] {}     at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] {}     at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] {}     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] {}     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] {} -- System Details -- Details:     Minecraft Version: 1.20.4     Minecraft Version ID: 1.20.4     Operating System: Windows 10 (amd64) version 10.0     Java Version: 17.0.9, Eclipse Adoptium     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Eclipse Adoptium     Memory: 578548144 bytes (551 MiB) / 1128267776 bytes (1076 MiB) up to 8522825728 bytes (8128 MiB)     CPUs: 20     Processor Vendor: GenuineIntel     Processor Name: 12th Gen Intel(R) Core(TM) i7-12700K     Identifier: Intel64 Family 6 Model 151 Stepping 2     Microarchitecture: Alder Lake     Frequency (GHz): 3.61     Number of physical packages: 1     Number of physical CPUs: 12     Number of logical CPUs: 20     Graphics card #0 name: NVIDIA GeForce RTX 3070 Ti     Graphics card #0 vendor: NVIDIA (0x10de)     Graphics card #0 VRAM (MB): 4095.00     Graphics card #0 deviceId: 0x2482     Graphics card #0 versionInfo: DriverVersion=31.0.15.3699     Memory slot #0 capacity (MB): 16384.00     Memory slot #0 clockSpeed (GHz): 4.80     Memory slot #0 type: Unknown     Memory slot #1 capacity (MB): 16384.00     Memory slot #1 clockSpeed (GHz): 4.80     Memory slot #1 type: Unknown     Virtual memory max (MB): 37373.42     Virtual memory used (MB): 22391.79     Swap memory total (MB): 4864.00     Swap memory used (MB): 95.69     JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump     ModLauncher: 10.1.2     ModLauncher launch target: forge_userdev_client     ModLauncher naming: mcp     ModLauncher services:          / slf4jfixer PLUGINSERVICE          / runtimedistcleaner PLUGINSERVICE          / runtime_enum_extender PLUGINSERVICE          / object_holder_definalize PLUGINSERVICE          / capability_token_subclass PLUGINSERVICE          / accesstransformer PLUGINSERVICE          / eventbus PLUGINSERVICE          / mixin PLUGINSERVICE          / fml TRANSFORMATIONSERVICE          / mixin TRANSFORMATIONSERVICE      FML Language Providers:          lowcodefml@49         minecraft@1.0         javafml@49.0.30     Mod List:                                                            |Minecraft                     |minecraft                     |1.20.4              |COMMON_SET|Manifest: NOSIGNATURE         TerraBlender-forge-1.20.4-3.3.0.12_mapped_official|TerraBlender                  |terrablender                  |3.3.0.12            |COMMON_SET|Manifest: NOSIGNATURE                                                           |Forge                         |forge                         |49.0.30             |COMMON_SET|Manifest: NOSIGNATURE         betterbiomes-forge-2.1.4.6-1.20.4.jar             |Better Biomes                 |betterbiomes                  |0.1.4.3             |ERROR     |Manifest: NOSIGNATURE         Notebook-api-forge-1.20.4-1.1.0.4_mapped_official_|Notebook                      |notebook                      |1.1.0.4             |COMMON_SET|Manifest: NOSIGNATURE     Crash Report UUID: ad19c004-038a-4777-adbc-0504acf15d93     FML: 0.0     Forge: net.minecraftforge:49.0.30
  • Topics

×
×
  • Create New...

Important Information

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