Jump to content

[SOLVED] Stairs of Metadata Blocks (Not stairs with metadata sub blocks)


Recommended Posts

Posted

Disclaimer: I am new to both Java and Forge. Probably I'm overlooking many things. I thank you for your patience!

 

Is it possible to make stairs out of only specific metadata sub blocks?

 

I have functioning stairs out of metadata sub blocks, but it makes stairs for each sub block, all of them with the first sub block's texture. Is there a way to specify which sub block to make stairs out of, in the same way you specify which sub block to use in crafting recipes? The stairs constructor doesn't call for, and doesn't accept, a metadata value. I tried changing the constructor in my own stair class (the class that extends BlockStairs), but that didn't go over so well. Maybe if I add a constructor that handles metadata?

 

Here's example code with working stairs from metadata blocks, but too many of them, and mostly the wrong texture (Don't mind the bacon; it's a result of being able to put any string I wanted as the mod title, which people should probably not let me do):

 

Block Class:

public class BaconBlocks {

public static String[] deathstoneNames = {
	"Deathstone", "Cracked Deathstone", "Condensed Deathstone", "Smooth Deathstone", "Deathstone Brick", "Carved Deathstone"
};

//add blocks -----------------------------------------------------------------------------------------------------------------------------------------
public static Block deathstone;

public static BlockStairs deathstoneStairs;
public static BlockStairs smoothDeathstoneStairs;
public static BlockStairs deathstoneBrickStairs;

@Init
public static void init() {

	//initialize blocks -------------------------------------------------------------------------------------------------------------------------------
	deathstone = new BlockDeathstone(BlockIDs.deathstone, Material.cactus).setUnlocalizedName("deathstone");

	deathstoneStairs = new StairBacon(BlockIDs.deathstoneStairs, BaconBlocks.deathstone, 0);
	smoothDeathstoneStairs = new StairBacon(BlockIDs.smoothDeathstoneStairs, BaconBlocks.deathstone, 0);
	deathstoneBrickStairs = new StairBacon(BlockIDs.deathstoneBrickStairs, BaconBlocks.deathstone, 0);

	//register blocks ---------------------------------------------------------------------------------------------------------------------------------
	GameRegistry.registerBlock(deathstone, ItemBlockBacon.class, "Bacon" + (deathstone.getUnlocalizedName().substring(5)));

	GameRegistry.registerBlock(deathstoneStairs, "deathstoneStairs");
	GameRegistry.registerBlock(smoothDeathstoneStairs, "smoothDeathstoneStairs");
	GameRegistry.registerBlock(deathstoneBrickStairs, "deathstoneBrickStairs");

	//name blocks -------------------------------------------------------------------------------------------------------------------------------------
	for (int i = 0; i< deathstoneNames.length; i++)
	{LanguageRegistry.addName(new ItemStack(deathstone, 1, i), deathstoneNames[i]);
	}	

	LanguageRegistry.addName(deathstoneStairs, "Deathstone Stairs");
	LanguageRegistry.addName(smoothDeathstoneStairs, "Smooth Deathstone Stairs");
	LanguageRegistry.addName(deathstoneBrickStairs, "Deathstone Brick Stairs");

	//set block harvest level -------------------------------------------------------------------------------------------------------------------------
	MinecraftForge.setBlockHarvestLevel(deathstone, "pickaxe", 3);
	MinecraftForge.setBlockHarvestLevel(deathstoneStairs, "pickaxe", 3);
	MinecraftForge.setBlockHarvestLevel(smoothDeathstoneStairs, "pickaxe", 3);
	MinecraftForge.setBlockHarvestLevel(deathstoneBrickStairs, "pickaxe", 3);

}
}

 

Deathstone Class:

public class BlockDeathstone extends Block {

public BlockDeathstone(int id, Material material) {
	super(id, material);
	setStepSound(Block.soundStoneFootstep);
	setHardness(4.0F);
	setResistance(5.0F);
	setCreativeTab(CreativeTabs.tabBlock);
	setLightValue(1.0F);
}

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
        float f = 0.0625F;
        return AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + f), (double)par3, (double)((float)par4 + f), (double)((float)(par2 + 1) - f), (double)((float)(par3 + 1) - f), (double)((float)(par4 + 1) - f));
    }

public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
        par5Entity.attackEntityFrom(DamageSource.lava, 3);
}

@SideOnly(Side.CLIENT)
private Icon[] icons;

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{    	   
	icons = new Icon[5];

	icons[0] = par1IconRegister.registerIcon("deathstone");
	icons[1] = par1IconRegister.registerIcon("condensedDeathstone");
	icons[2] = par1IconRegister.registerIcon("smoothDeathstone");
	icons[3] = par1IconRegister.registerIcon("deathstoneBrick");
	icons[4] = par1IconRegister.registerIcon("carvedDeathstone");
}


@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2) {
	return icons[par2];
}

public int quantityDropped(Random random){
	return 1;
}

public int damageDropped(int metadata)
{
     return metadata;
}

@SideOnly(Side.CLIENT)
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
	for (int var4 = 0; var4 < 5; ++var4)
	{
		par3List.add(new ItemStack(par1, 1, var4));
	}
}
}

 

ItemBlock Class:

public class ItemBlockBacon extends ItemBlock
{
public ItemBlockBacon(int par1)
{
	super(par1);
	setHasSubtypes(true);
}

public String getUnlocalizedName(ItemStack itemstack)
{
	String name = "";
	switch(itemstack.getItemDamage())
	{
	case 0:
	{
		name = "deathstone";
		break;
	}
	case 1:
	{
		name = "crackedDeathstone";
		break;
	}
	case 2:
	{
		name = "condensedDeathstone";
		break;
	}
	case 3:
	{
		name = "smoothDeathstone";
		break;
	}
	case 4:
	{
		name = "deathstoneBrick";
		break;
	}
	case 6:
	{
		name = "carvedDarkstone";
		break;
	}
	default: name = "broken";
	}
	return getUnlocalizedName() + "." + name;
}

public int getMetadata(int par1)
{
	return par1;
}
}

 

Stair Class:

public class StairBacon extends BlockStairs {

protected StairBacon(int par1, Block par2Block, int par3) {
	super(par1, par2Block, par3);
	// TODO Auto-generated constructor stub
}

public void updateIcons(IconRegister par1iconregister){
	this.blockIcon = par1iconregister.registerIcon("Bacon.BLOCK_ID");
	}

}

 

Have any ideas how I could get this to work? I have way too many blocks for me not to use metadata blocks, but I would really like to have stairs of some of them. I'll keep fiddling with things in the meantime.

Posted

Indeed. That's what I have done with the Deathstone block -- it has five metadata sub blocks. What I'm trying to do now is make stair blocks out of only three of those sub blocks. Stair blocks with their own IDs. So, there's one ID for all the Deathstone blocks, then one ID each for Deathstone Stairs, Smooth Deathstone Stairs, and Deathstone Brick stairs.

 

But I can't reference the individual sub blocks. So right now each instance of stairs that points toward Deathstone creates 5 stair blocks, all with the same texture.

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

    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • Same issue - I have no idea
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
    • un server de armas realista.  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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