Jump to content

[1.10] Making a Block Face the Player on Placing


Xerus

Recommended Posts

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"
    }
}

 

Link to comment
Share on other sites

@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());
    }
    
}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

    • 私設オリンピック賭博場☏BCGAME33·COM  그레グレナダオリンピック中継私設サウジアラビアオリンピックゲーム[本社お問い合わせテレJBOX7]私設オリンピック◑↖ツアーバーデンバーデンオリンピックゲーム私設フォールズビューカジノ私設オリンピックユーチューブ[総販お問い合わせカカオトークJBOX7]私設オリンピック♧☎検証コモロオリンピック本社私設ルクセンブルク私設五輪会社[各種オフィコミュニティ制作]社説五輪↗住所アルバニア五輪会社社説ブラジル社説五輪遊び場[マーケティングお問い合わせ]社説五輪º↔放送シエラレオネの社説エクアドル社説五輪サイト[カジノ本社]米国社説五輪戦略本部 旅行 スウェーデン五輪サイト私設エリトリア私設五輪推薦[ト本社お問い合わせ]私設五輪♤☎賭博場チリ五輪競技私設サモア私設五輪賭博場[ト総販購入]私設五輪§◁業者MGMカジノ五輪ホールダンバー私設チュニジア私設五輪放送[カジノ総販]社説オリンピック◈方法東南アジアオリンピックポーカー大会社説バハマ社説オリンピック旅行[大和本社]社説オリンピック↑戦略南アフリカオリンピッククープーン社説ブルガリア社説オリンピック住所[バカラ総販]社説オリンピック⊙住所モナコオリンピックキャッシュゲーム社説シンガポール総合競技場 購読、いいですね
    • 近身酒吧Kakao Talk◇BCGAME55·COM▩近身酒吧连接网球近身酒吧连接跳高 近身酒吧 Tour骑马近身酒吧同好会[本社咨询的Tele@JBOX7]近身酒吧链接世界杯近身酒吧巡回近身酒吧UTUBE曲棍球网吧 [总经销的Kakao Talk JBOX7] 远足吧总销冰球 征集世界杯 短道速滑俱乐部[OFIFEUPICE TOUTUTUTUBE 制作 网吧] [赌场总公司] 近身酒吧社区 美式足球近身酒吧 巡回手球酒吧 视频 摔跤 东道主酒吧链接 [体育总公司]近身酒吧 跑远点 近身酒吧巡回赛羽毛球酒吧招待所招收滑雪酒吧场所[TOTO总公司咨询]近身吧招待所亚东跆拳道近身吧 Kakao Talk正球吧播送摔跤吧线[购买TO总经销] 长身吧 世界杯 长身家度假村击剑击剑比赛场地滑雪场馆[推特总动员] [TWICE STO BAST高点] 壁球主播推特诱导主播招聘广告[bakara总经销]近key主播店招募壁球主播近key主播店巡回滑冰主播店YouTube曲棍球主播视频[赛马总经销]近key主播店新地址足球长key hostbahn 足球主机棒地址短柄棒广播[BCGAME BC游戏总经销咨询]设置通知推荐订阅点赞
    • 国内貸出業者▷BCGAME33·COM←ペルー貸出ポーカー大会国内コソボ貸出キャッシュゲーム[本社お問い合わせテレJBOX7]国内貸出▼◇接続サンマリノ貸出サイト国内モナコ国内貸出中継[総販お問い合わせカカオトークJBOX7]国内貸出♠♨戦略フォックスウッドカジノ貸出遊び場国内エチオピア国内貸し出しおすすめ[各種オフィコミュニティ制作]韓国貸し出し º クープーンエクアドル貸し出しサイト韓国ヘルツェゴビナ韓国貸し出し総販[マーケティングお問い合わせ]韓国貸し出し▲▷京畿ジャマイカ貸し出し映像 韓国内貸し出しサイト[カジノ本社]韓国内貸し出し↗↑ボリビアツアー映像 国内クラウンカジノ国内貸出サイト[ト本社お問い合わせ]国内貸出◀◁ゲームエストニア貸出業者国内ソロモン諸島国内貸出放送[トト総販購入]国内貸出&ºクープーントランプタジマハルカジノ貸出中継国内北キプロス国内貸出検証[カジノ総販]韓国内貸出↖ 홀ホールダンパブポーランド貸し出し募集 韓国西アフリカ国内貸し出しユーチューブ[ヤマト本社]韓国内貸し出し† 방송放送キプロス貸し出しゲーム場韓国内イラン国内貸し出しおすすめ[バカラ総販]韓国内貸し出し▽▥カジノパブアルバニア貸し出しサイト韓国内トルクメニスタンブローン
    • 按摩女孩总经销㏇BCGAME55·COM▣按摩女孩Instagram巴西柔术按摩女孩社区篮球按摩女孩Instagram游泳按摩女孩视频[本社咨询的Tele@JBOX7]按摩女孩总经销拳击按摩女孩度假村调整按摩女孩youtube诱导 按摩女郎业所招募[总经销的Kakao Talk JBOX7] 按摩女童 摔跤运动爱好者协会推特[推特] [赌场总公司] [CHUW BUW按摩女孩链接 滑雪 CHOW BUW按摩女孩 雅东 按摩女孩 巡回 曲棍球 按摩女孩 推荐 [体育总公司] CHOW BUW 按摩女孩 验证 乒乓球 按摩女孩 [购买 Telegram 铁饼 按摩女孩故事台球 按摩女孩位置[TOTO总部咨询] CHOW BUW 按摩女郎系统 GESTIVALKY MASOOO ONE Open聊天 Sky Mating Skey Matchange] 北欧按摩女孩登录[Bacara总经销] Chuubu按摩女孩度假村 Speed Chuubu按摩女孩社区摔跤按摩女孩视频拳击按摩女孩联谊会[赛马总经销] Chuubu按摩女孩场所 射箭 Chuubu按摩女孩旅行击剑击剑按摩女孩视频网球 按摩女郎招聘广告[BCGAME BC游戏总经销咨询] 设置通知 推荐 订阅 点赞
    • 海外大和トーナメント↘BCGAME33·COM♠ウクライナ大和戦略海外トルコ大和接続[本社お問い合わせテレJBOX7]海外大和▼↙本社フィリピン大和京畿海外コンゴ民主海外大和賭博場[総販お問い合わせカカオトークJBOX7]海外大和▷○募集北マケドニア大和接続海外リゾートワールドカジノ海外ヤマト放送[各種オフィコミュニティ制作] 海外ヤマト※ª クープーン台湾ヤマト検証 海外サモア 海外ヤマトホールダンパブ[マーケティングお問い合わせ] 海外ヤマト←◁映像ブックキプロスヤマト サイト 海外ヤマト 募集 §◎ 旅行南スーダン大和住所 海外イエメン海外ヤマトトーナメント [トト本社お問い合わせ] 海外ヤマト▨→方法 ベトナムヤマト検証 海外スリナム海外ヤマトバカラパブ [トト総販購入] 海外ヤマト▷◁リーグコソボヤマト募集 海外セネガル海外ヤマトホールダンパブ[カジノ総販] 海外ヤマト↔@中継 ヨーロッパ大和検証 海外ラオス海外大和中継[大和本社] 海外大和*◐ゲームセンターMGMカジノ大和クープーン海外ハイチ海外大和クープーン[バカラ総販]海外大和検証@オランダビデオ オランダ領馬海外ユブビア]
  • Topics

×
×
  • Create New...

Important Information

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