Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to TerraFirmaCraft Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Dries007

      ATTENTION Forum Database Breach   03/04/2019

      There has been a breach of our database. Please make sure you change your password (use a password manager, like Lastpass).
      If you used this password anywhere else, change that too! The passwords themselves are stored hashed, but may old accounts still had old, insecure (by today's standards) hashes from back when they where created. This means they can be "cracked" more easily. Other leaked information includes: email, IP, account name.
      I'm trying my best to find out more and keep everyone up to date. Discord (http://invite.gg/TerraFirmaCraft) is the best option for up to date news and questions. I'm sorry for this, but the damage has been done. All I can do is try to make sure it doesn't happen again.
    • Claycorp

      This forum is now READ ONLY!   01/20/2020

      As of this post and forever into the future this forum has been put into READ ONLY MODE. There will be no new posts! A replacement is coming SoonTM . If you wish to stay up-to-date on whats going on or post your content. Please use the Discord or Sub-Reddit until the new forums are running.

      Any questions or comments can be directed to Claycorp on either platform.
Konlii

Can't get setBlock to work right with new block

6 posts in this topic

I am working on a mod to add more content to the Stone Age, with the stated goal of making all crafting as manual as possible to try to make it really feel like you're building this stuff by hand (plus there's not much you can do with a 2x2 crafting grid).  And hopefully some of this could remain useful throughout the rest of the game, as well.

 

The first part of this project is adding in a way to make a canoe through the following process:

  • Place three logs down end-to-end
  • Right-click each log with an axe to strip the bark off (which replaces each log with a "chipped log" block)
  • Place a layer of charcoal on the top of each log (this will form the three logs and connected charcoal into a single multiblock structure)
  • Light the charcoal (actually the multiblock structure) with a firestarter
  • Once the fire burns out, I'm thinking 8 hours later, you have a canoe
  • Once you put the canoe in water, you can't make move it forward or backward unless you have a paddle in your hand (in your actual hand, not just in your hotbar)
  • During heavy rain/thunderstorms, you will have some chance that your canoe will capsize every so many seconds, maybe a 25% chance every 5 seconds

Unfortunately, making everything a manual process makes the mod quite a bit more complicated and I still have a lot to learn about how TerraFirmaCraft works under the hood.  The upshot of this is that I am stuck about halfway through step 2.

 

 

I have a chipped log block that I can place down by hand just fine.

I have an event handler that checks when the player right clicks with an axe on a horizontal log.

My event handler uses setBlock to replace the horizontal log with a chipped log.

 

But that's not what happens.  Every time you click a horizontal log with an axe, it gets replaced by a Quartzite Cobblestone Wall.

 

If I change my code to replace it with a TFCBlock (thatch, for example) instead of my new block, it works perfectly.  And like I said above, I can still place my new block down by hand all day long.

 

I'm sure I am missing something important to make this work, but I just can't figure it out.  Can anybody help?

 

 

 

My block code:

public class BlockChippedLog extends BlockLog{	public BlockChippedLog()	{		super();		setBlockName(SACrafting.MODID + "_" + "chippedLog");		setHarvestLevel("axe",0);		setHardness(0.5F);		setStepSound(Block.soundTypeWood);		setCreativeTab(CreativeTabs.tabBlock);	}		@SideOnly(Side.CLIENT)	protected IIcon[] icons;	@SideOnly(Side.CLIENT)	@Override	public void registerBlockIcons(IIconRegister par1IconRegister)	{		this.icons = new IIcon[2];		this.icons[0] = par1IconRegister.registerIcon("terrafirmacraft:wood/trees/Oak Log Top");		this.icons[1] = par1IconRegister.registerIcon("terrafirmacraft:wood/WoodSheet/Oak");	}	@SideOnly(Side.CLIENT)	@Override	public IIcon getSideIcon(int metaD)	{		return this.icons[1];	}		@SideOnly(Side.CLIENT)	@Override	public IIcon getTopIcon(int metaD)	{		return this.icons[0];	}}

My event handler

public class SACraftingEventHandler {	@SubscribeEvent	public void UseAxe(PlayerInteractEvent event)	{		if (!event.world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.inventory.getCurrentItem() != null)			{			if (event.entityPlayer.inventory.getCurrentItem().getItem() instanceof ItemAxe && event.world.getBlock(event.x, event.y, event.z) instanceof BlockLogHoriz)			{			Block oldBlock = event.world.getBlock(event.x, event.y, event.z);			Block chippedLog = new BlockChippedLog();						event.world.setBlock(event.x, event.y, event.z, chippedLog);			}		}	}}
1

Share this post


Link to post
Share on other sites

Your block likely isn't registered in the block registry. We had this exact same issue with the bloom block turning into a quartzite wall.

 

Edit: At some point during forge's preInit of your mod you need to use the GameRegistry.registerBlock method to register your chipped log.

0

Share this post


Link to post
Share on other sites

Thanks for such a quick response!

 

I already am registering my block, though.  Am I doing it wrong?

@Mod(modid = SACrafting.MODID, version = SACrafting.VERSION)public class SACrafting {    public static final String MODID = "sacrafting";    public static final String VERSION = "0.1";    public static Block chippedLog;        SACraftingEventHandler events = new SACraftingEventHandler();        @EventHandler    public void preinit(FMLPreInitializationEvent event)    {    	MinecraftForge.EVENT_BUS.register(events);    	    	chippedLog = new BlockChippedLog();    	    	GameRegistry.registerBlock(chippedLog, "chippedLog");    }}
0

Share this post


Link to post
Share on other sites

Hey Konlii, I have started a modpack called Stone Age Craft. The main concept is very similar to yours, take a look there.

My idea is to create a mod to simulate Stone Age.

I want to expand the crafting grid as soon as possible to 3 x 3 , just because is very hard to create recipes just with the 2 x 2.

At the same time one of the key points of the mod is that Humankind had agriculture well established before metalurgy, so for now I am requiring a sandwich in the crafting grid to create metal tools. (Not the best solution).

As for using the grid to unlock wood and stone, my idea is to create a new item, Nails, they would be required to place wood blocks. So every time you want to place a wood block you need to have nails in your inventory.

There are two new tools the carpenters Hammer and the Trowell. You can use and need the hammer in your hotbar too place wood blocks.

The same way you need the trowell in your hotbar and mortar in your inventory to place stone blocks.

Those are just limitations, the main thing is to make it so people can create a farm and actually live in stone age, 

0

Share this post


Link to post
Share on other sites

Thanks, Djakuta.  Since I'm new to TFC I've been trying to read through a lot of old posts on the forum and I have read your Make Stone Age Longer thread.

 

I thought it had some really good ideas, especially on making straw more useful.  However, I pretty strongly disagree with adding any artificial limits on game progression; if you have the materials you should be able to progress as fast or as slow as you like.  The devs spend a lot of time trying to balance that stuff, and unless I find something I think feels broken, I would rather not mess with it arbitrarily.

 

The mod I am creating comes from the viewpoint that you shouldn't have to scrap a world just because you spawn in an area with no clay.  Clay is very useful, and I don't mind it being required for primitive ore smelting, but TFC as it stands right now does not have any pre-metal gameplay that's worth anything if you don't have access to clay.  And even with clay, before you start making metal tools, there's still not enough content in the stone age to make staying in it worthwhile.

 

More than that, there's a lot of stone-age technology that's still around here in the 21st century because it just works.  Straw hats and basket weaving are pretty ubiquitous throughout the world.  Dugout canoes have not changed in pretty much forever.  Sledges have mostly been replaced by wheeled carts, but there are still people who rely on them, especially in places where it snows enough that they are actually more mobile than anything on wheels could be.

0

Share this post


Link to post
Share on other sites

I understand. Good that we agree on adding content to the Stone Age.

BTW I just started learning moding, I was able to create blocks and items in vanilla, but am having a hard time setting up the work-space to make ad-dons for TFC. What would be the best way?

0

Share this post


Link to post
Share on other sites