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 want to have a normal Block that just auto-faces the player when placed, and tried using the code from the furnace but I couldnt get it to work. The Block gets textured right but it doesnt rotate

My Block Class:

 

public class BulkCore extends TEBlock {

    public static final PropertyDirection FACING = BlockHorizontal.FACING;
public BulkCore() {
	super(1);
}

    @Override
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    	super.onBlockPlacedBy(worldIn, pos, state, placer, stack);;
    	worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    }
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)    {
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }
    public IBlockState withRotation(IBlockState state, Rotation rot)
    {
        return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
    }
    public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
    {
        return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
    }
    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {FACING});
    }
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);
        if (enumfacing.getAxis() == EnumFacing.Axis.Y) enumfacing = EnumFacing.NORTH;
        return this.getDefaultState().withProperty(FACING, enumfacing);
    }
    public int getMetaFromState(IBlockState state)
    {
        return ((EnumFacing)state.getValue(FACING)).getIndex();
    }
    
}

 

 

blockstate file:

 

{
    "variants": {
        "facing=north": { "model": "simpleautomation:bulkcore" },
        "facing=south": { "model": "simpleautomation:bulkcore", "y": 180 },
        "facing=west":  { "model": "simpleautomation:bulkcore", "y": 270 },
        "facing=east":  { "model": "simpleautomation:bulkcore", "y": 90 }
    }
}

 

 

block model file:

 

{
    "parent": "block/orientable",
    "textures": {       
        "top":  "simpleautomation:blocks/bulkcrate",
        "front":"simpleautomation:blocks/bulkcore",
        "side": "simpleautomation:blocks/bulkcrate"
    }
}

 

  • Author

@Override, as far as I know, doesnt actually do anything just lets you know that you override

TEBlock is just a Block that provides a TileEntity, here the Code to be clear:

 

public class TEBlock extends BlockContainer {

int type;
public TEBlock(int typ) {
	super(typ==1?Material.WOOD:Material.ROCK);
	setHardness(1.5F);
	setHarvestLevel("pickaxe", 0);
	type=typ;
}

public TileEntity createNewTileEntity(World world, int meta){
	switch(type){
	case 0: return new FarmerTE();
	case 1: return new BulkTE();
	}
	return null;
 }

    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ){
    	player.openGui(main.instance, type, world, pos.getX(), pos.getY(), pos.getZ());
    	return true;
    }

    @Override
    public EnumBlockRenderType getRenderType(IBlockState state){
        return EnumBlockRenderType.MODEL;
    }
    
    @Override
    public void breakBlock(World world, BlockPos pos, IBlockState blockstate) {
        TEInventory te = (TEInventory) world.getTileEntity(pos);
        InventoryHelper.dropInventoryItems(world, pos, te);
        super.breakBlock(world, pos, blockstate);
    }


    @Override
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    	if (stack.hasDisplayName()) ((TEInventory)worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName());
    }
    
}

 

It lets you know if you duck up the method signature.

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.

  • Author

Ok i was just dumb and registered the Superclass as this Block  :-X

 

SOLVED

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.