Jump to content

multiple textures/Recipe with metadata


majesticmadman98

Recommended Posts

I have this

 

package hat.blocks.palmblocks;

 

import javax.swing.Icon;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import hat.HAT;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

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

import net.minecraft.util.IIcon;

 

public class palmlog extends Block{

 

private static String textureName;

 

@SideOnly(Side.CLIENT)

private Icon topTexture;

 

public palmlog(String textureName){

super(Material.wood);

setHardness(1F);

setResistance(1.0F);

 

this.textureName = textureName;

}

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister reg){

this.blockIcon = reg.registerIcon(HAT.MODID + ":" + textureName);

this.topTexture = reg.registerIcon(HAT.MODID + ":" + textureName + "_Top");

}

@SideOnly(Side.CLIENT)

public Icon getIcon(int side, int meta){

if(side == 0 || side == 1){

return this.topTexture;

}

return this.blockIcon;

}

}

 

 

 

 

red=errors also in the main file

palmlog = new palmlog("Palm_Wood_Log").setBlockName("palmlog").setCreativeTab(hatblocksTab);

        GameRegistry.registerBlock(palmlog, "palmlog");

 

Link to comment
Share on other sites

Your setting textureName to null.. so it is returning null. Give it a location here:

 

palmlog = new palmlog(null).setBlockName("palmlog").setCreativeTab(hatblocksTab);

            GameRegistry.registerBlock(palmlog, "palmlog");

 

That null, needs to be a texture name.

Link to comment
Share on other sites

Hi

 

 

Dude, if you're getting an error it would probably help a lot if you tell us what the error message actually  is :-)

 

I guess the cause is probably this

 

import javax.swing.Icon;

 

Wrong import...

 

-TGG

there is no error message it's in eclipse which found and underlined the errors, and I'll check my imports tomorrow
Link to comment
Share on other sites

Also in 1.7.x aren't they called IIcon and IIconRegister?

You even imported the right classes, just missed the I in front of the names in your methods.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

ok i now have this copied from the normal log as it uses a rotated pillar block

 

package hat.blocks.palmblocks;

 

import javax.swing.Icon;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import hat.HAT;

import net.minecraft.block.Block;

import net.minecraft.block.BlockRotatedPillar;

import net.minecraft.block.material.Material;

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

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.IIcon;

 

public class palmlog extends BlockRotatedPillar{

 

@SideOnly(Side.CLIENT)

    public IIcon[] field_150167_a;

    @SideOnly(Side.CLIENT)

    public IIcon[] field_150166_b;

private static final String __OBFID = "CL_00000266";

   

  // sideicon =  Palm_Wood_Log_Side;

 

public palmlog() {

super(Material.wood);

  this.setHardness(2.0F);

      this.setStepSound(soundTypeWood);

 

}

 

@SideOnly(Side.CLIENT)

protected IIcon getSideIcon(int p_150163_1_) {

    return this.field_150167_a[p_150163_1_ % this.field_150167_a.length];

}

 

@SideOnly(Side.CLIENT)

    protected IIcon getTopIcon(int p_150161_1_)

    {

        return this.field_150166_b[p_150161_1_ % this.field_150166_b.length];

    }

 

 

 

}

 

 

or this

 

package hat.blocks.palmblocks;

 

import javax.swing.Icon;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import hat.HAT;

import net.minecraft.block.Block;

import net.minecraft.block.BlockRotatedPillar;

import net.minecraft.block.material.Material;

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

import net.minecraft.util.IIcon;

 

public class palmlog extends BlockRotatedPillar{

 

private static String textureName;

 

@SideOnly(Side.CLIENT)

private IIcon topTexture;

 

public palmlog(String textureName){

super(Material.wood);

setHardness(2.0F);

setResistance(1.0F);

setStepSound(soundTypeWood);

 

this.textureName = textureName;

 

 

}

@SideOnly(Side.CLIENT)

public void registerIcons(IIconRegister reg){

this.blockIcon = reg.registerIcon(HAT.MODID + ":" + textureName + "_Side.png");

this.topTexture = reg.registerIcon(HAT.MODID + ":" + textureName + "_Top.png");

}

@SideOnly(Side.CLIENT)

public IIcon getIcon(int side){

if(side == 0 || side == 1){

return this.topTexture;

}

return this.blockIcon;

}

@Override

protected IIcon getSideIcon(int var1) {

 

return null;

}}

 

 

 

 

Im aware that the if statement corrosponding to sides as in the one above doesnt work for a rotated pillar block, which is why i have a version with the copied code, i can't get textures to load in the world, the fields i pressume link to the texture name it's trying to pull but i dont know how to register these to pull my textures instead?

Link to comment
Share on other sites

Can you show your main class (where you initialize / register your block)?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

yup there you go

package hat;

 

 

import hat.blocks.dyeblocks.dyeblock1;

import hat.blocks.dyeblocks.dyeblock10;

import hat.blocks.dyeblocks.dyeblock11;

import hat.blocks.dyeblocks.dyeblock12;

import hat.blocks.dyeblocks.dyeblock13;

import hat.blocks.dyeblocks.dyeblock14;

import hat.blocks.dyeblocks.dyeblock15;

import hat.blocks.dyeblocks.dyeblock16;

import hat.blocks.dyeblocks.dyeblock2;

import hat.blocks.dyeblocks.dyeblock3;

import hat.blocks.dyeblocks.dyeblock4;

import hat.blocks.dyeblocks.dyeblock5;

import hat.blocks.dyeblocks.dyeblock6;

import hat.blocks.dyeblocks.dyeblock7;

import hat.blocks.dyeblocks.dyeblock8;

import hat.blocks.dyeblocks.dyeblock9;

import hat.blocks.palmblocks.palmlog;

import hat.blocks.palmblocks.palmplank;

import net.minecraft.block.Block;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.Mod;

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

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.registry.GameRegistry;

 

@Mod(modid = HAT.MODID, version = HAT.VERSION)

public class HAT

{

    public static final String MODID = "hat";

    public static final String VERSION = "1.0";

   

   

    @SidedProxy(clientSide = "hat.ClientProxy", serverSide = "hat.CommonProxy")

    public static CommonProxy proxy;

 

public static Block palmlog;

 

@EventHandler

        public void preInit(FMLPreInitializationEvent event){

//Palm Settings

        palmlog = new palmlog().setBlockName("palmlog").setCreativeTab(hatblocksTab);

        GameRegistry.registerBlock(palmlog, "palmlog");

}

 

 

Link to comment
Share on other sites

or

 

package hat;

 

 

import hat.blocks.dyeblocks.dyeblock1;

import hat.blocks.dyeblocks.dyeblock10;

import hat.blocks.dyeblocks.dyeblock11;

import hat.blocks.dyeblocks.dyeblock12;

import hat.blocks.dyeblocks.dyeblock13;

import hat.blocks.dyeblocks.dyeblock14;

import hat.blocks.dyeblocks.dyeblock15;

import hat.blocks.dyeblocks.dyeblock16;

import hat.blocks.dyeblocks.dyeblock2;

import hat.blocks.dyeblocks.dyeblock3;

import hat.blocks.dyeblocks.dyeblock4;

import hat.blocks.dyeblocks.dyeblock5;

import hat.blocks.dyeblocks.dyeblock6;

import hat.blocks.dyeblocks.dyeblock7;

import hat.blocks.dyeblocks.dyeblock8;

import hat.blocks.dyeblocks.dyeblock9;

import hat.blocks.palmblocks.palmlog;

import hat.blocks.palmblocks.palmplank;

import net.minecraft.block.Block;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.Mod;

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

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.registry.GameRegistry;

 

@Mod(modid = HAT.MODID, version = HAT.VERSION)

public class HAT

{

    public static final String MODID = "hat";

    public static final String VERSION = "1.0";

 

 

    @SidedProxy(clientSide = "hat.ClientProxy", serverSide = "hat.CommonProxy")

    public static CommonProxy proxy;

 

public static Block palmlog;

 

@EventHandler

        public void preInit(FMLPreInitializationEvent event){

//Palm Settings

            palmlog = new palmlog("Palm_Wood_Log").setBlockName("palmlog").setCreativeTab(hatblocksTab);

            GameRegistry.registerBlock(palmlog, "palmlog");

}

 

Link to comment
Share on other sites

also im creating view recipes for vanilla things such as beds and turning wool back into string, but only know how to do this for white wool, how can it be set to use all the colours? as i pressume if ||=or then 'new ItemStack(Blocks.wool, 1) || new Itemstack(Blocks.wool, 1, 1)' would work if i did for all 16 but is there a way to pull in one go

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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • 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;     }  
  • Topics

×
×
  • Create New...

Important Information

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