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 remember creating a bit of code before that worked for my campfire block - I tried to recreate that code from memory and it seems to not work. Am I missing something?

 

 

package gameslayar.practice.common.blocks;

import java.util.Random;

import gameslayar.practice.common.PracticeMain;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockCampfire extends Block {

private final String name = "campfireBlock";

//Basic Properties
public BlockCampfire() {
	super(Material.wood);
	setUnlocalizedName(PracticeMain.MODID + "_" + name);
	setCreativeTab(CreativeTabs.tabMisc);
	setHarvestLevel("axe", 0);
	setHardness(2);
	setLightLevel(4);
	setBlockBounds(0F, 0F, 0F, 1F, 0.59375F, 1F);
	System.out.println("SET!");

	GameRegistry.registerBlock(this, name);

}

//***


//Makes sure that all the blocks around are rendered as well because 
//this isn't a full 1x1x1 block
@Override
public boolean isOpaqueCube() {
	return false;
}
//Corrects lighting around the block
@Override
public boolean isFullCube() {
	return false;
}

//Particle effects. Fancy fire & smoke.
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, Random random) {
	System.out.println("Attempting..");
	float f1 = (float)(pos.getX()+0.5F);
	float f2 = (float)(pos.getY()+0.7F);
	float f3 = (float)(pos.getZ()+0.5F);
	float f4 = random.nextFloat() * 0.1F;
	float f5 = random.nextFloat() * -0.1F;

	world.spawnParticle(
			EnumParticleTypes.FLAME,
			(float)(f1+f4),
			(float)(f2),
			(float)(f3+f5),
			0.0D,
			0.0D,
			0.0D,
			new int[0]);
	System.out.println("Attempt finished.");
}


//***

public String getName() {
	return name;
}
}

 

 

PS - The console shows no sign of the

[i]System.out[/i]

messages I put in, it's like

randomDisplayTick

isn't being run at all

GameSlayar

Forgive my noobiness!

  • Author

Aha!

I was missing

IBlockState state,

!

 

Thanks so much, I was stressing so much over those silly particles :P

 

EDIT: For anyone else having a similar problem, the code should have been:

 

 

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random) {

 

GameSlayar

Forgive my noobiness!

Guest
This topic is now closed to further replies.

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.