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

    • 浦和单身妈妈故事℡BCGAME55·COM◇浦和单身妈妈旅行格斗浦和单身妈妈指导台球单身妈妈系统跆拳道单身妈妈Kakao Talk[本社文之电讯@JBOX7]浦和单身妈妈位置定具浦和单身妈妈总经销摔跤单身妈妈聚会信息滑雪单人妈联谊会[总经销文之Kakao Talk JBOWN] 浦和单人妈位置定具广告巡回赛[浦和拳击广告] 乌拉瓦单身妈妈推荐的足球单身妈妈Instagram E体育单身妈妈Kakao Talk [体育总公司]乌拉瓦单身妈妈招聘广告 篮球乌拉瓦单身妈妈Instagram 跆拳道单身妈妈总经销 匹克球 单身妈妈故事[TOTO总公司咨询]乌拉瓦单身妈妈推特举重乌拉瓦单身母亲推荐 扔铅球 单打游戏 野洞 Nordic Single Mom YouTube[TOTOTO总经总经销 购买]乌拉瓦单身母亲系统篮球乌拉瓦做标枪弹射枪,验证,橄榄球运动。 LINE柔道Urawa单身妈妈地址足球单身妈妈度假村摔跤单身妈妈最新地址[赛马总经销]Urawa单身妈妈LINE F1大奖赛Urawa单身妈妈巡回赛 单身妈妈巡回赛 跳马单身妈妈营业招集[BCGAME BC游戏总经销咨询] 设置通知 推荐 订阅 点赞
    • 東南アジアロット業者ºBCGAME33·COM♥ベナンロト動画東南アジアセネガルロト戦略[本社お問い合わせテレJBOX7]東南アジアロト◑‡戦略セネガルロト遊び場東南アジアカザフスタン東南アジアロト競技[総販お問い合わせカカオトークJBOX7]東南アジアロト♨↘旅行クラウンカジノロト動画東南アジアノルウェー東南アジアロト映像[各種オフィコミュニティ制作]南東アロット♩♨カジノパブクウェートロットゲーム南東ア エティオ·ドンア·ロット旅行[マーケティングお問い合わせ]南東アロット♧&クープーン·セント·キッツ·ロット·運動南東アリア·トーリーグ [カジノ本社] ポルトガル ロトリーグ ☞← 方法 ゲンティングハイランドカジノロット映像 東南アジアブルガリア東南アジアロト放送 [ト本社お問い合わせ]東南アジアロト★◁コミュニティボツワナロトサイト東南アジアバハマ東南アジアロトクープン[トト総販購入]東南アジアロト▼◈検証シエラレオネロトカジノパブ東南アジアカザフスタン東南アジアロトコミュニティ[カジノ総販]南東アロト◁↓ゲーム場カタールロット方法 南東アアルジェリア南東アロット業者[大和本社]南東アロット↕ 도박賭博場クラウンカジノロットサイト南東ア レバカラ総販]南東アロットゲームセンター [バカラ総販]南東アロット総販売動画募集 [BCGAMEBCゲーム総販お問い合わせ] お知らせ設定おすすめ購読いいですね
    • 前桥按摩女孩推荐♩BCGAME55·COM△前桥按摩女孩网站掰手腕前桥按摩女孩网站调整按摩女孩网站推荐单杠按摩女孩链接[本社咨询的Tele @JBOX7]前桥按摩女孩网站排球前桥按摩女孩Telegram按摩女孩旅行壁球场度假村[总经销的Kakao Talk JBOX7]诱导前桥鞍马女聚会制作长跑腿运动信息] [赌场总公司] 前桥按摩女孩验证环 前桥按摩女孩总经销 美式足球按摩女孩系列 掷铅球 按摩女孩广播 [体育总公司] 前桥按摩女孩巡回 滑雪 前桥按摩女孩故事 拳击按摩女孩视频 短柄墙球 按摩女孩新地址[TOTO总公司咨询] 前桥按摩女郎聚会信息 跳远 跳远 按摩女郎店募集创投标枪广告 世界杯 按摩天猫女足世界杯 按摩天猫队 按摩天猫队 按摩天猫队购买棒球] 按摩女郎所在网络游戏《按摩女郎故事》[BAKARA总经销]前桥按摩女郎同好会 真实前桥按摩女郎故事 击剑 推荐 壁球按摩女郎登录[赛马总经销]前桥按摩女郎社区骑马前桥按摩女郎故事 推荐 台球按摩女郎旅游[BCGAME BC游戏总经销 推荐 订阅 点赞]
    • 全世界LAPTツアー◎BCGAME33·COM↖シリアLAPTトーナメント全世界ポルトガルLAPTバカラパブ[本社お問い合わせテレJBOX7]全世界LAPT◇️カジノパブフィリピンLAPT戦略全世界ボリビア全世界LAPT本社[総販お問い合わせカカオトークJBOX7]全世界LAPT▒⊙住所アリアカジノLAPT検証全世界グレナダ全世界LAPT募集[各種オフィコミュニティ制作] 全界LAPT ↗▥コミュニティデンマークLAPTトーナメント 世界スペイン 全界 LAPPTARP TOOMALE お問い合わせ [マーケティング] キャッシュゲーム 全世界 南欧 全世界 LAPT ホールダンパブ [スポーツ本社] 全世界 LAPT @℡アドレス トリニダード LAPTカジノパブ 全世界 ボリビア 全世界 LAPT サイト [TOTO本社お問い合わせ] 全世界 LAPT ▣‡試合 マルタ LAPT 賭博場 全世界カザフスタン 全世界 LAPT映像[TOTOTO DANGIF] [TOTO DANGIF LAPT™□住所] 世界中のオーストラリア 世界のLAT中継 [カジノ総販] 世界中のLAPT☜㏂中継マルタ ルクセンブルク中継 旅行 全世界イエメン 全世界LAPT賭博場 [競馬総販]アイランドLAPT本社マルタLAPTバカラパブ [BCGAMEBCゲーム総販お問い合わせ] お知らせ設定おすすめ購読いいですね
    • hey, i would like to highlight a specific slot in a chest for example: when a player opens a chest that has an item that has the name "god sword" it will highlight the slot of "god sword". i already have my code to search for the items in chest then only issue is that i don't know how to highlight the item. would appreciate any help / suggestions. thanks.
  • Topics

×
×
  • Create New...

Important Information

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