Jump to content

Can't manage to give a texture to a block


traxys

Recommended Posts

I am at the very starting point of moding, I managed to "make" a block , but I can't manage to give it a texture

 

I loooked on pahimar(youtube) tutorials for the begining , so I have the basic stucture he showed , but since he did not post any video , I tried to do somethings my self.

 

So here is my code :

 

First: structure :

 

Ininity bows

  |

  |---common

  |        |

  |        |-------traxys.infbow

  |        |                    |

  |        |                    |---------IninityBow.java

  |        |                     

  |        |-------traxys.infbow.lib       

  |        |                    |

  |        |                    |---------GenBlock.java

  |        |                    |

  |        |                    |---------Reference.java

  |        |

  |        |-------traxys.infbow.proxy(there are two java files , (ckient & common proxy) but there are nearly blank)

  |        |

  |        |-------mcmod.info

  |        |

  |        |-------pack.mcmeta

  |

  |---Ressources

              |

              |------assets.infbow.lang(empty)

              |

              |------assets.infbow.textures.blocks

              |                    |

              |                    |---------hardWall.png(a 16*16 file)

              |

              |------assets.infbow.textures.item(also empty)

 

Here are my codes :

InfinityBow.java

 

 

package traxys.infbow;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraftforge.common.MinecraftForge;

import traxys.infbow.lib.GenBlock;

import traxys.infbow.lib.Reference;

import traxys.infbow.proxy.CommonProxy;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

@Mod(modid= Reference.MOD_ID, name= Reference.MOD_NAME, version = Reference.VERSION)

public class InfinityBow {

 

public static Block hardWall;

 

@Instance(Reference.MOD_ID)

public static InfinityBow instance;

 

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)

public static CommonProxy proxy;

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

hardWall = new GenBlock(1048, Material.rock)

.setHardness(55.0F).setResistance(2050.0F).setStepSound(Block.soundStoneFootstep)

.setUnlocalizedName("hardWall").setCreativeTab(CreativeTabs.tabBlock)

.setTextureName("generic:hardWall");

}

 

@EventHandler

public void init(FMLInitializationEvent event){

LanguageRegistry.addName(hardWall, "Hard Wall");

MinecraftForge.setBlockHarvestLevel(hardWall, "pickaxe", 3);

GameRegistry.registerBlock(hardWall, "Hard Wall");

}

@EventHandler

public void postInit(FMLPostInitializationEvent event){

 

}

 

}

 

 

GenBlock.java

 

 

package traxys.infbow.lib;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

 

public class GenBlock extends Block {

 

public GenBlock(int par1, Material par2Material) {

super(par1, par2Material);

}

}

 

 

Reference.java

 

 

package traxys.infbow.lib;

 

public class Reference {

 

public static final String MOD_ID ="InfBow";

public static final String MOD_NAME ="Infinity Bows";

public static final String VERSION ="0.0.1";

 

public static final String SERVER_PROXY_CLASS ="traxys.infbow.proxy.CommonProxy";

public static final String CLIENT_PROXY_CLASS ="traxys.infbow.proxy.ClientProxy";

}

 

 

pack.mcmeta

 

 

{

  "pack":{

      "pack_format":1,

      "description":"Infinity Bows textures"

  }

}

 

 

Link to comment
Share on other sites

in your block.class do this

 

 

 @SideOnly(Side.CLIENT)
    @Override
    public void registerIcons(IconRegister register) {
    	this.blockIcon = register.registerIcon(Reference.MOD_ID + ":" + (this.getUnlocalizedName().substring(5)));

 

replace "Reference.MOD_ID with with the name of the class that contains your modid (most likely your base class) and your modid

Link to comment
Share on other sites

(You don't need to override registerIcons, but it will work using the same details as my post)

 

this.setTextureName("MODID" + ":" + "BLOCKNAME")

 

Where MODID is whatever you want to name your assets folder and BLOCKNAME is whatever you want to name the texture file.  These must be lower case (if they're not, they will be converted).

 

Now go to /src/minecraft/assets and create a new folder there called MODID, inside that a folder called textures inside that a folder called blocks inside that add your texture file named BLOCKNAME.png

 

Voila.

 

http://www.minecraftforge.net/wiki/Icons_and_Textures

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.

Link to comment
Share on other sites

You haven't done any of the things suggested to you, your block class is still basically empty.  You haven't set its name, texture, hardness, resistance, or anything.

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.

Link to comment
Share on other sites

I did it in the Main Mod Class(InfinityBow.java) , It works if I do it in another class ?

 

And Can I put the texture somewhere else than the minecraft texture directory (in a directory for my mod in a folder in an otherplace than minecraft texture (or is thant when the mod is release?)?)

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

    • I have a problem, I am trying to put two different effects to two different armors but when I run it only the emerald armor effect works. This is the code public class ModArmorItem extends ArmorItem{ private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE,200, 1,false,false, true)) .put(ModArmorMaterials.OBSIDIAN, new MobEffectInstance(MobEffects.FIRE_RESISTANCE,200, 1,false,false, true)).build(); public ModArmorItem(ArmorMaterial pMaterial, Type pType, Properties pProperties) { super(pMaterial, pType, pProperties); } @Override public void onArmorTick(ItemStack stack, Level world, Player player){ if (!world.isClientSide()) { if (hasFullSuitOfArmorOn(player)) { evaluateArmorEffects(player); } } } private void evaluateArmorEffects(Player player) { for (Map.Entry<ArmorMaterial,MobEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()){ ArmorMaterial mapArmorMaterial = entry.getKey(); MobEffectInstance mapStatusEffect = entry.getValue(); if (hasCorrectArmorOn(mapArmorMaterial, player)) { addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect); } } } private void addStatusEffectForMaterial(Player player, ArmorMaterial mapArmorMaterial, MobEffectInstance mapStatusEffect) { boolean hasPlayerEffect = player.hasEffect(mapStatusEffect.getEffect()); if (hasCorrectArmorOn(mapArmorMaterial, player) && !hasPlayerEffect) { player.addEffect(new MobEffectInstance(mapStatusEffect)); } } private boolean hasCorrectArmorOn(ArmorMaterial material, Player player) { for (ItemStack armorStack : player.getInventory().armor){ if (!(armorStack.getItem() instanceof ArmorItem)) { return false; } } ArmorItem helmet = ((ArmorItem)player.getInventory().getArmor(3).getItem()); ArmorItem breastplace = ((ArmorItem)player.getInventory().getArmor(2).getItem()); ArmorItem leggins = ((ArmorItem)player.getInventory().getArmor(1).getItem()); ArmorItem boots = ((ArmorItem)player.getInventory().getArmor(0).getItem()); return helmet.getMaterial() == material && breastplace.getMaterial() == material && leggins.getMaterial() == material && boots.getMaterial() == material; } private boolean hasFullSuitOfArmorOn(Player player){ ItemStack helmet = player.getInventory().getArmor(3); ItemStack breastplace = player.getInventory().getArmor(2); ItemStack leggins = player.getInventory().getArmor(1); ItemStack boots = player.getInventory().getArmor(0); return !helmet.isEmpty() && !breastplace.isEmpty() && !leggins.isEmpty() && !boots.isEmpty(); } } Also when I place two effects on the same armor, the game crashes. Here is the crash file. The code is the same, only this part is different   private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE,200, 1,false,false, true)) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.FIRE_RESISTANCE,200, 1,false,false, true)).build(); I hope you guys can help me. Thanks.
    • I removed all related embeddium and oculus mods, i just tested it by disconnecting and the error happened again. heres the report https://pastebin.com/1kcR5wAt   EDIT: i tried removing xaeros and also smoothboot thinking there may be an issue there, nothing, heres that report too. https://pastebin.com/zQS7i9rM
    • Hi, I need suggestions. I am a beginner in Minecraft Modding. I would like to apply custom effects to some armors, something like: more chance to drop seeds, change zombie awareness, drop more pieces of wood when chopping logs, and things like that. How would you recommend me to do it, is there any library that has something similar and which ones would you recommend me?.
    • "downloading minecraft server failed, invalid Checksum. try again, or manually place server.jar to skip download"    
    • You have to create an Entity class called PlayerPart and use multiple of them to make the different parts of the player. See EnderDragonPart.java source code. The green hitboxes of the dragon are all EnderDragonParts
  • Topics

×
×
  • Create New...

Important Information

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