Jump to content

Recommended Posts

Posted

I have some problem with creating a new Armor with Forge ...

Everythings works fine except for the .itemID error it gives me

for some reason inside the SapphireArmor.java

I can't fix it myself so I hope someone can help me  :(

 

Just in case the mod_file etc. is needed, I will post them too

 

 

SapphireHelmet.itemID

SapphireChest.itemID

SapphirePants.itemID

SapphireBoots.itemID

These .itemID gives the error

 

SapphireArmor.java

package modding.morematerials;

import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;

public class SapphireArmor extends ItemArmor implements IArmorTextureProvider{

public SapphireArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial,
		int par3, int par4) {
	super(par1, par2EnumArmorMaterial, par3, par4);
}

@Override
public String getArmorTextureFile(ItemStack itemstack) {
	if(itemstack.itemID == mod_MainClass.SapphireHelmet.itemID || itemstack.itemID == mod_MainClass.SapphireChest.itemID || itemstack.itemID == mod_MainClass.SapphireBoots.itemID){
		return "/MoreMaterials/Armor/Sapphire_1.png";
	}
	if(itemstack.itemID == mod_MainClass.SapphirePants.itemID){
		return "/MoreMaterials/Armor/Sapphire_2.png";
	}
	else return "/MoreMaterials/Armor/Sapphire_2.png";
}

public String getTextureFile(){
	return"/MoreMaterials/Items.png";
}
}

 

mod_MainClass.java

package modding.morematerials;

import net.minecraft.block.Block;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Item;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;


@Mod(modid = "morematerials", name = "More Materials", version = "1.4.7")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class mod_MainClass {

private static final EnumArmorMaterial SapphireArmorMaterial = null;
private static final String SapphireArmor = null;
@SidedProxy(clientSide = "modding.morematerials.ClientProxy", serverSide = "modding.morematerials.ServerProxy")
public static ServerProxy proxy;
//Ore
public static Block SapphireOre;
public static Block TopazOre;
public static Block AmethystOre;
public static Block RubyOre;

//Blocks
public static Block SapphireBlock;
public static Block TopazBlock;
public static Block AmethystBlock;
public static Block RubyBlock;

//Armor
public static Item SapphireHelmet;
public static Item SapphireChest;
public static Item SapphirePants;
public static Item SapphireBoots;

//Item

@PreInit	
public void load(FMLPreInitializationEvent Preevent){

}

@Init
public void load(FMLInitializationEvent event){
proxy.registerRenderThings();
proxy.registerServerTickHandler();
//Ore
SapphireOre = new SapphireOre (504, 16).setHardness(1.5F).setResistance(10.0F).setBlockName("SaphOre");
TopazOre = new TopazOre (505, 17).setHardness(1.5F).setResistance(10.0F).setBlockName("TopaOre");
RubyOre = new RubyOre (506, 18).setHardness(1.5F).setResistance(10.0F).setBlockName("RubOre");
AmethystOre = new AmethystOre (507, 19).setHardness(1.5F).setResistance(10.0F).setBlockName("AmetOre");

//Block
SapphireBlock = new SapphireBlock (500, 0).setHardness(1.5F).setResistance(10.0F).setBlockName("SaphBlock");
TopazBlock = new TopazBlock (501, 1).setHardness(1.5F).setResistance(10.0F).setBlockName("TopaBlock");
RubyBlock = new RubyBlock (502, 2).setHardness(1.5F).setResistance(10.0F).setBlockName("RubBlock");
AmethystBlock = new AmethystBlock (503, 3).setHardness(1.5F).setResistance(10.0F).setBlockName("AmetBlock");

//Item
SapphireHelmet = (Item) new SapphireArmor(4000, SapphireArmorMaterial, proxy.addArmor(SapphireArmor), 0).setItemName("Sapphire Helmet").setIconIndex(0);
SapphireChest = (Item) new SapphireArmor(4001, SapphireArmorMaterial, proxy.addArmor(SapphireArmor), 1).setItemName("Sapphire Chestplate").setIconIndex(0);
SapphirePants = (Item) new SapphireArmor(4002, SapphireArmorMaterial, proxy.addArmor(SapphireArmor), 2).setItemName("Sapphire Leggings").setIconIndex(0);
SapphireBoots = (Item) new SapphireArmor(4003, SapphireArmorMaterial, proxy.addArmor(SapphireArmor), 3).setItemName("Sapphire Boots").setIconIndex(0);

//EnumArmorMaterial
EnumArmorMaterial SapphireArmorMaterial = EnumHelper.addArmorMaterial("Sapphire_Armor", 22, new int[] {3, 6, 4, 3}, 14);

//Armor

//EnumToolMaterial

//Tools

//Registry
GameRegistry.registerBlock(SapphireBlock, "Saph_Block");
GameRegistry.registerBlock(TopazBlock, "Topa_Block");
GameRegistry.registerBlock(AmethystBlock, "Amet_Block");
GameRegistry.registerBlock(RubyBlock, "Rub_Block");
GameRegistry.registerBlock(SapphireOre, "Saph_Ore");
GameRegistry.registerBlock(TopazOre, "Topa_Ore");
GameRegistry.registerBlock(AmethystOre, "Amet_Ore");
GameRegistry.registerBlock(RubyOre, "Rub_Ore");

//Harvest Level
MinecraftForge.setBlockHarvestLevel(SapphireOre, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(TopazOre, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(AmethystOre, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(RubyOre, "pickaxe", 2);

//Name
LanguageRegistry.addName(SapphireBlock, "Sapphire Block");
LanguageRegistry.addName(TopazBlock, "Topaz Block");
LanguageRegistry.addName(AmethystBlock, "Amethyst Block");
LanguageRegistry.addName(RubyBlock, "Ruby Block");
LanguageRegistry.addName(SapphireOre, "Sapphire Ore");
LanguageRegistry.addName(TopazOre, "Topaz Ore");
LanguageRegistry.addName(AmethystOre, "Amethyst Ore");
LanguageRegistry.addName(RubyOre, "Ruby Ore");
LanguageRegistry.addName(SapphireHelmet, "Sapphire Helmet");
LanguageRegistry.addName(SapphireChest, "Sapphire Chestplate");
LanguageRegistry.addName(SapphirePants, "Sapphire Leggings");
LanguageRegistry.addName(SapphireBoots, "Sapphire Boots");
}

}

 

ClientProxy.java

package modding.morematerials;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient;

public class ClientProxy extends ServerProxy{

@Override 
public void registerRenderThings(){
	MinecraftForgeClient.preloadTexture("/MoreMaterials/Blocks.png");
	MinecraftForgeClient.preloadTexture("/MoreMaterials/Items.png");

}

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

 

ServerProxy.java

package modding.morematerials;

import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;

public class ServerProxy {

public void registerRenderThings(){

}

public void registerServerTickHandler(){
	TickRegistry.registerTickHandler(new ServerTickHandler(), Side.SERVER);
}

public int addArmor(String Armor) {
	return 0;
}
}

Posted

here is my armor plate code, this DEFINITELY works, all you have to do to change it to boots and such is change the class name.

package ashtonsmod.common;

import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;

public class ObsidianPlate extends ItemArmor implements IArmorTextureProvider{

        public ObsidianPlate(int par1,EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) {
                super(par1, par2EnumArmorMaterial, par3, par4);

        }
    	@Override
    	public String getTextureFile(){
    		return CommonProxy.items_png;
               
        }

        public String getArmorTextureFile(ItemStack par1){
                if ( par1.itemID==ashtonsmod.ObsidianHelmet.shiftedIndex|| par1.itemID==ashtonsmod.ObsidianPlate.shiftedIndex||
                                 par1.itemID==ashtonsmod.ObsidianBoots.shiftedIndex){
                        return "/armor/ObsidianArmor_1.png";
                }if(par1.itemID==ashtonsmod.ObsidianLegs.shiftedIndex){
                        return "/armor/ObsidianArmor_2.png";
                }return "/armor/ObsidianArmor_2.png";
        }
       

     

     

     

}

Use examples, i have aspergers.

Examples make sense to me.

Posted

Well .... Didn't worked too .... Seems like there has to be something wrong in one of the other .java files >__<

 

Edit: Since there has to be something wrong I will make a completly new modding folder and try it again and well ... maybe it doesnt give me an error then :/ Did the same as in the Tutorials and still that error -__-

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

    • 1) Update to the latest build of Forge for your MC version. The recommended build actually means minimum recommended. I can’t remember if it was backported to 1.20.1 or not, but we did clean up the early loading screen a bit in newer builds to look less cluttered. 2) Change the accessibility setting in game to black background. The early loading screen will then be black instead of red.
    • I'm sure this entire community knows exactly who you are, what mixin you're talking about, and how deer function in minecraft.  But being new here, and I am ignorant about all of those things. That said, I'd love to review your mixin.  I'm also having mixin issues, and I feel that if I can help you, perhaps both of our problems might get solved. Can you provide some links and context for people who aren't aware of your renown?  I'm asking humbly because I know you probably have better things to do, and you just want somebody to fix things for you.
    • I am working in the latest MDK.  Minecraft 1.21.4, Forge 54.1.0. I am trying to create a mixin.  The implementation doesn't matter.  Assume it is doing nothing more than logging to the console: @Mixin(LevelRenderer.class) public abstract class LevelRendererMixin { private static final Logger LOGGER = LogManager.getLogger("LevelRendererMixin"); @Inject(method = "renderLevel", at = @At("TAIL")) private void onRenderLevel( com.mojang.blaze3d.resource.GraphicsResourceAllocator allocator, net.minecraft.client.DeltaTracker deltaTracker, boolean someFlag, Camera camera, GameRenderer gameRenderer, Matrix4f matrix1, Matrix4f matrix2, CallbackInfo ci ) { Assuming my whole implementation is just to write something to console, it works perfectly fine in when I debug (runClient) in IntelliJ.  Whenever the Minecraft `renderLevel` runs every frame, my logging is overlaid at "TAIL". Yes, this spams the sht out of the console. But when I `build` and use the jar as a mod, it does not.  The mixin annotation processor shows to be loading, and my other parts of my mod work, but the nothing gets logged by my mixin. I am apparently generating a proper `refmap` and it's in the jar root.  Other files are also in the jar appropriately, including mods.toml.  And all the naming and reference paths are correct. I had to add this to my build.gradle to get my refmap into the jar ([name] obviously replaced): tasks.register("copyRefmap", Copy) { dependsOn tasks.named("compileJava") from("${project.buildDir}/tmp/compileJava") { include "mixins.[name].refmap.json" } into("${project.buildDir}/resources/main") } tasks.named("processResources", ProcessResources).configure { dependsOn(tasks.named("copyRefmap")) } tasks.named("jar", Jar).configure { // Include the generated refmap from build/resources/main into the jar. from("${project.buildDir}/resources/main") { include "mixins.[name].refmap.json" } }   Just for fun, here is my refmap in case something looks wrong to anybody:   { "mappings": { "com/[name]/mixin/LevelRendererMixin": { "renderLevel": "Lnet/minecraft/client/renderer/LevelRenderer;m_109599_(Lcom/mojang/blaze3d/resource/GraphicsResourceAllocator;Lnet/minecraft/client/DeltaTracker;ZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V" } }, "data": { "searge": { "com/[name]/mixin/LevelRendererMixin": { "renderLevel": "Lnet/minecraft/client/renderer/LevelRenderer;m_109599_(Lcom/mojang/blaze3d/resource/GraphicsResourceAllocator;Lnet/minecraft/client/DeltaTracker;ZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V" } } } } TLDR; My mixin works in dev, but not when built and run in an official Forge/Minecraft environment.  Like it's not overlaying/replacing the minecraft function. What are some typical other things to check when a mixin works in dev, but not after build?
    • Thank you, Ugdhar.  But that only confirms the problem.  Both in the github and in my IDE, if I search for objects extended from net.minecraftforge.client.event, it isn't there.  Though the javadocs (at least at nekoyue) say it should be. Maybe since it definitely isn't there, is there some other way anybody knows to highlight some blocks (without mixins and drawing artificial faces on the camera).
  • Topics

×
×
  • Create New...

Important Information

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