Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I have custom blocks, and I'm trying to add slabs of them. I have the slab working, asides from the texture.

 

BlockSlab.class

 

 

package com.fallingkitten.abstractadditions.blocks;

 

import java.util.List;

import java.util.Random;

 

import com.fallingkitten.abstractadditions.lib.Constants;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockSlab;

import net.minecraft.block.material.Material;

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

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.init.Blocks;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.IIcon;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.world.World;

 

public class BlockBasaltStoneBrickSlab extends BlockSlab {

 

private String name = "basaltStoneBrickSlab";

 

public BlockBasaltStoneBrickSlab(String unlocalizedName, boolean isDoubleSlab, Material material) {

super(isDoubleSlab, material);

this.setBlockName(Constants.MODID + "_" + name);

        setBlockTextureName(Constants.MODID + ":" + name);

setHardness(20.0F);

setResistance(45.0F);

setHarvestLevel("pickaxe", 0);

this.setCreativeTab(CreativeTabs.tabBlock);

}

 

@Override

//This method returns the unlocalized name based on the metadata. It is canned by ItemSlab

public String func_150002_b(int metadata) {

switch (metadata & 7) {

default: return this.getUnlocalizedName();

}

}

 

@Override

public IIcon getIcon(int side, int meta) {

switch (meta & 7) {

default: return Blocks.stone.getIcon(0, 0);

}

}

 

@Override

public void registerBlockIcons(IIconRegister iconRegister){

this.blockIcon = iconRegister.registerIcon(Constants.MODID + ":" + "basaltStoneBrick");

}

 

@Override

@SuppressWarnings({ "unchecked", "rawtypes" })

public void getSubBlocks(Item item, CreativeTabs tab, List list) {

if (!this.field_150004_a) { //Only if this is a single slab

list.add(new ItemStack(item, 1, 0));

}

}

 

@Override

public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {

Block block = world.getBlock(x, y, z);

 

if (block == null) return null;

if (block == ModBlocks.basaltStoneBrickDouble_slab) block = ModBlocks.basaltStoneBrickSlab;

 

int meta = world.getBlockMetadata(x, y, z) & 7;

return new ItemStack(block, 1, meta);

}

 

@Override

public Item getItemDropped(int meta, Random rand, int fortune) {

return Item.getItemFromBlock(ModBlocks.basaltStoneBrickSlab);

}

 

@Override

public int quantityDropped(int meta, int fortune, Random random) {

return this.field_150004_a ? 2 : 1;

}

}

 

 

 

ItemSlab.class

 

 

package com.fallingkitten.abstractadditions.items;

 

import net.minecraft.block.Block;

import net.minecraft.item.ItemSlab;

 

import com.fallingkitten.abstractadditions.blocks.BlockBasaltStoneBrickSlab;

 

public class ItemBasaltStoneBrickSlab extends ItemSlab {

 

public ItemBasaltStoneBrickSlab(Block block, BlockBasaltStoneBrickSlab single_slab, BlockBasaltStoneBrickSlab double_slab, Boolean isDoubleSlab) {

super(block, single_slab, double_slab, isDoubleSlab);

}

 

}

 

 

 

Block.class (block that the slab is of)

 

 

package com.fallingkitten.abstractadditions.blocks;

 

import com.fallingkitten.abstractadditions.lib.Constants;

 

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

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

 

public class BlockBasaltStoneBrick extends Block

{

 

private String name = "basaltStoneBrick";

 

public BlockBasaltStoneBrick()

{

super(Material.rock);

this.setBlockName(Constants.MODID + "_" + name);

        setBlockTextureName(Constants.MODID + ":" + name);

GameRegistry.registerBlock(this, name);

this.setCreativeTab(CreativeTabs.tabBlock);

setHardness(20.0F);

setResistance(45.0F);

setHarvestLevel("pickaxe", 0);

}

}

 

 

 

ModBlocks.class

 

 

package com.fallingkitten.abstractadditions.blocks;

 

import com.fallingkitten.abstractadditions.items.ItemModBlockSlab;

import com.fallingkitten.abstractadditions.items.ItemBasaltStoneBrickSlab;

 

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

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.init.Blocks;

 

public class ModBlocks {

 

public static Block basaltStoneBrick;

 

public static Block basaltStoneBrickSlab;

public static Block basaltStoneBrickDouble_slab;

 

public static void init() {

 

basaltStoneBrick = new BlockBasaltStoneBrick();

 

basaltStoneBrickSlab = new BlockBasaltStoneBrickSlab("slab", false, Material.rock);

basaltStoneBrickDouble_slab = new BlockBasaltStoneBrickSlab("double_slab", true, Material.rock);

GameRegistry.registerBlock(basaltStoneBrickSlab, ItemBasaltStoneBrickSlab.class, "basaltStoneBrickSlab", basaltStoneBrickSlab, basaltStoneBrickDouble_slab, false);

GameRegistry.registerBlock(basaltStoneBrickDouble_slab, ItemBasaltStoneBrickSlab.class, "basaltStoneBrickDouble_slab", basaltStoneBrickSlab, basaltStoneBrickDouble_slab, true);

 

}

 

}

 

 

 

I think that's all the relevant bits? I get no errors or anything, it just looks like stone, and I'm not sure how to make it use the same texture as the Basalt Stone Brick. Google isn't proving very helpful.

If the texture doesn't show, a message is printed to the log.

 

You didn't include that bit.

 

That said:

Why do you bother doing this?

this.blockIcon = iconRegister.registerIcon(Constants.MODID + ":" + "basaltStoneBrick");

 

The whole point of setTextureName is so that in the iconRegistration method the call is made to getTextureName().

 setBlockTextureName(Constants.MODID + ":" + name);

If later you do this

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.

Ha, nice catch diesieben. :D

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.