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



×
×
  • Create New...

Important Information

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