1

[Help] Exact copy of a crafting table...

Unlocked's Avatar Unlocked8/31/14 5:21 pm
9/3/2014 8:00 pm
Unlocked's Avatar Unlocked
Hi. I want to make a crafting table/workbench/whatever that acts EXACTLY the same as the vanilla one, but I want to retexture my version. The following is my code:

package com.unlocked.stone_bricks.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.block.BlockWorkbench;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

public class CraftingBrick extends Block
{

private static final String __OBFID = "CL_00000221";

public CraftingBrick(boolean inverted)
{
super(Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setHardness(1.5f);
this.setResistance(10f);
if (inverted){
this.setBlockName("crafting_brick_inverted");
}
else{
this.setBlockName("crafting_brick");
}

if (inverted){
this.setBlockTextureName("stonebricks:invertedcrafting_brick");
}
else{
this.setBlockTextureName("stonebricks:crafting_brick");
}
}


/**
* Called upon block activation (right click on the block.)
*/
@Override
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{

if (!p_149727_1_.isRemote)
{
return true;
}
else
{
p_149727_5_.displayGUIWorkbench(p_149727_2_, p_149727_3_, p_149727_4_);
return true;
}
}
}


It works... kind of. The GUI opens and I can craft with it but the item selection is messed up I can never tell what I'm selecting when I click. If anyone could help, it would be appreciated.

~Unlocked
Posted by Unlocked's Avatar
Unlocked
Level 28 : Expert Dragon
10

Create an account or sign in to comment.

12

dunem666
09/03/2014 7:14 am
Level 44 : Master Network
dunem666's Avatar
You dont need to copy the workbench code at all...

Just make a workbench2 = new workbench.... just extend the workbench class

that all pretty much
1
Unlocked
09/03/2014 8:00 pm
Level 28 : Expert Dragon
Unlocked's Avatar
I tried doing this although it appears that the BlockWorkbench class is protected.
1
searchndstroy
09/03/2014 4:09 am
Level 14 : Journeyman Modder
searchndstroy's Avatar
I hope you realise that reading obfuscated code is really hard to do. At this point I have no idea why
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)

is returning a boolean. I might be able to figure out why, but I don't know what any of those ints or floats are and what they are doing. I am also wondering why you did a useless if statement here:

if (inverted){
this.setBlockName("crafting_brick_inverted");
}
else{
this.setBlockName("crafting_brick");
}

if (inverted){
this.setBlockTextureName("stonebricks:invertedcrafting_brick");
}
else{
this.setBlockTextureName("stonebricks:crafting_brick");
}


Could've done this:

if (inverted) {
this.setBlockTextureName("stonebricks:invertedcrafting_brick");
this.setBlockName("crafting_brick_inverted");
} else {
this.setBlockTextureName("stonebricks:crafting_brick");
this.setBlockName("crafting_brick");
}

And two final things, I'm new to forge modding(so please correct me if I am wrong, and tell me why), but couldn't you just extend the craftingbench class..? Also, this class means absolutely nothing. From what I can tell, it is a block with a texture.
1
EsvDefcon
09/03/2014 1:49 am
Level 62 : High Grandmaster Programmer
EsvDefcon's Avatar
Firstly, you are using obfuscated code, and you haven't even bothered renaming all of the functions, etc. Make your code more legibly.

Secondly, you might as well make a new crafting bench, there's absolutely no point (from what you've posted) in making a duplicate vanilla crafting bench.

That aside, clean up your code, and then post it again. It will be much easier to see what's wrong with it.
1
Zitzabis
09/03/2014 12:05 am
Level 75 : Legendary Gent Programmer
Zitzabis's Avatar
What about...a resource pack. That allows you to use a crafting table normally but with a different texture.
Although, I know that's not what you're looking for...
1
Unlocked
09/03/2014 12:28 am
Level 28 : Expert Dragon
Unlocked's Avatar
I want the original crafting table to still exist.
1
Zitzabis
09/03/2014 12:31 am
Level 75 : Legendary Gent Programmer
Zitzabis's Avatar
Yeah...I figured that was the case.
1
funny bunny
09/03/2014 12:14 am
Level 31 : Artisan Dragonborn
funny bunny's Avatar
Yeah, I'm pretty sure that'd be way easier
1
Unlocked
09/03/2014 12:02 am
Level 28 : Expert Dragon
Unlocked's Avatar
BUMP!
1
Unlocked
09/01/2014 11:05 am
Level 28 : Expert Dragon
Unlocked's Avatar
bump
1
TheXFactor117
08/31/2014 5:26 pm
Level 60 : High Grandmaster Programmer
TheXFactor117's Avatar
Didn't even bother changing the function names?
1
Unlocked
08/31/2014 5:32 pm
Level 28 : Expert Dragon
Unlocked's Avatar
Everything there is referencing vanilla functions so that I wouldn't have to do all of the work of getting a custom GUI to work
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome