Jump to content

How do I create a mountable block (for a chair)?


Skullmassarce7

Recommended Posts

So I am working on a furniture mod that consists of many things. One of them being chairs, I am unsure on how to make a player sit in it. I have the model, directional facing, texture, etc. all done. I just cannot seem to figure out how to make it mountable. May someone please explain to me how to do it?

 

For any developer's reference, here is my chair code:

 

[embed=425,349]package com.skm7.test.blocks;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.block.properties.IProperty;

import net.minecraft.block.properties.PropertyDirection;

import net.minecraft.block.state.BlockState;

import net.minecraft.block.state.IBlockState;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.util.BlockPos;

import net.minecraft.util.EnumFacing;

import net.minecraft.world.World;

 

 

public class Chair extends Block {

 

public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

 

public Chair(Material materialIn) {

super(materialIn);

this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));

}

 

@Override

public IBlockState getStateFromMeta(int meta) {

EnumFacing facing = EnumFacing.getFront(meta);

 

if(facing.getAxis()==EnumFacing.Axis.Y) {

facing=EnumFacing.NORTH;

}

 

return getDefaultState().withProperty(FACING, facing);

}

 

@Override

public int getMetaFromState(IBlockState state) {

return ((EnumFacing) state.getValue(FACING)).getIndex();

}

 

@Override

protected BlockState createBlockState() {

return new BlockState(this, new IProperty[]{FACING});

}

@Override

public IBlockState onBlockPlaced(World worldIn, BlockPos pos,

EnumFacing facing, float hitX, float hitY, float hitZ, int meta,

EntityLivingBase placer) {

return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());

}

 

@Override

public boolean isOpaqueCube()

{

return false;

}

 

 

}[/embed]

Link to comment
Share on other sites

So I am working on a furniture mod that consists of many things. One of them being chairs, I am unsure on how to make a player sit in it. I have the model, directional facing, texture, etc. all done. I just cannot seem to figure out how to make it mountable. May someone please explain to me how to do it?

 

For any developer's reference, here is my chair code:

 

[embed=425,349]package com.skm7.test.blocks;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.block.properties.IProperty;

import net.minecraft.block.properties.PropertyDirection;

import net.minecraft.block.state.BlockState;

import net.minecraft.block.state.IBlockState;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.util.BlockPos;

import net.minecraft.util.EnumFacing;

import net.minecraft.world.World;

 

 

public class Chair extends Block {

 

public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

 

public Chair(Material materialIn) {

super(materialIn);

this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));

}

 

@Override

public IBlockState getStateFromMeta(int meta) {

EnumFacing facing = EnumFacing.getFront(meta);

 

if(facing.getAxis()==EnumFacing.Axis.Y) {

facing=EnumFacing.NORTH;

}

 

return getDefaultState().withProperty(FACING, facing);

}

 

@Override

public int getMetaFromState(IBlockState state) {

return ((EnumFacing) state.getValue(FACING)).getIndex();

}

 

@Override

protected BlockState createBlockState() {

return new BlockState(this, new IProperty[]{FACING});

}

@Override

public IBlockState onBlockPlaced(World worldIn, BlockPos pos,

EnumFacing facing, float hitX, float hitY, float hitZ, int meta,

EntityLivingBase placer) {

return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());

}

 

@Override

public boolean isOpaqueCube()

{

return false;

}

 

 

}[/embed]

You need a mountable entity that is invisible.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I would start by looking at the minecart code to see how a player sits in a minecart.

 

One thing I can say, is that you must invoke sitting on the server side when the entity is placed in the world. You can also search Google with the terms Sittable Entity GitHub and see what you find in the results there.

 

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

    • The game crashed whilst exception ticking world Error: java.lang.NullPointerException: Cannot invoke "net.minecraft.resources.ResourceLocation.equals(Object)" because "this.lootTableId" is null Error given is above. I was already playing for around 15 minutes and wasn't doing anything specific or even breaking anything when the crashed happened. This is update 1.19.2 forge: 43.2.23 Mod list: ESSENTIAL Mod (by SparkUniverse_) Traveler's Titles (Forge) (by YUNGNICKYOUNG) Resourceful Config (by ThatGravyBoat) Dynamic Lights (by atomicstrykergrumpy) TenzinLib (by CommodoreThrawn) Nature's Compass (by Chaosyr) Library Ferret - Forge (by jtl_elisa) Cold Sweat (by Mikul) Simple Voice Chat (by henkelmax) Waystones (by BlayTheNinth) Carry On (by Tschipp) [Let's Do] Meadow (by satisfy) Creeper Overhaul (by joosh_7889) AutoRegLib (by Vazkii) Moonlight Lib (by MehVahdJukaar) AppleSkin (by squeek502) Xaero's World Map (by xaero96) Rotten Creatures (by fusionstudiomc) YUNG's API (Forge) (by YUNGNICKYOUNG) Village Artifacts (by Lothrazar) Right Click, Get Crops (by TeamCoFH) Supplementaries (by MehVahdJukaar) Automatic Tool Swap (by MelanX) Better Third Person (by Socolio) Supplementaries Squared (by plantspookable) Traveler's Backpack (by Tiviacz1337) Caelus API (Forge/NeoForge) (by TheIllusiveC4) Creatures and Beasts (by joosh_7889) Architectury API (Fabric/Forge/NeoForge) (by shedaniel) Quark Oddities (by Vazkii) Origins (Forge) (by EdwinMindcraft) Villager Names (by Serilum) GeckoLib (by Gecko) Realistic Bees (by Serilum) Illuminations Forge 🔥 (by dimadencep) Serene Seasons (by TheAdubbz) Critters and Companions (by joosh_7889) [Let's Do] Bakery (by satisfy) Falling Leaves (Forge) (by Cheaterpaul) Jade 🔍 (by Snownee) Collective (by Serilum) TerraBlender (Forge) (by TheAdubbz) [Let's Do] API (by Cristelknight) Towns and Towers (by Biban_Auriu) More Villagers (by SameDifferent) Biomes O' Plenty (by Forstride) Goblin Traders (by MrCrayfish) Corpse (by henkelmax) Tree Harvester (by Serilum) Balm (Forge Edition) (by BlayTheNinth) Mouse Tweaks (by YaLTeR) Sound Physics Remastered (by henkelmax) Xaero's Minimap (by xaero96) Just Enough Items (JEI) (by mezz) Terralith (by Starmute) Quark (by Vazkii) [Let's Do] Vinery (by satisfy) [Let's Do] Candlelight (by satisfy) Repurposed Structures (Neoforge/Forge) (by telepathicgrunt) Dusty Decorations (by flint_mischiff) Immersive Armors [Fabric/Forge] (by Conczin) Serene Seasons Fix (by Or_OS) Shutup Experimental Settings! (by Corgi_Taco) Skin Layers 3D (Fabric/Forge) (by tr7zw)
    • Make sure Java is running via Nvidia GPU https://windowsreport.com/minecraft-not-using-gpu/  
    • Also make a test with other Custom Launchers like AT Launcher, MultiMC or Technic Launcher
    • Embeddium and valkyrienskies are not working together - remove one of these mods With removing Embeddium, also remove Oculus, TexTrue's Embeddium Options and Embeddium Extras Or use Rubidium instead
  • Topics

×
×
  • Create New...

Important Information

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