Jump to content

[1.8] My sword texture isn't showing up! (Solved!)


JakeT24

Recommended Posts

:( My sword texture isn't showing, all it is is a giant purple and black checkered block going through me(ow! >:()!

 

SteelWeaponsMod.java <<< This is my main mod file.

package JakeT24.SteelModPlus;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
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;

@Mod(modid = "swm", name = "Steel Weapons Mod", version = "0.1")
public class SteelWeaponsMod {
   
public static ItemSword SteelSword;
public static Block SteelOre;
public static ToolMaterial SteelA = EnumHelper.addToolMaterial("Steel", 3, 999, 15.0F, 2.5F, 10);
@EventHandler
public void preInit(FMLPreInitializationEvent event){
    	SteelSword = (ItemSword) new SteelSword(SteelA).setUnlocalizedName("SteelSword");
    	SteelSword.setCreativeTab(CreativeTabs.tabCombat);
    	SteelSword.setMaxStackSize(1);
    	SteelOre = new SteelOre(Material.iron).setUnlocalizedName("SteelOre");
        SteelOre.setCreativeTab(CreativeTabs.tabBlock);
    	GameRegistry.registerItem(SteelSword, SteelSword.getUnlocalizedName().substring(5));
    	GameRegistry.registerBlock(SteelOre, SteelOre.getUnlocalizedName().substring(5));
    }
@EventHandler
    public void init(FMLInitializationEvent event){
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(SteelSword, 8000, new ModelResourceLocation("swm:item_SteelSword", "inventory"));
}
    @EventHandler
public void postInit(FMLPostInitializationEvent event){
    	
    }

}

 

SteelSword.json <<< This is my rendering .json file I have in assets/swm/models/items along with my SteelSword.png!

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "swm:items/SteelSword"
    },
    "display": {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}

Check out my mod- SteelMod++ and maybe we can support each other :)

Help me learn and some day I will be able to help you learn!

Link to comment
Share on other sites

Oh. and if you could tell me how to set it's tooltip that would be kool. And before you criticize me on how I'm not trying hard enough iv'e spent 8 hours of my day sitting hear with my laptop plugged into my TV trying to figure out Forge 1.8 and yes I did look for tutorials. Thats mostly how I got this far!

Check out my mod- SteelMod++ and maybe we can support each other :)

Help me learn and some day I will be able to help you learn!

Link to comment
Share on other sites

you need to reference a variable

How does:

SteelSword = (ItemSword) new SteelSword(SteelA).setUnlocalizedName("SteelSword");

not give you an error?

 

you need something like:

SteelSword mySword = (ItemSword) new SteelSword(SteelA).setUnlocalizedName("SteelSword")

 

and to add texture to your item you need something like this:

mySword.setTextureName(modid + ":" + name_of_your_file);

 

make sure you place your png file into the correct folder (assets/swm/textures/items)

Link to comment
Share on other sites

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(SteelSword, 8000, new ModelResourceLocation("swm:item_SteelSword", "inventory"));

should be changed to

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(SteelSword, 0, new ModelResourceLocation("swm:SteelSword", "inventory"));

 

Also, never capitalize the first letter of variables. Always capitalize the first letter of classes, though.

Link to comment
Share on other sites

Hey Thanks! This made my texture get flat and look like the normal non-textured item, which I was worried about. So now I have this problem, it still isn't showing the texture. But it is flat like it should be, just purple and black.

Check out my mod- SteelMod++ and maybe we can support each other :)

Help me learn and some day I will be able to help you learn!

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
  • Topics

×
×
  • Create New...

Important Information

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