Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to change the height of the bed?


MikeDark
 Share

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • It doesn't work even if I remove every mod Please help
    • Hi, so I was making an item that sends info to the server to do some work, and I want the server to send the client back the results? How do I do that? Here is my code:   The snippet that sends the packet to the server SimpleChannelNetwork.CHANNEL.sendToServer(new CreateStructureCompass("fortress"));   The file that manage the traffic package io.github.bossmania.NetherandEndMaps.core.network; import io.github.bossmania.NetherandEndMaps.NetherandEndMaps; import io.github.bossmania.NetherandEndMaps.core.network.message.CreateStructureCompass; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.simple.SimpleChannel; public class SimpleChannelNetwork { public static final String NETWORK_VERSION = "0.1.0"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(NetherandEndMaps.MOD_ID, "network"), () -> NETWORK_VERSION, version -> version.equals(NETWORK_VERSION), version -> version.equals(NETWORK_VERSION)); public static void init() { CHANNEL.registerMessage(0, CreateStructureCompass.class ,CreateStructureCompass::encode, CreateStructureCompass::decode, CreateStructureCompass::handle); } }   the code that handle the packet receive and where I want the server to send back a packet to the client package io.github.bossmania.NetherandEndMaps.core.network.message; import java.util.function.Supplier; import io.github.bossmania.NetherandEndMaps.common.items.TemporaryItem; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.feature.structure.Structure; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.fml.network.NetworkEvent; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; public class CreateStructureCompass { public String structureType; public CreateStructureCompass() { } //create the constructor and store the structureType public CreateStructureCompass(String structureType) { this.structureType = structureType; } //encode the message public static void encode(CreateStructureCompass message, PacketBuffer buffer) { buffer.writeString(message.structureType); } //decode the message public static CreateStructureCompass decode(PacketBuffer buffer) { return new CreateStructureCompass(buffer.readString()); } //execute function when message is sent to server public static void handle(CreateStructureCompass message, Supplier<NetworkEvent.Context> contextSupplier) { NetworkEvent.Context context = contextSupplier.get(); context.enqueueWork(() -> { //get the player and the server ServerPlayerEntity player = context.getSender(); ServerWorld SEWorld = player.getServerWorld(); //get the location of the structure BlockPos structureLocation = SEWorld.func_241117_a_(Structure.FORTRESS, player.getPosition(),100, false); //this is where I want the server to send structureLocation back to the player }); context.setPacketHandled(true); } }  
    • I cannot get an instance of MC Forge to run with either the vanilla launcher or GDLauncher, yet vanilla MC and Fabric MC work fine in both.  I am running the latest versions of everything, and no 1.18-compatible version of Forge will launch even though they all install without fail. Using the vanilla launcher I get exit code 0 and the following logs: Debug log Latest log With GDLauncher I get the following console output:  
    • In 1.15 and before, you could get the item being held/dragged by the cursor using PlayerInventory#getItemStack. This no longer seems to be the case. How do we do this now?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.