Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

hello,I am making an object similar to glass_pane.But their status seems to be a bit problematic

 

QQ%E6%88%AA%E5%9B%BE20211209214606.png

 

 

  • Author
1 minute ago, diesieben07 said:

SHow your code.

package ocean.chinacraft.common.block.decoration;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FourWayBlock;
import net.minecraft.block.PaneBlock;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.StateContainer;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import ocean.chinacraft.common.block.properties.PropertiesMisc;

/**
 * 木窗格
 *
 * @author zhang
 * @since 2021/12/9
 */
public class WoodWindow extends FourWayBlock {

    public WoodWindow() {
        super(1.0F, 1.0F, 16.0F, 16.0F, 16.0F, PropertiesMisc.defaultWindow());
        this.registerDefaultState(this.stateDefinition.any().setValue(NORTH, Boolean.FALSE).setValue(EAST,
                Boolean.FALSE).setValue(SOUTH, Boolean.FALSE).setValue(WEST,
                Boolean.FALSE).setValue(WATERLOGGED, Boolean.FALSE));
    }

    @Override
    public BlockState getStateForPlacement(BlockItemUseContext context) {
        IBlockReader iblockreader = context.getLevel();
        BlockPos blockpos = context.getClickedPos();
        FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos());
        BlockPos blockpos1 = blockpos.north();
        BlockPos blockpos2 = blockpos.south();
        BlockPos blockpos3 = blockpos.west();
        BlockPos blockpos4 = blockpos.east();
        BlockState blockstate = iblockreader.getBlockState(blockpos1);
        BlockState blockstate1 = iblockreader.getBlockState(blockpos2);
        BlockState blockstate2 = iblockreader.getBlockState(blockpos3);
        BlockState blockstate3 = iblockreader.getBlockState(blockpos4);
        return this.defaultBlockState().setValue(NORTH, this.attachsTo(blockstate,
                blockstate.isFaceSturdy(iblockreader, blockpos1, Direction.SOUTH))).setValue(SOUTH,
                this.attachsTo(blockstate1, blockstate1.isFaceSturdy(iblockreader, blockpos2,
                        Direction.NORTH))).setValue(WEST, this.attachsTo(blockstate2,
                blockstate2.isFaceSturdy(iblockreader, blockpos3, Direction.EAST))).setValue(EAST,
                this.attachsTo(blockstate3, blockstate3.isFaceSturdy(iblockreader, blockpos4,
                        Direction.WEST))).setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER);
    }

    @Override
    public BlockState updateShape(BlockState p_196271_1_, Direction p_196271_2_, BlockState p_196271_3_,
                                  IWorld p_196271_4_, BlockPos p_196271_5_, BlockPos p_196271_6_) {
        if (p_196271_1_.getValue(WATERLOGGED)) {
            p_196271_4_.getLiquidTicks().scheduleTick(p_196271_5_, Fluids.WATER,
                    Fluids.WATER.getTickDelay(p_196271_4_));
        }

        return p_196271_2_.getAxis().isHorizontal() ? p_196271_1_.setValue(PROPERTY_BY_DIRECTION.get(p_196271_2_),
                Boolean.valueOf(this.attachsTo(p_196271_3_, p_196271_3_.isFaceSturdy(p_196271_4_, p_196271_6_,
                        p_196271_2_.getOpposite())))) : super.updateShape(p_196271_1_, p_196271_2_, p_196271_3_,
                p_196271_4_, p_196271_5_, p_196271_6_);
    }

    @Override
    public VoxelShape getVisualShape(BlockState p_230322_1_, IBlockReader p_230322_2_, BlockPos p_230322_3_,
                                     ISelectionContext p_230322_4_) {
        return VoxelShapes.empty();
    }

    @Override
    @OnlyIn(Dist.CLIENT)
    public boolean skipRendering(BlockState p_200122_1_, BlockState p_200122_2_, Direction p_200122_3_) {
        if (p_200122_2_.is(this)) {
            if (!p_200122_3_.getAxis().isHorizontal()) {
                return true;
            }

            if (p_200122_1_.getValue(PROPERTY_BY_DIRECTION.get(p_200122_3_)) && p_200122_2_.getValue(PROPERTY_BY_DIRECTION.get(p_200122_3_.getOpposite()))) {
                return true;
            }
        }

        return super.skipRendering(p_200122_1_, p_200122_2_, p_200122_3_);
    }

    public final boolean attachsTo(BlockState p_220112_1_, boolean p_220112_2_) {
        Block block = p_220112_1_.getBlock();
        return !isExceptionForConnection(block) && p_220112_2_ || block instanceof PaneBlock || block.is(BlockTags.WALLS);
    }

    @Override
    protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> p_206840_1_) {
        p_206840_1_.add(NORTH, EAST, WEST, SOUTH, WATERLOGGED);
    }
}


status:


{
  "multipart": [
    {
      "apply": {
        "model": "chinacraft:block/wood_window_post"
      }
    },
    {
      "when": {
        "north": "true"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_side"
      }
    },
    {
      "when": {
        "east": "true"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_side",
        "y": 90
      }
    },
    {
      "when": {
        "south": "true"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_side_alt"
      }
    },
    {
      "when": {
        "west": "true"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_side_alt",
        "y": 90
      }
    },
    {
      "when": {
        "north": "false"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_noside"
      }
    },
    {
      "when": {
        "east": "false"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_noside_alt"
      }
    },
    {
      "when": {
        "south": "false"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_noside_alt",
        "y": 90
      }
    },
    {
      "when": {
        "west": "false"
      },
      "apply": {
        "model": "chinacraft:block/wood_window_noside",
        "y": 270
      }
    }
  ]
}

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.