Jump to content

[1.6.4] [SOLVED] Different Armor texture path?!


Recommended Posts

Posted

What must I change, that the texture for my armor will load from my folder and not from the 1.6.4.jar like Twilight Forest Mod do it.

 

Here is my code:

SCItem

public class SCItem 
{	
// creative tabs
public static CreativeTabs CreativeTabSCBlocks = new CreativeTabSCBlocks(CreativeTabs.getNextID(), "Building Blocks"){};
public static CreativeTabs CreativeTabSCMaterials = new CreativeTabSCMaterials(CreativeTabs.getNextID(), "Materials"){};
public static CreativeTabs CreativeTabSCFood = new CreativeTabSCFood(CreativeTabs.getNextID(), "Foodstuffs"){};
public static CreativeTabs CreativeTabSCTool = new CreativeTabSCTool(CreativeTabs.getNextID(), "Tools"){};
public static CreativeTabs CreativeTabSCCombat = new CreativeTabSCCombat(CreativeTabs.getNextID(), "Combat"){};

// Uranium armor
public static Item helmetUranium;
public static Item plateUranium;
public static Item legsUranium;
public static Item bootsUranium;

// Copper armor
public static Item helmetCopper;
public static Item plateCopper;
public static Item legsCopper;
public static Item bootsCopper;

// Unobtanium armor
public static Item helmetUnobtanium;
public static Item plateUnobtanium;
public static Item legsUnobtanium;
public static Item bootsUnobtanium;

// Enum Armor Material
    public static EnumArmorMaterial ARMOR_URANIUM = net.minecraftforge.common.EnumHelper.addArmorMaterial("URANIUM", 18, new int[] 
    {
    		2, 7, 5, 2
    }, 9);
    public static EnumArmorMaterial ARMOR_COPPER = net.minecraftforge.common.EnumHelper.addArmorMaterial("COPPER", 8, new int[] 
    {
    		2, 4, 3, 1
    }, 28);
    public static EnumArmorMaterial UNOBTANIUM = net.minecraftforge.common.EnumHelper.addArmorMaterial("UNOBTANIUM", 35, new int[]
    {
    		4, 10, 8, 4
    }, 12);
    
    public static EnumArmorMaterial Arnomr = EnumHelper.addArmorMaterial("Unob", 8, new int[] {2, 5, 6, 1}, 30);
    
    // renderer
    int uraniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/UraniumArmor_");
    int copperRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/CopperArmor_");
    int unobtaniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/UnobtaniumArmor_");

public SCItem()
{
// define uranium armor
	helmetUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemHelmetUranium, ARMOR_URANIUM, uraniumRenderID, 0)).setUnlocalizedName("helmetUranium");
	plateUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemPlateUranium, ARMOR_URANIUM, uraniumRenderID, 1)).setUnlocalizedName("plateUranium");
	legsUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemLegsUranium, ARMOR_URANIUM, uraniumRenderID, 2)).setUnlocalizedName("legsUranium");
	bootsUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemBootsUranium, ARMOR_URANIUM, uraniumRenderID, 3)).setUnlocalizedName("bootsUranium");

	// define copper armor
	helmetCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemHelmetCopper, ARMOR_COPPER, copperRenderID, 0)).setUnlocalizedName("helmetCopper");
	plateCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemPlateCopper, ARMOR_COPPER, copperRenderID, 1)).setUnlocalizedName("plateCopper");
	legsCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemLegsCopper, ARMOR_COPPER, copperRenderID, 2)).setUnlocalizedName("legsCopper");
	bootsCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemBootsCopper, ARMOR_COPPER, copperRenderID, 3)).setUnlocalizedName("bootsCopper");

	// define unobtanium armor
	helmetUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemHelmetUnobtanium, UNOBTANIUM, unobtaniumRenderID, 0)).setUnlocalizedName("helmetUnobtanium");
	plateUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemPlateUnobtanium, UNOBTANIUM, unobtaniumRenderID, 1)).setUnlocalizedName("plateUnobtanium");
	legsUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemLegsUnobtanium, UNOBTANIUM, unobtaniumRenderID, 2)).setUnlocalizedName("legsUnobtanium");
	bootsUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemBootsUnobtanium, UNOBTANIUM, unobtaniumRenderID, 3)).setUnlocalizedName("bootsUnobtanium");

	// register uranium armor
	registerSCItems(helmetUranium, "helmetUranium");
	registerSCItems(plateUranium, "plateUranium");
	registerSCItems(legsUranium, "legsUranium");
	registerSCItems(bootsUranium, "bootsUranium");

	// register copper armor
	registerSCItems(helmetCopper, "helmetCopper");
	registerSCItems(plateCopper, "plateCopper");
	registerSCItems(legsCopper, "legsCopper");
	registerSCItems(bootsCopper, "bootsCopper");

	// register unobtanium armor
	registerSCItems(helmetUnobtanium, "helmetUnobtanium");
	registerSCItems(plateUnobtanium, "plateUnobtanium");
	registerSCItems(legsUnobtanium, "legsUnobtanium");
	registerSCItems(bootsUnobtanium, "bootsUnobtanium");
}

// register items
private void registerSCItems(Item item, String englishName)
{
	GameRegistry.registerItem(item, item.getUnlocalizedName(), "serocraft");
}

ClientProxy

package minecraftplaye.serocraft;

import net.minecraft.client.renderer.entity.RenderBiped;
import minecraftplaye.serocraft.entity.EntitySCMutant;
import minecraftplaye.serocraft.entity.model.ModelSCMutant;
import minecraftplaye.serocraft.entity.render.RenderSCMutant;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class SCClientProxy extends SCCommonProxy
{
public SCClientProxy()
{
}

    public void doPreLoadRegistration()
    {
    	
    }
    
    public void registerRenderInformation()
    {
    	//RenderingRegistry.registerEntityRenderingHandler(EntityAngryBat.class, new RenderAngryBat());
    	RenderingRegistry.registerEntityRenderingHandler(EntitySCMutant.class, new RenderBiped(new ModelSCMutant(), 0.625F));
    }
    
public void doOnLoadRegistration()
{

}

public int registerArmorRenderID(String prefix)
{
	return RenderingRegistry.addNewArmourRendererPrefix(prefix);
}
}

CommonProxy

package minecraftplaye.serocraft;

import minecraftplaye.serocraft.entity.EntitySCMutant;
import cpw.mods.fml.common.registry.EntityRegistry;

public class SCCommonProxy 
{

public void doPreLoadRegistration() 
{

}

public void init()
{
	EntityRegistry.registerGlobalEntityID(EntitySCMutant.class, "Mutant", EntityRegistry.findGlobalUniqueEntityId(), 424313, 45131);
	//registerRenderInformation();
}

public void registerRenderInformation()
{
	// Nothing here as the server doesn't render graphics
}

public int registerArmorRenderID(String string) // registerArmorRenderID
{
	return 0;
}
}

ItemSCUnobtaniumArmor

package minecraftplaye.serocraft.items;

import minecraftplaye.serocraft.SeroCraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

public class ItemSCUnobtaniumArmor extends ItemArmor
{

public ItemSCUnobtaniumArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int renderIndex, int armorType) 
{
	super(par1, par2EnumArmorMaterial, renderIndex, armorType);
	this.setCreativeTab(SCItem.CreativeTabSCCombat);
}

    public String getArmorTextureFile(ItemStack itemstack, Entity entity, int slot, int layer)
    {
    	if (itemstack.itemID == SCItem.helmetUnobtanium.itemID || itemstack.itemID == SCItem.plateUnobtanium.itemID || itemstack.itemID == SCItem.bootsUnobtanium.itemID) 
    	{
    		//return "serocraft:UnobtaniumArmor_layer_1.png";
            //return SeroCraft.ARMOR_DIR + "UnobtaniumArmor_1.png";
    		return "serocraft:textures/armor/UnobtaniumArmor_1.png";
    	}
    	if (itemstack.itemID == SCItem.legsUnobtanium.itemID) 
    	{
    		//return "serocraft:UnobtaniumArmor_layer_2.png";
    		//return SeroCraft.ARMOR_DIR + "UnobtaniumArmor_2.png";
    		return "serocraft:textures/armor/UnobtaniumArmor_2.png";
    	} 
    	else
    	{
    		return "serocraft:textures/armor/UnobtaniumArmor_1.png";
    	}
    }
    
    public void registerIcons(IconRegister reg)
    { // Make sure to import IconRegister!
    	if (itemID == SCItem.plateUnobtanium.itemID)
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "plateUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}

    	if (itemID == SCItem.legsUnobtanium.itemID) 
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "legsUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}

    	if (itemID == SCItem.bootsUnobtanium.itemID) 
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "bootsUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}

    	if (itemID == SCItem.helmetUnobtanium.itemID) 
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "helmetUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}
    }
    
    public EnumRarity func_77613_e(ItemStack par1ItemStack)
    {
        return EnumRarity.uncommon;
    }
}

 

With this code, I get every time this error:

2014-01-09 19:38:51 [Warnung] [Minecraft-Client] Failed to load texture: minecraft:textures/models/armor/serocraft/UnobtaniumArmor__layer_1.png
java.io.FileNotFoundException: minecraft:textures/models/armor/serocraft/UnobtaniumArmor__layer_1.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:64)
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:63)
at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:31)
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:84)
at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:41)
at net.minecraft.client.renderer.entity.Render.bindTexture(Render.java:53)
at net.minecraft.client.renderer.entity.RenderPlayer.setArmorModel(RenderPlayer.java:72)
at net.minecraft.client.renderer.entity.RenderPlayer.shouldRenderPass(RenderPlayer.java:514)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRenderLiving(RendererLivingEntity.java:164)
at net.minecraft.client.renderer.entity.RenderPlayer.func_130009_a(RenderPlayer.java:166)
at net.minecraft.client.renderer.entity.RenderPlayer.doRender(RenderPlayer.java:556)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:312)
at net.minecraft.client.gui.inventory.GuiInventory.func_110423_a(GuiInventory.java:121)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:849)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:111)
at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:43)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:683)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1036)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:944)
at net.minecraft.client.Minecraft.run(Minecraft.java:836)
at net.minecraft.client.main.Main.main(Main.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
2014-01-09 19:38:51 [Warnung] [Minecraft-Client] Failed to load texture: minecraft:textures/models/armor/serocraft/UnobtaniumArmor__layer_2.png
java.io.FileNotFoundException: minecraft:textures/models/armor/serocraft/UnobtaniumArmor__layer_2.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:64)
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:63)
at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:31)
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:84)
at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:41)
at net.minecraft.client.renderer.entity.Render.bindTexture(Render.java:53)
at net.minecraft.client.renderer.entity.RenderPlayer.setArmorModel(RenderPlayer.java:72)
at net.minecraft.client.renderer.entity.RenderPlayer.shouldRenderPass(RenderPlayer.java:514)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRenderLiving(RendererLivingEntity.java:164)
at net.minecraft.client.renderer.entity.RenderPlayer.func_130009_a(RenderPlayer.java:166)
at net.minecraft.client.renderer.entity.RenderPlayer.doRender(RenderPlayer.java:556)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:312)
at net.minecraft.client.gui.inventory.GuiInventory.func_110423_a(GuiInventory.java:121)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:849)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:111)
at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:43)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:683)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1036)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:944)
at net.minecraft.client.Minecraft.run(Minecraft.java:836)
at net.minecraft.client.main.Main.main(Main.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

I hope that you can help me.

Developer of Primeval Forest.

Posted

That DOES help.  Here's your problem:

 

    int uraniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/UraniumArmor_");

    int copperRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/CopperArmor_");

    int unobtaniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/UnobtaniumArmor_");

 

Compare and contrast to

 

"serocraft:textures/armor/UnobtaniumArmor_1.png";

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Try this:

    int uraniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft:textures/armor/UraniumArmor");
    int copperRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft:textures/armor/CopperArmor");
    int unobtaniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft:textures/armor/UnobtaniumArmor");

 

The problem is that "_layer_#.png" is already added, so "serocraft/Armor_" makes Minecraft look for textures in "minecraft:textures/models/armor/serocraft/Armor__layer_#.png" (two underscores after "Armor").

 

Also, put your armor textures in "serocraft:textures/models/armor" rather than "serocraft:textures/armor". You might need to change some code here and there, but it helps with compatibility.

Before you even think about modding,

Posted

This won't work:

Failed to load texture: textures/models/armor/serocraft:textures/models/armor/UnobtaniumArmor_layer_1.png
Failed to load texture: textures/models/armor/serocraft:textures/models/armor/UnobtaniumArmor_layer_2.png

 

My code: (SCItem)

 

package minecraftplaye.serocraft.items;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionHelper;
import net.minecraftforge.common.EnumHelper;

import minecraftplaye.serocraft.SeroCraft;
import minecraftplaye.serocraft.config.SCConfigurationIDs;
import minecraftplaye.serocraft.helpers.creative.*;

public class SCItem 
{	

// Items
public static Item copperIngot;
public static Item uraniumPowder;
public static Item uraniumIngot;
public static Item smeltingglass;
public static Item unobtaniumIngot;
public static Item mutantFlesh;
public static Item lighter;

// creative tabs
public static CreativeTabs CreativeTabSCBlocks = new CreativeTabSCBlocks(CreativeTabs.getNextID(), "Building Blocks"){};
public static CreativeTabs CreativeTabSCMaterials = new CreativeTabSCMaterials(CreativeTabs.getNextID(), "Materials"){};
public static CreativeTabs CreativeTabSCFood = new CreativeTabSCFood(CreativeTabs.getNextID(), "Foodstuffs"){};
public static CreativeTabs CreativeTabSCTool = new CreativeTabSCTool(CreativeTabs.getNextID(), "Tools"){};
public static CreativeTabs CreativeTabSCCombat = new CreativeTabSCCombat(CreativeTabs.getNextID(), "Combat"){};

// Uranium tools and weapons
public static Item pickaxeUranium;
public static Item axeUranium;
public static Item spadeUranium;
public static Item hoeUranium;
public static Item swordUranium;

// Copper tools and weapons
public static Item pickaxeCopper;
public static Item axeCopper;
public static Item spadeCopper;
public static Item hoeCopper;
public static Item swordCopper;

// Unobtanium tools and weapons
public static Item pickaxeUnobtanium;
public static Item axeUnobtanium;
public static Item spadeUnobtanium;
public static Item hoeUnobtanium;
public static Item swordUnobtanium;

// Uranium armor
public static Item helmetUranium;
public static Item plateUranium;
public static Item legsUranium;
public static Item bootsUranium;

// Copper armor
public static Item helmetCopper;
public static Item plateCopper;
public static Item legsCopper;
public static Item bootsCopper;

// Unobtanium armor
public static Item helmetUnobtanium;
public static Item plateUnobtanium;
public static Item legsUnobtanium;
public static Item bootsUnobtanium;

// Enum Tool Material
public static EnumToolMaterial TOOL_URANIUM = net.minecraftforge.common.EnumHelper.addToolMaterial("URANIUM", 2, 250, 6.5F, 1, 10);
public static EnumToolMaterial TOOL_Copper = net.minecraftforge.common.EnumHelper.addToolMaterial("COPPER", 0, 36, 12.0F, 0, 22);
public static EnumToolMaterial TOOL_UNOBTANIUM = net.minecraftforge.common.EnumHelper.addToolMaterial("UNOBTANIUM", 4, 1600, 8.5F, 4, 12);

// Enum Armor Material
    public static EnumArmorMaterial ARMOR_URANIUM = net.minecraftforge.common.EnumHelper.addArmorMaterial("URANIUM", 18, new int[] 
    {
    		2, 7, 5, 2
    }, 9);
    public static EnumArmorMaterial ARMOR_COPPER = net.minecraftforge.common.EnumHelper.addArmorMaterial("COPPER", 8, new int[] 
    {
    		2, 4, 3, 1
    }, 28);
    public static EnumArmorMaterial UNOBTANIUM = net.minecraftforge.common.EnumHelper.addArmorMaterial("UNOBTANIUM", 35, new int[]
    {
    		4, 10, 8, 4
    }, 12);
    
    public static EnumArmorMaterial Arnomr = EnumHelper.addArmorMaterial("Unob", 8, new int[] {2, 5, 6, 1}, 30);
    
    // renderer
    //int uraniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/UraniumArmor_");
    //int copperRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/CopperArmor_");
    //int unobtaniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft/UnobtaniumArmor_");
    int uraniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft:textures/models/armor/UraniumArmor");
    int copperRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft:textures/models/armor/CopperArmor");
    int unobtaniumRenderID = SeroCraft.proxy.registerArmorRenderID("serocraft:textures/models/armor/UnobtaniumArmor");
    
public SCItem()
{
	// define Items
	copperIngot = new ItemSC(SCConfigurationIDs.idItemCopperIngot).setCreativeTab(SCItem.CreativeTabSCMaterials).setUnlocalizedName("copperIngot");
	uraniumPowder = new ItemSC(SCConfigurationIDs.idItemUraniumDust).setCreativeTab(SCItem.CreativeTabSCMaterials).setUnlocalizedName("uraniumPowder");
	uraniumIngot = new ItemSC(SCConfigurationIDs.idItemUraniumIngot).setCreativeTab(SCItem.CreativeTabSCMaterials).setUnlocalizedName("uraniumIngot");
	smeltingglass = new ItemSC(SCConfigurationIDs.idItemSmeltingglass).setCreativeTab(SCItem.CreativeTabSCMaterials).setUnlocalizedName("smeltingglass");
	unobtaniumIngot = new ItemSC(SCConfigurationIDs.idItemUnobtaniumIngot).setCreativeTab(SCItem.CreativeTabSCMaterials).setUnlocalizedName("unobtaniumIngot");
	mutantFlesh = (new ItemSCFood(SCConfigurationIDs.idItemMutantFlesh, -6, 0.9F, false)).setPotionEffect(Potion.poison.id, 600, 3, 9.0F).setPotionEffect(PotionHelper.spiderEyeEffect).setUnlocalizedName("mutantFlesh");
	lighter = new ItemSCLighter(SCConfigurationIDs.idItemSCLighter).setUnlocalizedName("lighter");

	// define uranium tools and weapons
	pickaxeUranium = (new ItemSCPick(SCConfigurationIDs.idItemUraniumPick, TOOL_URANIUM)).setMaxStackSize(1).setUnlocalizedName("pickaxeUranium");
	axeUranium = (new ItemSCAxe(SCConfigurationIDs.idItemUraniumAxe, TOOL_URANIUM)).setMaxStackSize(1).setUnlocalizedName("axeUranium");
	spadeUranium = (new ItemSCSpade(SCConfigurationIDs.idItemUraniumSpade, TOOL_URANIUM)).setMaxStackSize(1).setUnlocalizedName("spadeUranium");
	hoeUranium = (new ItemSCHoe(SCConfigurationIDs.idItemUraniumHoe, TOOL_URANIUM)).setMaxStackSize(1).setUnlocalizedName("hoeUranium");
	swordUranium = (new ItemSCSword(SCConfigurationIDs.idItemUraniumSword, TOOL_URANIUM)).setMaxStackSize(1).setUnlocalizedName("swordUranium");

	// define copper tools and weapons
	pickaxeCopper = (new ItemSCPick(SCConfigurationIDs.idItemCopperPick, TOOL_Copper)).setMaxStackSize(1).setUnlocalizedName("pickaxeCopper");
	axeCopper = (new ItemSCAxe(SCConfigurationIDs.idItemCopperAxe, TOOL_Copper)).setMaxStackSize(1).setUnlocalizedName("axeCopper");
	spadeCopper = (new ItemSCSpade(SCConfigurationIDs.idItemCopperSpade, TOOL_Copper)).setMaxStackSize(1).setUnlocalizedName("spadeCopper");
	hoeCopper = (new ItemSCHoe(SCConfigurationIDs.idItemCopperHoe, TOOL_Copper)).setMaxStackSize(1).setUnlocalizedName("hoeCopper");
	swordCopper = (new ItemSCSword(SCConfigurationIDs.idItemCopperSword, TOOL_Copper)).setMaxStackSize(1).setUnlocalizedName("swordCopper");

	// define unobtanium tools and weapons
	pickaxeUnobtanium = (new ItemSCPick(SCConfigurationIDs.idItemUnobtaniumPick, TOOL_UNOBTANIUM)).setMaxStackSize(1).setUnlocalizedName("pickaxeUnobtanium");
	axeUnobtanium = (new ItemSCAxe(SCConfigurationIDs.idItemUnobtaniumAxe, TOOL_UNOBTANIUM)).setMaxStackSize(1).setUnlocalizedName("axeUnobtanium");
	spadeUnobtanium = (new ItemSCSpade(SCConfigurationIDs.idItemUnobtaniumSpade, TOOL_UNOBTANIUM)).setMaxStackSize(1).setUnlocalizedName("spadeUnobtanium");
	hoeUnobtanium = (new ItemSCHoe(SCConfigurationIDs.idItemUnobtaniumHoe, TOOL_UNOBTANIUM)).setMaxStackSize(1).setUnlocalizedName("hoeUnobtanium");
	swordUnobtanium = (new ItemSCSword(SCConfigurationIDs.idItemUnobtaniumSword, TOOL_UNOBTANIUM)).setMaxStackSize(1).setUnlocalizedName("swordUnobtanium");

	// define uranium armor
	helmetUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemHelmetUranium, ARMOR_URANIUM, uraniumRenderID, 0)).setUnlocalizedName("helmetUranium");
	plateUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemPlateUranium, ARMOR_URANIUM, uraniumRenderID, 1)).setUnlocalizedName("plateUranium");
	legsUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemLegsUranium, ARMOR_URANIUM, uraniumRenderID, 2)).setUnlocalizedName("legsUranium");
	bootsUranium = (new ItemSCUraniumArmor(SCConfigurationIDs.idItemBootsUranium, ARMOR_URANIUM, uraniumRenderID, 3)).setUnlocalizedName("bootsUranium");

	// define copper armor
	helmetCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemHelmetCopper, ARMOR_COPPER, copperRenderID, 0)).setUnlocalizedName("helmetCopper");
	plateCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemPlateCopper, ARMOR_COPPER, copperRenderID, 1)).setUnlocalizedName("plateCopper");
	legsCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemLegsCopper, ARMOR_COPPER, copperRenderID, 2)).setUnlocalizedName("legsCopper");
	bootsCopper = (new ItemSCCopperArmor(SCConfigurationIDs.idItemBootsCopper, ARMOR_COPPER, copperRenderID, 3)).setUnlocalizedName("bootsCopper");

	// define unobtanium armor
	helmetUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemHelmetUnobtanium, UNOBTANIUM, unobtaniumRenderID, 0)).setUnlocalizedName("helmetUnobtanium");
	plateUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemPlateUnobtanium, UNOBTANIUM, unobtaniumRenderID, 1)).setUnlocalizedName("plateUnobtanium");
	legsUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemLegsUnobtanium, UNOBTANIUM, unobtaniumRenderID, 2)).setUnlocalizedName("legsUnobtanium");
	bootsUnobtanium = (new ItemSCUnobtaniumArmor(SCConfigurationIDs.idItemBootsUnobtanium, UNOBTANIUM, unobtaniumRenderID, 3)).setUnlocalizedName("bootsUnobtanium");

	// rendering Armor on players body
	//RenderingRegistry.addNewArmourRendererPrefix("ARMOR_URANIUM");
	//RenderingRegistry.addNewArmourRendererPrefix("ARMOR_COPPER");
	//RenderingRegistry.addNewArmourRendererPrefix("ARMOR_UNOBTANIUM");

	// register Items
	registerSCItems(copperIngot, "copperIngot");
	registerSCItems(uraniumPowder, "uraniumDust");
	registerSCItems(uraniumIngot, "uraniumIngot");
	registerSCItems(unobtaniumIngot, "unobtaniumIngot");
	registerSCItems(smeltingglass, "smeltingglass");
	registerSCItems(mutantFlesh, "mutantFlesh");
	registerSCItems(lighter, "lighter");

	// register uranium tools and weapons
	registerSCItems(pickaxeUranium, "pickaxeUranium");
	registerSCItems(axeUranium, "axeUranium");
	registerSCItems(spadeUranium, "spadeUranium");
	registerSCItems(hoeUranium, "hoeUranium");
	registerSCItems(swordUranium, "swordUranium");

	// register copper tools and weapons
	registerSCItems(pickaxeCopper, "pickaxeCopper");
	registerSCItems(axeCopper, "axeCopper");
	registerSCItems(spadeCopper, "spadeCopper");
	registerSCItems(hoeCopper, "hoeCopper");
	registerSCItems(swordCopper, "swordCopper");

	// register unobtanium tools and weapons
	registerSCItems(pickaxeUnobtanium, "pickaxeUnobtanium");
	registerSCItems(axeUnobtanium, "axeUnobtanium");
	registerSCItems(spadeUnobtanium, "spadeUnobtanium");
	registerSCItems(hoeUnobtanium, "hoeUnobtanium");
	registerSCItems(swordUnobtanium, "swordUnobtanium");

	// register uranium armor
	registerSCItems(helmetUranium, "helmetUranium");
	registerSCItems(plateUranium, "plateUranium");
	registerSCItems(legsUranium, "legsUranium");
	registerSCItems(bootsUranium, "bootsUranium");

	// register copper armor
	registerSCItems(helmetCopper, "helmetCopper");
	registerSCItems(plateCopper, "plateCopper");
	registerSCItems(legsCopper, "legsCopper");
	registerSCItems(bootsCopper, "bootsCopper");

	// register unobtanium armor
	registerSCItems(helmetUnobtanium, "helmetUnobtanium");
	registerSCItems(plateUnobtanium, "plateUnobtanium");
	registerSCItems(legsUnobtanium, "legsUnobtanium");
	registerSCItems(bootsUnobtanium, "bootsUnobtanium");

	Language_en_US();
	Language_de_DE();
}

public void Language_en_US()
{
	LanguageRegistry.instance().addNameForObject(lighter, "en_US", "Lighter - \u00a74Only to create a portal!");
	LanguageRegistry.instance().addNameForObject(uraniumPowder, "en_US", "\u00a7aUranium Dust");
}

public void Language_de_DE()
{
	LanguageRegistry.instance().addNameForObject(lighter, "de_DE", "Feuerzeug - \u00a74Nur zum erstellen eines Portals!");
	LanguageRegistry.instance().addNameForObject(uraniumPowder, "de_DE", "\u00a7aUranstaub");
}

    // register items
private void registerSCItems(Item item, String englishName)
{
	GameRegistry.registerItem(item, item.getUnlocalizedName(), "serocraft");
}
}

 

 

ItemSCUnobtaniumArmor

 

 

package minecraftplaye.serocraft.items;

import minecraftplaye.serocraft.SeroCraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

public class ItemSCUnobtaniumArmor extends ItemArmor
{

public ItemSCUnobtaniumArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int renderIndex, int armorType) 
{
	super(par1, par2EnumArmorMaterial, renderIndex, armorType);
	this.setCreativeTab(SCItem.CreativeTabSCCombat);
}

    public String getArmorTextureFile(ItemStack itemstack, Entity entity, int slot, int layer)
    {
    	if (itemstack.itemID == SCItem.helmetUnobtanium.itemID || itemstack.itemID == SCItem.plateUnobtanium.itemID || itemstack.itemID == SCItem.bootsUnobtanium.itemID) 
    	{
    		//return "serocraft:UnobtaniumArmor_layer_1.png";
            //return SeroCraft.ARMOR_DIR + "UnobtaniumArmor_1.png";
    		return "serocraft:textures/models/armor/UnobtaniumArmor_1.png";
    	}
    	if (itemstack.itemID == SCItem.legsUnobtanium.itemID) 
    	{
    		//return "serocraft:UnobtaniumArmor_layer_2.png";
    		//return SeroCraft.ARMOR_DIR + "UnobtaniumArmor_2.png";
    		return "serocraft:textures/models/armor/UnobtaniumArmor_2.png";
    	} 
    	else
    	{
    		return "serocraft:textures/models/armor/UnobtaniumArmor_1.png";
    	}
    }
    
    public void registerIcons(IconRegister reg)
    { // Make sure to import IconRegister!
    	if (itemID == SCItem.plateUnobtanium.itemID)
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "plateUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}

    	if (itemID == SCItem.legsUnobtanium.itemID) 
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "legsUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}

    	if (itemID == SCItem.bootsUnobtanium.itemID) 
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "bootsUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}

    	if (itemID == SCItem.helmetUnobtanium.itemID) 
    	{
    		this.itemIcon = reg.registerIcon(SeroCraft.modid + ":" + "helmetUnobtanium"); // You can also replace blockID and blockIcon with itemID and itemIcon
    	}
    }
    
    public EnumRarity func_77613_e(ItemStack par1ItemStack)
    {
        return EnumRarity.uncommon;
    }
}

 

 

SCClientProxy

 

package minecraftplaye.serocraft;

import net.minecraft.client.renderer.entity.RenderBiped;
import minecraftplaye.serocraft.entity.EntitySCMutant;
import minecraftplaye.serocraft.entity.model.ModelSCMutant;
import minecraftplaye.serocraft.entity.render.RenderSCMutant;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class SCClientProxy extends SCCommonProxy
{
public SCClientProxy()
{
}

    public void doPreLoadRegistration()
    {
    	
    }
    
    public void registerRenderInformation()
    {
    	//RenderingRegistry.registerEntityRenderingHandler(EntityAngryBat.class, new RenderAngryBat());
    	RenderingRegistry.registerEntityRenderingHandler(EntitySCMutant.class, new RenderBiped(new ModelSCMutant(), 0.625F));
    }
    
public void doOnLoadRegistration()
{

}

public int registerArmorRenderID(String prefix)
{
	return RenderingRegistry.addNewArmourRendererPrefix(prefix);
}
}

 

 

SCCommonProxy

 

package minecraftplaye.serocraft;

import minecraftplaye.serocraft.entity.EntitySCMutant;
import cpw.mods.fml.common.registry.EntityRegistry;

public class SCCommonProxy 
{

public void doPreLoadRegistration() 
{

}

public void init()
{
	EntityRegistry.registerGlobalEntityID(EntitySCMutant.class, "Mutant", EntityRegistry.findGlobalUniqueEntityId(), 424313, 45131);
	//registerRenderInformation();
}

public void registerRenderInformation()
{
	// Nothing here as the server doesn't render graphics
}

public int registerArmorRenderID(String string) // registerArmorRenderID
{
	return 0;
}
}

 

 

I hope that this will help you.

Developer of Primeval Forest.

Posted

Looking over my own code, I'm pretty sure I know what's the problem. But before we get fixing, change your render IDs:

    int uraniumRenderID = SeroCraft.proxy.registerArmorRenderID(ARMOR_URANIUM.name());
    int copperRenderID = SeroCraft.proxy.registerArmorRenderID(ARMOR_COPPER.name());
    int unobtaniumRenderID = SeroCraft.proxy.registerArmorRenderID(UNOBTANIUM.name());

 

You have to change them again because

RenderingRegistry.addNewArmourRendererPrefix

(which is in your client proxy) adds an armor prefix to the string array

RenderBiped.bipedArmorFilenamePrefix

.

bipedArmorFilenamePrefix

is defined as an array of armor type strings (

new String[] {"leather", "chainmail", "iron", "diamond", "gold"}

), so your code should register armor type strings, rather than texture paths, when using

SeroCraft.proxy.registerArmorRenderID

.

 

Now getting to the actual fixing, change

public String getArmorTextureFile(ItemStack itemstack, Entity entity, int slot, int layer)

to

public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, int layer)

. This is in the armor class (e.g. ItemSCUnobtaniumArmor).

Before you even think about modding,

Posted

Looking over my own code, I'm pretty sure I know what's the problem. But before we get fixing, change your render IDs:

    int uraniumRenderID = SeroCraft.proxy.registerArmorRenderID(ARMOR_URANIUM.name());
    int copperRenderID = SeroCraft.proxy.registerArmorRenderID(ARMOR_COPPER.name());
    int unobtaniumRenderID = SeroCraft.proxy.registerArmorRenderID(UNOBTANIUM.name());

 

You have to change them again because

RenderingRegistry.addNewArmourRendererPrefix

(which is in your client proxy) adds an armor prefix to the string array

RenderBiped.bipedArmorFilenamePrefix

.

bipedArmorFilenamePrefix

is defined as an array of armor type strings (

new String[] {"leather", "chainmail", "iron", "diamond", "gold"}

), so your code should register armor type strings, rather than texture paths, when using

SeroCraft.proxy.registerArmorRenderID

.

 

Now getting to the actual fixing, change

public String getArmorTextureFile(ItemStack itemstack, Entity entity, int slot, int layer)

to

public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, int layer)

. This is in the armor class (e.g. ItemSCUnobtaniumArmor).

 

That fixed everything. :D

Thanks...

Developer of Primeval Forest.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

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

×
×
  • Create New...

Important Information

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