net.minecraft.state.property.Properties Java Examples

The following examples show how to use net.minecraft.state.property.Properties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public BlockState getPlacementState(ItemPlacementContext placementContext) {
	final BlockState blockState = this.getDefaultState().with(FACING, placementContext.getPlayerFacing().getOpposite());
	if (blockState.contains(Properties.WATERLOGGED)) {
		final FluidState fluidState = placementContext.getWorld().getFluidState(placementContext.getBlockPos());
		return blockState.with(Properties.WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
	}
	
	return blockState;
}
 
Example #2
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState otherState, IWorld world, BlockPos pos, BlockPos otherPos) {
	if (state.contains(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED)) {
		world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
	}
	
	return super.getStateForNeighborUpdate(state, direction, otherState, world, pos, otherPos);
}
 
Example #3
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
	builder.add(HorizontalFacingBlock.FACING);
	
	if (HallowedConfig.TinyPumpkin.waterloggable) {
		builder.add(Properties.WATERLOGGED);
	}
}
 
Example #4
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public Fluid tryDrainFluid(IWorld world, BlockPos pos, BlockState state) {
	if (state.contains(Properties.WATERLOGGED)) {
		return Waterloggable.super.tryDrainFluid(world, pos, state);
	} else {
		return Fluids.EMPTY;
	}
}
 
Example #5
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public boolean tryFillWithFluid(IWorld world, BlockPos pos, BlockState blockState, FluidState fluidState) {
	if (blockState.contains(Properties.WATERLOGGED)) {
		return Waterloggable.super.tryFillWithFluid(world, pos, blockState, fluidState);
	} else {
		return false;
	}
}
 
Example #6
Source File: Protocol_1_12_2.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public boolean acceptBlockState(BlockState state) {
    Block block = state.getBlock();
    if (block == Blocks.TNT)
        return super.acceptBlockState(state.with(TntBlock.UNSTABLE, false)); // re-add unstable because it was absent from 1.13.0 :thonkjang:

    if (!super.acceptBlockState(state))
        return false;

    if (block instanceof LeavesBlock && state.get(LeavesBlock.DISTANCE) < 6)
        return false;
    if (block == Blocks.PISTON_HEAD && state.get(PistonHeadBlock.SHORT))
        return false;
    if (state.getEntries().containsKey(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED))
        return false;
    if (block == Blocks.LEVER) {
        WallMountLocation face = state.get(LeverBlock.FACE);
        Direction facing = state.get(LeverBlock.FACING);
        if ((face == WallMountLocation.FLOOR || face == WallMountLocation.CEILING) && (facing == Direction.SOUTH || facing == Direction.EAST))
            return false;
    }
    if (block instanceof TrapdoorBlock && state.get(TrapdoorBlock.POWERED))
        return false;
    if ((block == Blocks.OAK_WOOD || block == Blocks.SPRUCE_WOOD
            || block == Blocks.BIRCH_WOOD || block == Blocks.JUNGLE_WOOD
            || block == Blocks.ACACIA_WOOD || block == Blocks.DARK_OAK_WOOD)
            && state.get(PillarBlock.AXIS) != Direction.Axis.Y)
        return false;
    return true;
}
 
Example #7
Source File: MixinBlock.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @author B0undarybreaker
 */
@Deprecated
@Inject(method = "getFluidState", at = @At("HEAD"), cancellable = true)
private void getWaterloggedFluidState(BlockState state, CallbackInfoReturnable<FluidState> info) {
    if (state.contains(Properties.WATERLOGGED))
        info.setReturnValue(state.get(Properties.WATERLOGGED) ? Fluids.WATER.getDefaultState() : Fluids.EMPTY.getDefaultState());
}
 
Example #8
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 4 votes vote down vote up
public TinyPumpkinBlock(Settings blockSettings) {
	super(blockSettings);
	if (HallowedConfig.TinyPumpkin.waterloggable) {
		setDefaultState(getDefaultState().with(Properties.WATERLOGGED, false));
	}
}
 
Example #9
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public FluidState getFluidState(BlockState blockState) {
	return blockState.contains(Properties.WATERLOGGED) && blockState.get(Properties.WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(blockState);
}
 
Example #10
Source File: TinyPumpkinBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public boolean canFillWithFluid(BlockView blockView, BlockPos pos, BlockState state, Fluid fluid) {
	return state.contains(Properties.WATERLOGGED) && Waterloggable.super.canFillWithFluid(blockView, pos, state, fluid);
}
 
Example #11
Source File: TombstoneBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
	builder.add(HorizontalFacingBlock.FACING);
	builder.add(Properties.AGE_1);
}
 
Example #12
Source File: PropertyUtil.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Property get(String s) {
    if (s.equals("attached"))
        return (Property) Properties.ATTACHED;
    if (s.equals("bottom"))
        return (Property) Properties.BOTTOM;
    if (s.equals("conditional"))
        return (Property) Properties.CONDITIONAL;
    if (s.equals("disarmed"))
        return (Property) Properties.DISARMED;
    if (s.equals("drag"))
        return (Property) Properties.DRAG;
    if (s.equals("enabled"))
        return (Property) Properties.ENABLED;
    if (s.equals("extended"))
        return (Property) Properties.EXTENDED;
    if (s.equals("eye"))
        return (Property) Properties.EYE;
    if (s.equals("falling"))
        return (Property) Properties.FALLING;
    if (s.equals("hanging"))
        return (Property) Properties.HANGING;
    if (s.equals("has_bottle_0"))
        return (Property) Properties.HAS_BOTTLE_0;
    if (s.equals("has_bottle_1"))
        return (Property) Properties.HAS_BOTTLE_1;
    if (s.equals("has_bottle_2"))
        return (Property) Properties.HAS_BOTTLE_2;
    if (s.equals("has_record"))
        return (Property) Properties.HAS_RECORD;
    if (s.equals("has_book"))
        return (Property) Properties.HAS_BOOK;
    if (s.equals("inverted"))
        return (Property) Properties.INVERTED;
    if (s.equals("in_wall"))
        return (Property) Properties.IN_WALL;
    if (s.equals("lit"))
        return (Property) Properties.LIT;
    if (s.equals("locked"))
        return (Property) Properties.LOCKED;
    if (s.equals("occupied"))
        return (Property) Properties.OCCUPIED;
    if (s.equals("open"))
        return (Property) Properties.OPEN;
    if (s.equals("persistent"))
        return (Property) Properties.PERSISTENT;
    if (s.equals("powered"))
        return (Property) Properties.POWERED;
    if (s.equals("short"))
        return (Property) Properties.SHORT;
    if (s.equals("signal_fire"))
        return (Property) Properties.SIGNAL_FIRE;
    if (s.equals("snowy"))
        return (Property) Properties.SNOWY;
    if (s.equals("triggered"))
        return (Property) Properties.TRIGGERED;
    if (s.equals("unstable"))
        return (Property) Properties.UNSTABLE;
    if (s.equals("waterlogged"))
        return (Property) Properties.WATERLOGGED;
    if (s.equals("fluidlevel"))
        return (Property) Properties.LEVEL_1_8;
    if (s.equals("level_15"))
        return (Property) Properties.LEVEL_15;
    return null;
}