Jump to content

How to change the height of the bed?


MikeDark

Recommended Posts

I am creating a tent and she is already fully ready, but I'm suffering from a little bug at bedtime where the player is flying, I tried to give a search but could not find where make the change and would your help...

 

Bug

 

 

 

3W5biT5.png

 

 

 

My tent code:

 

 

 

 

package mike.scoutcraft.blocks;

import java.util.Iterator;
import java.util.List;
import java.util.Random;

import mike.scoutcraft.main.ScoutCraft;
import mike.scoutcraft.tileentity.TileEntityBarracaVermelha;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlocoBarracaVermelha extends BlockContainer {

public BlocoBarracaVermelha() {
	super(Material.cloth);
	this.setBlockName("BarracaVermelha");
    this.setResistance(1);
    this.setHardness(0.3F);
    this.setStepSound(soundTypeCloth);
    this.setCreativeTab(ScoutCraft.scoutcraft);
    this.setBlockTextureName("Minecraft" + ":" + "wool_colored_red");
    this.setBlockBounds(0F, 0F, 0F, 1F, 1.3F, 1F);
}

public boolean onBlockActivated(final World world, int x, final int y, int z, final EntityPlayer entityplayer, final int p_149727_6_, final float p_149727_7_, final float p_149727_8_, final float p_149727_9_){
	if (world.isRemote) {
            return true;
	}
	int i1 = world.getBlockMetadata(x, y, z);
            if (world.getBlock(x, y, z) != this) {
                return true;
        }
        if (!world.provider.canRespawnHere() || world.getBiomeGenForCoords(x, z) == BiomeGenBase.hell) {
            double d2 = x + 0.5;
            d2 = y + 0.1;
            double d3 = z + 0.5;
            world.setBlockToAir(x, y, z);
            final int k1 = BlockDirectional.getDirection(i1);
            if (world.getBlock(x, y, z) == this) {
                world.setBlockToAir(x, y, z);
                d2 = (d2 + x + 0.5) / 2.0;
                d2 = (d2 + y + 0.1) / 2.0;
                d3 = (d3 + z + 0.5) / 2.0;
            }
            world.newExplosion((Entity)null, (double)(x + 0.5f), (double)( + 0.5f), (double)(z + 0.5f), 5.0f, true, true);
            return true;
        }
        if (func_149976_c(i1)) {
            EntityPlayer entityplayer1 = null;
            Iterator iterator = world.playerEntities.iterator();
            while (iterator.hasNext())
            {
            	EntityPlayer entityplayer2 = (EntityPlayer)iterator.next();
                if (entityplayer2.isPlayerSleeping()) {
                    final ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation;
                    if (chunkcoordinates.posX != x || chunkcoordinates.posY != y || chunkcoordinates.posZ != z) {
                        continue;
                    }
                    entityplayer1 = entityplayer2;
                }
            }
            if (entityplayer1 != null) {
                entityplayer.addChatComponentMessage((IChatComponent)new ChatComponentTranslation("tile.bed.occupied", new Object[0]));
                return true;
            }
            func_149979_a(world, x, y, z, false);
        }
        final EntityPlayer.EnumStatus enumstatus = entityplayer.sleepInBedAt(x, y, z);
        if (enumstatus == EntityPlayer.EnumStatus.OK) {
            func_149979_a(world, x, y, z, true);
            return true;
        }
        if (enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW) {
            entityplayer.addChatComponentMessage((IChatComponent)new ChatComponentTranslation("tile.bed.noSleep", new Object[0]));
        }
        else if (enumstatus == EntityPlayer.EnumStatus.NOT_SAFE) {
            entityplayer.addChatComponentMessage((IChatComponent)new ChatComponentTranslation("tile.bed.notSafe", new Object[0]));
        }
        return true;
    }

  public int getRenderType() {
        return -1;
    }
    
    public boolean renderAsNormalBlock() {
        return false;
    }
    
    public boolean isOpaqueCube() {
        return false;
    }
    
    public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block block) {
        final int l = world.getBlockMetadata(x, y, z);
        final int i1 = BlockDirectional.getDirection(l);
        if (world.getBlock(x, y, z) != this) {
        	world.setBlockToAir(x, y, z);
            if (!world.isRemote) {
                this.dropBlockAsItem(world, x, y, z, l, 0);
            }
        }
    }
    
    public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_) {
        return Item.getItemFromBlock(SCBlocos.BlocoBarracaVermelha);
    }
    
    public static boolean func_149976_c(final int p_149976_0_) {
        return (p_149976_0_ & 0x4) != 0x0;
    }
    
    public static void func_149979_a(final World p_149979_0_, final int p_149979_1_, final int p_149979_2_, final int p_149979_3_, final boolean p_149979_4_) {
        int l = p_149979_0_.getBlockMetadata(p_149979_1_, p_149979_2_, p_149979_3_);
        if (p_149979_4_) {	
            l |= 0x4;
        }
        else {
            l &= 0xFFFFFFFB;
        }
        p_149979_0_.setBlockMetadataWithNotify(p_149979_1_, p_149979_2_, p_149979_3_, l, 4);
    }
    
    public static ChunkCoordinates func_149977_a(final World p_149977_0_, final int p_149977_1_, final int p_149977_2_, final int p_149977_3_, int p_149977_4_) {
        final int i1 = p_149977_0_.getBlockMetadata(p_149977_1_, p_149977_2_, p_149977_3_);	        
        return null;
    }
    
    public int getMobilityFlag() {
        return 1;
    }
    
    @SideOnly(Side.CLIENT)
    public Item getItem(final World p_149694_1_, final int p_149694_2_, final int p_149694_3_, final int p_149694_4_) {
        return Item.getItemFromBlock(SCBlocos.BlocoBarracaVermelha);
    }
    
    public boolean isBed(final IBlockAccess world, final int x, final int y, final int z, final EntityLivingBase player) {
        return this == SCBlocos.BlocoBarracaVermelha;
    }
    
    public TileEntity createNewTileEntity(World world, int var2){
		return new TileEntityBarracaVermelha();
	}
    
    @Override
    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack){
    	if(entity == null){
    		return;
    	}	    		    	
    	int direction = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.5D) & 3;
    	world.setBlockMetadataWithNotify(x, y, z, direction, 0);
    }
}

 

 

 

 

Link to comment
Share on other sites

Hey,

I saw that you block height was 1.3F. Looking at the (somewhat dark) picture, it seems like the player is laying at that height. So might it fix this if you would lower that number.

 

Let me know if this helped.

 

Good luck!

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

that shouldn't solve the problem indeed. if you take a look at "sleepInBedAt()" in the "EntityPlayer.class", it sets the player size, offset and position. so one of these three (or all of them) are skipped during the event 'sleeping'. try to set it manualy for the player.

also a quick question, your are calling a function "func_149979_a". I might be blind, but where exactualy is it from, and what is the function of it?

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

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

    • I was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
  • Topics

×
×
  • Create New...

Important Information

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